rbpi:raspbian_usb

Install and run Raspbian from a USB Flash Drive

SD Cards have a limited read/write cycle, and it won’t take long before you start getting corruptions and failures. On the other hand, USB Flash drives provide a cheap and reliable alternative. I’ve tested several USB Flash drives, and found Sandisk and Corsair to be the best for speed and reliability.

You will need the standard Raspbian OS image, you can download this from the official Raspberry Pi website. Once you’ve downloaded it, unzip it. It’s around 4 GB in size, so should only take about 15 minutes over a broadband connection.

Plug in your USB stick and launch Win32DiskImager. Select the unpacked image file and make sure that you selected the correct device (this will essentially delete everything stored on this device) and press Write. This takes anything from 5 to 20 mins depending on the speed of your USB Flash Drive.

Now, insert your SD card (64mb should be enough). Format the SD card to FAT32 and set the label (and other properties) to match the /boot partition on the USB drive and copy all the data from the USB /boot to SD /boot. Or simply clone the /boot partition from your USB drive to the SD card.

We’re almost done at this point, only one more thing to do: change the default boot path to tell the Raspberry Pi to boot from your USB drive.

Open a cmdline.txt from SD /boot partition in any text editor and change this:

root=/dev/mmcblk0p2

To this:

root=/dev/sda2

This will instruct your Raspberry Pi to start from the USB Flash Drive instead of from the SD card.

Insert the SD and USB into the Raspberry PI and power on.

If you used an USB drive larger than 4GB, you might want to utilize the extra space you have. Install and use GParted, or do it from terminal:

sudo fdisk /dev/sda

To grow your partition you can do it while it’s mounted:

sudo resize2fs /dev/sda2

The command above would resize to the maximum permitted. Provided that you already have the empty space ready to be merged. Afterwards, reboot for the changes to take effect correctly. If you wish to resize to a particular size then simply add the size at the end:

sudo resize2fs /dev/sda1 25G

Note that if you want to specify 25.4 GB, you can’t use a decimal number. You need specify MB, so it would look like this:

sudo resize2fs /dev/sda1 25400M

This way you will have a partition of 25.4G

Enter your comment:
128 +6 = 
 
  • rbpi/raspbian_usb.txt
  • Last modified: 2019/10/31 08:55
  • by 127.0.0.1