You’re running a Raspberry Pi, perhaps as a server or for retro gaming. Maybe you’re using it for Kodi. The point is, you need extra storage beyond the limits of a microSD card.
It doesn’t matter how large your microSD card is; sooner or later, your Raspberry Pi will need more storage. Also, regardless of how good the error correction is on your little piece of flash memory, sooner or later it will corrupt.
The solution is a hard disk. But how do you connect a hard disk drive to a Raspberry Pi? And what are the benefits of doing so? Here’s everything you need to know.
How to Mount and Read an HDD in Raspbian
As long as you have an external HDD with a USB cable and its own power supply, you’ll be able to use it with your Raspberry Pi. (If your drive doesn’t have a power supply, it will require connecting via a powered USB hub.) All you have to do is connect the drive to a USB port, and power it up.
By default, the hard disk drive won’t be immediately accessible. This is due to a couple of factors: the file system on the disk, and the lack of automatic mounting in Raspbian.
If the disk isn’t formatted with the EXT4 file system, then it cannot be natively read. One way around this is to remove the data from the drive, reformat in EXT4, and then replace the data. Once this is done, it should be accessible, but you’ve wasted a lot of time and effort.
More convenient is the option to use the ntfs-3g software, so that the Raspberry Pi can read the NTFS file system:
sudo apt install ntfs-3g
Note: If the drive is in FAT32 format, you’ll need to install vfat instead.
Ensuring the drive is connected, and powered on, you should find it within the Media directory on your Raspberry Pi. If not, you’ll need to do a bit more work.
First, find its UUID string:
In the response, the final alphanumeric string is the UUID; keep a note of this. Next, create a location for the mount point. This is typically:
sudo mkdir /mnt/mydisk
Note: Swap “mydisk” with your preferred disk label.
Assign permissions with:
sudo chmod 770 /mnt/mydisk
Next, mount the drive with:
sudo mount -t ntfs-3g -o uid=1000,gid=1000,umask=007 /dev/sda1 /mnt/mydisk
Once you’ve done this, you should be able to access the drive in Raspbian. But what if you want to access the disk after a reboot?
The answer is to edit the fstab. Begin by backup:
sudo cp /etc/fstab /etc/fstab.backup
Next, edit the original:
sudo nano /etc/fstab
Add the information need to mount the disk; this begins with the 16-character UUID string you made a note of earlier:
UUID=ABCDEFGH12345678 /mnt/volume ntfs-3g uid=1000,gid=1000,nofail,umask=007 0 0
You should now find that the HDD storage is accessible each time you boot up your Raspberry Pi! This might prove very useful for storing a retro gaming library, or media for a Raspberry Pi-based Plex media center to stream.
How to Boot Your Raspberry Pi From HDD
What if simple storage isn’t what you’re looking for? Perhaps you want to lose the potential weak link of the microSD card, and boot from HDD instead?
Using a hard disk drive with your Raspberry Pi doesn’t have to mean using the disk as a secondary device. It is possible to install your OS to the disk, removing the requirement for a microSD card completely.
To do this, you’ll need to ensure the Pi (this works only with the Raspberry Pi 3 and Pi 3B+) knows that it no longer needs to boot from microSD. This is achieved by starting with a standard Raspbian install on microSD, then changing the USB boot mode.
You can then connect a HDD via USB, format the drive, copy the operating system from the microSD card, and enjoy larger (potentially faster) storage with your Raspberry Pi.
For the full details, see our guide to booting a Raspberry Pi from USB.
Installing Multiple Raspberry Pi OSes to HDD
If these seems too hands on, and you want to take advantage of the vast additional storage, you should check out the various tools for installing multiple operating systems to your Raspberry Pi. Berryboot, NOOBS, and PINN Lite can all do the job.
All options can install to your Pi-attached hard disk drive, although you may prefer to jump straight into our guides. We’ve produced a tutorial for NOOBS, and an in-depth guide for Berryboot. (You cannot use NOOBS to install to HDD without first following our guide to changing the USB boot mode.)
Raspberry Pi Cases With Space for an HDD
Once you’ve got your HDD sorted out, you’ll probably want to keep it close to your Raspberry Pi. Several enclosures are available that have space for a Raspberry Pi and a 2.5-inch hard disk drive.
This popular online store has several options from WD Labs, all designed to store a Raspberry Pi and a HDD. Although designed for the WD Labs PiDrive disk drive, a small amount of customization should allow any 2.5 inch drive to slot into one of these.
A useful all-in-one option is this enclosure from Geekwork, which incorporates a Raspberry Pi, X820 expansion board, and compatible 2.5 inch SATA disk drive.
While the enclosure itself is available on Amazon, the X820 SATA expansion board must be purchased separately.
NODE Decentralized Mini Server
If you prefer, something even more integrated, prefer an open source design, and don’t mind a bit of soldering, then YouTuber NODE’s amazing decentralized mini server build might suit you.
Featuring some modifications to a Raspberry Pi 3B+ and a 3D-printed case with space for a 2.5 inch HDD to slot in, this is designed for using your Pi as a server. Find full details at n-o-d-e.net.
Setting Up Your Raspberry Pi With an HDD Is Simple
By now, you should be ready to add a hard disk drive to your Raspberry Pi, if you haven’t already. While any model can benefit, the best results are undoubtedly enjoyed on a Raspberry Pi 3 or 3B+.
How you use the hard disk drive is up to you. It may prove useful in a number of ways, including several of the ones in our list of the best Raspberry Pi projects.
Read the full article: How to Connect a Hard Drive to Raspberry Pi (And Why You Should)