Difference between revisions of "Mounting Root File System on External USB Drive"

From odroid US
Jump to: navigation, search
 
Line 76: Line 76:
  
 
</pre>
 
</pre>
 
  
 
=== Download Example Files to the Odroid-U2 ===  
 
=== Download Example Files to the Odroid-U2 ===  
Line 97: Line 96:
 
</pre>
 
</pre>
  
 +
Now we have two new files:
 +
<li>boot-thumb.txt  -- The source file for the u-boot script
 +
<li>boot-thumb.scr  -- The compiled u-boot script
 +
 +
Here is the boot-thumb file:
 +
<pre>
 +
setenv initrd_high "0xffffffff"
 +
setenv fdt_high "0xffffffff"
 +
setenv bootcmd "fatload mmc 0:1 0x40008000 zImage; fatload mmc 0:1 0x42000000 uInitrd; bootm 0x40008000 0x42000000"
 +
setenv bootargs "console=tty1 console=ttySAC1,115200n8 root=/dev/sda1 rootwait ro mem=2047M"
 +
boot
 +
</pre>
 +
 +
The kernel boot argument root= now points to the partition the root file system lives on.  Note: you don't have to use the disk-by-ID technique with a UUID used to identify the drive.  To boot the stock rootfs partition you would change the root=/dev/sda1 to root=/dev/mmcblk0p2 and re-compile the script.
 +
 +
Here is how I compiled the boot-thumb script:
 +
<pre>
 +
mkimage -T script -A arm -C none -n 'odroid-u2.Boot Thumb' -d boot-thumb.txt boot-thumb.scr
 +
</pre>
  
 
Move the USB drive to the odroid and reboot.
 
Move the USB drive to the odroid and reboot.

Latest revision as of 11:42, 1 February 2013

This tutorial shows how to mount your root file system on an external USB drive. It could be either a USB Hard Drive or a Thumb Drive.

Prepare the External Drive

Format the drive with an ext 4 file system and write a root file system image to it. For help in handling root file system images, please see Updating from Root File System Images.

There are many tools you might use to format the drive, but you need to be careful not to distroy any host drive.

Plug the drive into your Linux host, then use dmesg to see which drive designator is used.

dmesg | tail -n 10

Here we see the drive designator is /dev/sdc It happens to be formatted already, that is why we see the sdc1.

[1554360.507662] sd 21:0:0:0: [sdc] Mode Sense: 23 00 00 00
[1554360.508252] sd 21:0:0:0: [sdc] No Caching mode page present
[1554360.508256] sd 21:0:0:0: [sdc] Assuming drive cache: write through
[1554360.512161] sd 21:0:0:0: [sdc] No Caching mode page present
[1554360.512165] sd 21:0:0:0: [sdc] Assuming drive cache: write through
[1554360.539551]  sdc: sdc1
[1554360.542408] sd 21:0:0:0: [sdc] No Caching mode page present
[1554360.542412] sd 21:0:0:0: [sdc] Assuming drive cache: write through
[1554360.542415] sd 21:0:0:0: [sdc] Attached SCSI removable disk
[1554361.651882] EXT4-fs (sdc1): mounted filesystem with ordered data mode. Opts: (null)

For explaination purposes, I going to use sdX to you don't accidentally copy/paste the example instructions into your console and wreck your host.

Unmount the drive, just in case it was automounted.

sudo umount /dev/sdX*

Format the drive with ext4 layout

sudo mkfs.ext4 /dev/sdc1

We just created one partition taking up the whole external drive

Get a Root File System Image

If you don't have one, get one. This example gets a Debian Wheezy system that is set up to do native builds.

wget http://odroid.us/odroid/odroidu2/debian/odroidu2_20130104-debian-wheezy-devel-4-rootfs.tgz
wget http://odroid.us/odroid/odroidu2/debian/odroidu2_20130104-debian-wheezy-devel-4-rootfs.tgz.md5sum
md5sum -c odroidu2_20130104-debian-wheezy-devel-4-rootfs.tgz.md5sum

odroidu2_20130104-debian-wheezy-devel-4-rootfs.tgz: OK The md5sum checked OK.

Expand a root file system tarball to the external drive

mkdir mnt
sudo mount /dev/sdX1 mnt
cd mnt
sudo tar -xvzf ../odroidu2_20130104-debian-wheezy-devel-4-rootfs.tgz
cd ../
sync
sudo umount mnt


Mount the boot partition on the Odroid-U2

Mount the boot partition and move into it. Some root file systems will already have /boot mounted, if so you can skip the mount step. No harm done if you mount again.

mkdir /boot >/dev/null 2>&1
mount /dev/mmcblkp1 /boot
cd /boot

Download Example Files to the Odroid-U2

# Do this on the odroid
cd /boot
# Get the example files
wget http://odroid.us/odroid/users/osterluk/rfs-on-external-drive/rfs-on-external-drive.tgz
wget http://odroid.us/odroid/users/osterluk/rfs-on-external-drive/rfs-on-external-drive.tgz.md5sum
md5sum -c rfs-on-external-drive.tgz.md5sum
# Assuming the md5sum is correct, continue
tar -xvf rfs-on-external-drive.tgz
# copy existing boot script so you can switch back
cp boot.scr boot.scr.orig
# replace the existing script with the one that mounts the external drive
cp boot-thumb.scr boot.scr
sync

Now we have two new files:

  • boot-thumb.txt -- The source file for the u-boot script
  • boot-thumb.scr -- The compiled u-boot script Here is the boot-thumb file:
    setenv initrd_high "0xffffffff"
    setenv fdt_high "0xffffffff"
    setenv bootcmd "fatload mmc 0:1 0x40008000 zImage; fatload mmc 0:1 0x42000000 uInitrd; bootm 0x40008000 0x42000000"
    setenv bootargs "console=tty1 console=ttySAC1,115200n8 root=/dev/sda1 rootwait ro mem=2047M"
    boot
    

    The kernel boot argument root= now points to the partition the root file system lives on. Note: you don't have to use the disk-by-ID technique with a UUID used to identify the drive. To boot the stock rootfs partition you would change the root=/dev/sda1 to root=/dev/mmcblk0p2 and re-compile the script.

    Here is how I compiled the boot-thumb script:

    mkimage -T script -A arm -C none -n 'odroid-u2.Boot Thumb' -d boot-thumb.txt boot-thumb.scr
    
    Move the USB drive to the odroid and reboot.