How to Boot Up Raspberry Pi 3 from External Hard Disk

raspberry-pi-featured

Raspberry Pi is designed to run from the SD/MicroSD card. For operating systems like PIXEL, this means that your “root” and “Home” partitions all lie in the SD card, which can be a little limiting considering its minuscule storage size. If you are intending to run a home storage server on your Raspberry Pi, it is best to move the OS to the external hard drive so you have tons of storage space to use.

In this tutorial we will show you how to get Raspberry Pi 3 to boot up and run from the external hard disk.

Note: The reason Raspberry Pi 3 is used here is because it doesn’t need an additional power source to power up the external hard disk. The power supply of Raspberry Pi 3 is sufficient to power up the external hard disk via the USB port. Do make sure that you are using the official Pi power adapter or that your power plug is capable of outputting 2.5A (minimum) of current.

Before we start, here are the requirements for this tutorial:

  1. A Raspberry Pi 3
  2. A microSD card (minimum 4 GB) with PIXEL installed. (This tutorial assumes that you already have a working PIXEL installation on your microSD card. For more details, you can check out the tutorials here to set up images for Raspberry Pi.)
  3. An external hard disk formatted to Ext4. (You can use GParted or the fdisk command to format your external hard drive to Ext 4.)

1. Insert the microSD card into the Raspberry Pi 3. Plug in the external hard drive to the USB port of the Raspberry Pi 3. Power up the Pi.

2. Once you have reached the desktop, open a terminal. Log into the root account and mount the external hard drive.

3. Next, we need to install Rsync (if it is not already installed):

4. Copy all the files from the microSD card to the external hard drive. We are using rsync, so all file permissions and ownership are intact.

raspberry-pi-rsync

5. With all the boot up files in the external hard drive, we need to modify the startup file so that it is pointing to the external hard disk for boot up instructions.

We need to edit two parts of this line. Change the root= to /dev/sda, and at the end, add rootdelay=5.

The result should look like this:

raspberry-pi-boot-cmdline

6. Lastly, we are adding the hard drive entry to “/mnt/etc/fstab” so the root folder in the external hard drive is automatically mounted during boot up.

Add this line to the second line of the file:

Add a “#” at the start of the last line to disable booting up from the microSD card:

Note: /devmncblk0p7 is referring to your microSD card slot and the value might differ in your case.

After the changes, it should look like this:

raspberry-pi-fstab

That’s it. Reboot your Pi, and it should boot up and run from the external hard drive. One thing to note is that the microSD card needs to be in its slot, as the Pi needs to read the startup file from it before it boots up from the external hard drive.

Assuming your external hard drive comes with tons of space, you might want to increase the swapfile size so your Pi can run slightly faster.

1. Open a terminal and log into the root account.

2. Edit the swapfile.

Change the value of CONF_SWAPSIZE from 100 to 512. Save and exit the file.

raspberry-pi-swapfile

3. Restart the service to update the changes.

The Raspberry Pi 3 comes with several useful improvements such as higher RAM, a WiFi module and a power supply big enough to support an external hard drive. This makes it useful to run bigger and more intensive projects. As such, the microSD card with a small storage size can be a limiting factor, not to mention its slow read/write speed and it being susceptible to data corruption. With the instructions above, you can now power your Raspberry Pi from the external hard drive and improve its performance.

7 comments

  1. Correct me if I’m wrong but you are here describing a way to move the rootfs to a USB drive. This is kind of misleading as the Raspberry pi 3 is the only Raspberry pi that can actually be booted (for real, not just mooving rootfs) from USB. You should have named your article “How to only move the rootfs to usb, something that could be done in 2012 already, even though now you could truly boot it entirely from USB”

    https://www.raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/msd.md

  2. I found this very useful. I know that the other way to do this is to set the One Time Programming bit which cannot be undone according to the Raspberry Pi help page. This way is better because it does not make any permanent changes to the hardware of the Pi. Thank you for your post.

    • @ Steve,

      Programming the OTP bit for USB boot has no detrimental affect on the Pi3. You can still boot off an SD card if desired. The Pi3 will always check the SD card first, the bit just tells it to check for a bootable USB device if there is no SD card.

  3. This is not booting the Pi3 off the hard drive – it is just moving the file system over – you can do that with just about any micro. Oh well, off to find out what I originally came here looking for…

  4. Having problems with rsync….. sudo rsync -axv / /mnt
    Whats wrong with this command ? are the spaces before and after the / s correct?
    space before the first / required?

    • @dave, yes there are spaces between the backslashes (/ /). There is also a space between the options (-axv) and the first backslash (/).

      sudo rsync -axv / /mnt

      so what this means is you are coping through rsync the whole home folder (which is /) to the mounted drive (/mnt). I use rsync alot especially over an ssh connection.

  5. I found this useful with my Pi 3. I’m booting from a Pi-powered USB HDD, and the Pi doesn’t wait long enough for the disk to spin up before it starts booting. So booting directly from the disk doesn’t work. This is a good compromise, and only requires me to leave a small MicroSD card installed for the /boot partition. The alternative was to use external power for the disk, and that’s just silly.

Comments are closed.

Sponsored Stories