Well… technically it won’t boot from a hard drive, it has to be the boot partition on the SD card, but that’s actually just a small script setting up the root partition of the SD card.
The raspberry Pi is brilliant and every iteration has made it better and faster, all except one thing, the SD card. It still requires an SD card to boot up and run, but now you can run Linux from an SSD!
What I will show you is how to copy the contents of this root partition to an external drive, be it a USB memory stick, USB hard drive or like I have, an external USB Solid state drive.
This is actually a VERY VERY easy thing to do and aside from copying the contents from one drive to another, very quick too.
So the first thing to do is attach the USB drive to the Pi. For easy install I’ve already partitioned and formatted the drive to linux EXT4, all I need to do is discover where it is in the file system.
The result is /dev/sda1 – So now I know where the drive is, simples 🙂
If you have more than one drive attached it could be another letter, eg. sda1 is mine, sdb1, sdc2 and so on. Make sure you have the correct one.
Next you need to copy the files from the SD card to the external drive.
sudo dd if=/dev/mmcblk0p2 of=/dev/sda1 bs=512
Now this will take about 30 minutes to complete, but when it’s done there are a few things we need to do to finish the preparation of the drive
1. sudo e2fsck -f /dev/sda1
2. sudo resize2fs /dev/sda1
The first line checks the filesystem the second resizes the new drive and makes it use the full amount of space, the copy just copied the SDCARD sector by sector, so the new drive size will also match the SD CARD, resize2fs opens the drive up
Just two edits now stand between you and a faster pi.
sudo nano /boot/cmdline.txt
change the part that says root=/dev/mmcblk0p2 to root=/dev/sda1
Next we need to make a directory to mount the USB Drive for easier access, you don’t technically need to do this but I did.
you can call the folder what ever you want, I had a spare 60GB SSD so I called it 60GB
The final edit and job is to edit the fstab so it’ll be correctly mounted at boot.
sudo nano /dev/sda1/etc/fstab
edit the line that says /dev/mmcblk0p2 to /dev/sda1
At this point you can safely reboot the Pi and welcome to a way faster Raspberry Pi.