Raspberry Pi Root FS on USB Drive
This tutorial will demonstrate how to install the Debian root filestem (ie. ‘/’) on a USB drive instead of the SD card. The SD card still retains the /boot partion and swap space. This requires a modified kernel to support the USB storage. You can download the minimal modified kernel and modules here or follow my guide on how to compile it for yourself.
In either case, begin by installing the Debian image as you normally would to an SD card. Manually format the USB drive you intend to use as the root filesystem as ext4 using a utility like gparted.
Next, copy the root filesytem from the Debian install on the SD card to the USB drive, preserving attributes with the -a flag, substituting “sdcard-rootfs-partition-uuid” and “usbdrive-rootfs-partition-uuid” with the respective identifiers as the filesystem are mounted in Ubuntu.
sudo cp -a /media/sdcard-rootfs-partition-uuid/* /media/usbdrive-rootfs-partition-uuid/
Now, delete the existing kernel.img and replace it with the new one, substituting “sdcard-boot-partition-uuid” with the identifier of the partion as it is mounted in Ubuntu.
sudo rm /media/sdcard-boot-partition-uuid/kernel.img
sudo mv kernel.img /media/sdcard-boot-partition-uuid/
Next, remove the existing /lib/modules and lib/firmware directories,
sudo rm -rf /media/usbdrive-rootfs-partition-uuid/lib/modules/
sudo rm -rf /media/usbdrive-rootfs-partition-uuid/lib/firmware/
and copy the new modules and firmware in their place:
sudo cp -a lib/modules/ /media/usbdrive-rootfs-partition-uuid/lib/
sudo cp -a lib/firmware/ /media/usbdrive-rootfs-partition-uuid/lib/
Now we need to modify the location of the root partition in the /boot partion. This is contained within the file, cmdline.txt. In this file, change:
That’s it! Plug in and boot up the root filesystem from the USB stick!