How to Boot Up Raspberry Pi 3 from External Hard Disk
Basically Raspberry Pi boot from SD/MicroSD card. So No other boot option provided by Raspberry Pi. But in this post we learn “How to Boot Up Raspberry Pi 3 from External Hard Disk”.
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, You have a working Raspberry pi 3. A microSD card (minimum 4 GB) with PIXEL installed. An external hard disk formatted to Ext4. (You can use GParted or the fdisk command to format your external hard drive to Ext 4.)
Recommended: How To Use Raspberry pi in a truely headless mode
Setting Up External Hard Disk for Boot
- 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.
- Once you have reached the desktop, open a terminal. Log into the root account and mount the external hard drive.
sudo su mount /dev/sda /mnt
- Next, we need to install Rsync (if it is not already installed):
apt-get install rsync
- 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.
sudo rsync -axv / /mnt
- 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.
cp /boot/cmdline.txt /boot/cmdline.txt.bak nano /boot/cmdline.txt
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:
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/sda1 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait rootdelay=5
- 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.
nano /mnt/etc/fstab
Add this line to the second line of the file:
/dev/sda1 / ext4 defaults,noatime 0 1
Add a “#” at the start of the last line to disable booting up from the microSD card:
#/dev/mmcblk0p7 / ext4 defaults,noatime 0 1
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:
proc /proc proc defaults 0 0 /dev/sda1 / ext4 defaults,noatime 0 1 /dev/mmcblk0p6 /boot vfat defaults 0 2 #/dev/mmcblk0p7 / ext4 defaults,noatime 0 1
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.
Increase the swapfile size (Optional)
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.
- Open a terminal and log into the root account.
sudo su
- Edit the swapfile.
nano /etc/dphys-swapfile
Change the value of CONF_SWAPSIZE
from 100 to 512. Save and exit the file.
- Restart the service to update the changes.
sudo dphys-swapfile setup sudo /etc/init.d/dphys-swapfile stop sudo /etc/init.d/dphys-swapfile start
I hope you like this post. Do you have any questions? Leave a comment down below!
Thanks for reading. If you like this post probably you might like my next ones, so please support me by subscribing my blog.
Explore Some more Raspberry Pi Tutorials :
- Raspberry Pi – Introduction | Overview | Setup and Management | Tutorials
- piCore (Tiny Core) Linux on Raspberry Pi
- Setup Docker on Raspberry Pi
- Create a Docker Container for Raspberry Pi to Blink an LED
- Raspberry Pi Alternatives in 2019
- How to Install Mosquitto Broker on Raspberry Pi
- Setting up SPI on Raspberry Pi
- Getting Started with The Sense HAT – Raspberry Pi
- Raspberry Pi GPIO Basics
- Controlling LED with Raspberry Pi PART-2
- How To Setup Static IP Address on Raspberry Pi
- Controlling LED with Raspberry Pi
- Interfacing a light Sensor (LDR) with Raspberry Pi
- Remote control your Raspberry Pi from your PC with VNC!
- How To Use Raspberry pi in a truely headless mode
- ROCK Pi 4 : Overview | Installation
- Best OS for Raspberry Pi
- How to setup Bluetooth on a Raspberry Pi 3
- Simple Raspberry Pi Home Security System
- Raspbian – OS For Raspberry Pi
- Setting up a Raspberry Pi headless
Pingback: How to Boot Up Raspberry Pi 3 from External Hard Disk — IoTbyHVM – Bits & Bytes of IoT – hashstacks