Booting Raspberry Pi from USB Flash Drive

The following tutorial will work/required for only 2B v1.2, 3A+, 3B, Compute Module 3, 3+ for 3B+ and above USB boot is out of the box.

To make this work we still need to use one SD Card, the Pi will boot from it but it will redirect to the USB Storage device as the location of the OS.

To start with write the image file to the USB Drive and an SD Card. You can remove the USB Storage device but resinsert the SD card.  On liniux it will show two partitions and on Windows it will show one. Open the drive with label boot. You will see a file named cmdline.txt

This cmdline.txt file will be containing the boot path as shown in the following image,



To boot from USB Flash Drive we have to change the path to dev/sda2.

Now plug the Drive and SD card into the Raspberry PI and if everything went write it will boot from the USB flash drive. And you are ready. However the file system wil not be exapnded automatically and it has to be done manually, to do that use the following commands

$ sudo fdisk /dev/sda
Then press p and enter to see the partitions. There should only be 2.Make a note of the start position for the partition sda2. Press d and then when prompted type 2 and then hit enter. This will delete the partition.Now we’re going to create a new partition, and make it large enough for the OS to occupy the full space available on the USB Flash Drive. To do this type n to create a new partition, when prompted to give the partition type, press p for primary. Then it will as for a partition number, press 2 and hit enter.You will be asked for a first sector, set this as the start of partition 2 as noted earlier. In my case this as 122880 but this is likely to be different for you.After this it will ask for an end position, hit enter to use the default which is end of disk. Now type w to commit the changes. You will see a message about the Kernel just ignore this. Type the following to reboot:
$ sudo reboot

Once your Raspberry Pi has rebooted, we need to resize the partition. To do this type the following,

 $ sudo resize2fs /dev/sda2

Once it’s done reboot again. Then type:

$ df -h

This will show the partitions and space, you’ll see the full USB Flash Disk has all the space available now. That’s it, all done!

Related posts

Leave a Comment