Thursday, February 3, 2011

GuruPlug Plus Gets a New OS - Redux, part 3 (Fedora ARM on microSDHC)

Booting a Fedora ARM Root Filesystem from microSDHC
(this continues from the previous post)

Now we have a fabulous new kernel and shiny new uboot.  Time to get Fedora ARM working.

Although Fedora 12 is quite old at this point, I'm going to use it since the ARM packages for both Fedora 13, 14, and rawhide are incomplete.

My first thought was to partition the SD card with 3 partitions:  1) a partition to support /boot (about 512 MB), 2) an ext3 partition (about 2 GB) for the root filesystem (since you'll soon see that booting a logical volume is going to be too much work), and 3) a partition to be a physical volume for LVM for anything that I might want to mount later.

In the end I decided that I really didn't need /boot separate unless I was going to also be using LVM for the root filesystem.  The problem is that the Linux kernel by itself can not boot a filesystem on a logical volume.  You have to boot Linux with an initrd which loads the LVM modules, then boots from the root filesystem.  That's just too much effort at this point so I'm going to make the root filesystem ext3.  And that means that I won't need a separate /boot to hold the kernels.

This is what my microSDHC looks like:

# fdisk -l /dev/sde



Disk /dev/sde: 7973 MB, 7973371904 bytes

246 heads, 62 sectors/track, 1021 cylinders, total 15572992 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x5e8436c8



   Device Boot      Start         End      Blocks   Id  System

/dev/sde1              62     2120027     1059983   83  Linux

/dev/sde2         2120028    15572291     6726132   8e  Linux LVM

#

You can get a copy of the root filesystem here:  https://fedoraproject.org/wiki/Architectures/ARM/Using#Latest_Release:_Fedora_12

Assuming you've mounted your root filesystem (sde1 in my example) under /media/sdhc, you'll need to copy the contents of the pre-built root filesystem onto your SDHC card

# tar -jxf rootfs-f12.tar.bz2
# cp -ar rootfs-f12/* /media/sdhc/

Now we're going to need the major/minor numbers of the root filesystem to feed to the kernel through uboot.  But don't fret, it can be found quite easily if you don't know.  Go ahead and test boot the kernel and let it tell you what the available major/minors are:

Marvell>> nand read.e 0x6400000 0x100000 0x400000                              
                                                                               
NAND read: device 0 offset 0x100000, size 0x400000                             
 4194304 bytes read: OK                                                        
Marvell>> setenv bootargs console=ttyS0,115200 rootdelay=10                    
Marvell>> bootm 0x6400000                                                      
## Booting kernel from Legacy Image at 06400000 ...                            
   Image Name:   Linux-2.6.36                                                  
   Image Type:   ARM Linux Kernel Image (uncompressed)                         
   Data Size:    2947644 Bytes =  2.8 MB                                       
   Load Address: 00008000                                                      
   Entry Point:  00008000                                                      
   Verifying Checksum ... OK                                                   
   Loading Kernel Image ... OK                                                 
OK                                                                             
                                                                               
Starting kernel ...                                                            
                                                                               
Uncompressing Linux... done, booting the kernel.                               
Linux version 2.6.36 (kelly@speedy) (gcc version 4.4.3 (Sourcery G++ Lite er) )0
...
VFS: Cannot open root device "(null)" or unknown-block(2,0)                    
Please append a correct "root=" boot option; here are the available partitions:
1f00            1024 mtdblock0 (driver?)                                       
1f01            4096 mtdblock1 (driver?)                                       
1f02          519168 mtdblock2 (driver?)                                       
0810         7786496 sdb driver: sd                                            
  0811         1059983 sdb1                                                    
  0812         6726132 sdb2                                                    
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)


From this boot attempt, we can see that our SDHC card is sdb and the root partition that I created is sdb1 which has a major/minor of 0811.


With this info, we can now setup the uboot environment to boot this filesystem:

Marvell>> editenv x_bootargs_root                                              
edit: ubi.mtd=2 root=0811 rootdelay=10                                         
Marvell>> saveenv                                                              
Saving Environment to NAND...                                                  
Erasing Nand...                                                                
Erasing at 0x40000 -- 100% complete.                                           
Writing to Nand... done                                                        
Marvell>> reset                                                                
resetting ...


With a little luck, you'll now now a login prompt to your new Fedora 12 ARM system (default root password: "fedoraarm").

Fedora release 12 (Constantine)                                                
Kernel 2.6.36 on an armv5tel (/dev/ttyS0) 


There was probably a lot of complaints about modules, which you can fix by installing the kernel modules that you got from the same place as your kernel.  These should be untarred to the / directory (which installs them in /lib/modules).

Note: The pre-built rootfs you just booted has a guest user with no password.  Consider the security implications of this for your use case and take appropriate action.

Additional packages I needed to install to meet my goals:
  • cryptsetup-luks
  • device-mapper
  • lvm2
  • nfs-utils
  • rpcbind
Also, if you're trying to use the plug as a NFS server like I am, the kernel that is installed has the sunrpc functionality built in whereas Fedora assumes that it's a module to be loaded.  This will cause the startup scripts to emit an error.  This can be worked around by adding the following line to /etc/fstab:

rpc_pipefs              /var/lib/nfs/rpc_pipefs rpc_pipefs defaults     0 0

No comments:

Post a Comment