5

After searching google, I know you can let a external usb flash drive take over after booting from the SD or microSD card. I want to know what is the easiest way to boot from one usb drive but have multiple drives connected for other purposes (ex: storage: owncloud,bittorrent sync,etc). All the drives will be connected to the rpi using a powered 4 port hub.

The other devices will be a external usb harddrive, not a flash drive.

4 Answers 4

6

The default pi kernel may or may not have the right drivers built in to mount the external drive without the root filesystem,1 so the first thing you'll have to do is investigate that and if it doesn't, build a kernel that does. It's probably okay (various blog posts online imply a custom kernel is not generally needed), but this is important to note just in case.

Once you have that, make a copy of your primary partition (the 2nd one) from the SD card onto the HDD to test with. Do not do this naively while the pi is running. It should reflect the state of the filesystem while the system is off, so take the card out of the pi to copy it.

If you make the copy by duplicating the entire filesystem, you'll need to change the UUID, since otherwise it will be the same as the second partition on the SD card. To get the UUID under linux, if the partition is /dev/sdb3:

> blkid /dev/sdb3
/dev/sdb3: LABEL="whatever" UUID="8f30e12b-8a7c-4121-86f7-1134f39c66d5" TYPE="ext4"

If the UUIDs are the same, you need to change the one on the HDD. To do that: tune2fs -U random /dev/sdb3.

Next, edit cmdline.txt from the first partition on the SD card (the one that gets mounted as /boot). Change this part:

 root=/dev/mmcblk0p2

to:

 root=UUID=c2b2016e-629a-4010-bf1f-563fd4c50e72

Or whatever the new UUID is for the HDD partition. Don't accidentally add a newline into this file or anything. If all this doesn't work, all you have to do is change that back to what it was (/dev/mmcblk0p2).

The reason you need to use the UUID instead of the device node is unless you add a udev rule to set it, the device node of the HDD partition is unpredictable (although it may often be the same).

Finally, before you try this, edit the /etc/fstab on the HDD partition. Change this:

 /dev/mmcblk0p2  /

to:

UUID=c2b2016e-629a-4010-bf1f-563fd4c50e72 /

Leave everything else the same.


1. Modules can be either built-in or loadable. Loadable modules are .ko files in /lib/modules directories, which are part of the root filesystem. A just loaded kernel can't mount the root filesystem if it requires stuff from /lib/modules in order to do it. Those modules either have to be built-in to the kernel, or put into an initramfs.

2

You don't need to let a USB drive take over. A large SD card can hold the complete Linux installation.

What you can do, is to let the Pi mount the drives at various locations (like /mydisks/torrent) during boot time, and then configure the services you need to use to have their data on the appropriate disk.

Note that you will want ext4 or similar as file system on the disks so they are resilient against the Pi being power cycled.

1
  • I use Raspbian and configured it to mount a 4 TB Synology NAS. This gives all the Raspberries plenty of space and even additional swap space (via loopback devices on the NAS).
    – Black
    Dec 21, 2013 at 11:12
2

@conrad_heimbold is right, and editing /boot/cmdline.txt with the PARTUUID will actually boot your Pi.

However, he is wrong in one place. If you place quotemarks around the PARTUUID, your Pi will fail to boot, but if you remove them, it will boot up with no issues.

ie this works:

root=PARTUUID=abcdef01-01 rootfstype=f2fs rw rootwait BLAH BLAH BLAH

but this will fail (because of the quotemarks around PARTUUID="..."):

root=PARTUUID="abcdef01-01" rootfstype=f2fs rw rootwait BLAH BLAH BLAH
2

The default pi kernel can not handle UUIDs, only PARTUUIDs.

To be more detailed:

  • UUIDS depend on the file system of the partition
  • PARTUUIDS do NOT depend on the file system of the partition

This answer in an archwiki forum explains the difference between UUIDs and PARTUUIDs more detailed.

So if the default pi kernel does not support the mentioned file system, it will not work with the UUID - which is the case, according to the kernel source code provided here.

Therefore, the answer mentioned by @goldilocks will not work; you have to use the PARTUUID mentioned with sudo blkid /dev/sdb3 instead of the UUID; and you also have to write root=PARTUUID=... instead of root=UUID=.... All the other stuff mentioned by @goldilocks above however is correct; just always replace the UUID with the PARTUUID.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.