I have already explained how to do a basic Raspberry Pi server install. But if you want to do something more exciting with it, perhaps running a Nextcloud instance or setting up a torrent box, you will need more space than just an SD card. That’s why in this post I will show you how to connect external hard drive to Raspberry Pi.
If you don’t already have an external hard drive, I recommend the Western Digital Pi Drive, which is designed to work with Raspberry Pi. For other drives, you must increase how much juice Raspberry puts out via its USBs, because the default is not enough for an external drive. So, open
nano and add this line:
Save the file with
Ctrl+X and restart your Pi. Now, connect the drive and try to mount it to see if it works. To find out its device name, use
sudo blkid. It should probably be something like
/dev/sda1. The mount command is easy:
$ mount /dev/sda1 /mnt
Next, try saving a test file to the drive. If it’s saved successfully, you are good to go. If you get any errors, your drive is probably too power hungry and you might need to connect it to your Pi through an externally powered USB hub.
Mounting the drive manually every time you restart your Pi is a bit of pain though. So let us make it mount automatically. First, you need to make a mount point for it:
$ mkdir /media/external
Of course, you can call whatever you want. When done, edit the
/etc/fstab file, adding the following line:
/dev/sda1 /media/external ntfs defaults 0 0
/dev/sda1, put in your own device name. This assumes the drive uses the default Windows filesystem - ntfs. If you use something else instead (ext4, btrfs), change it accordingly. And that’s it - you have successfully connected an external drive to your Raspberry Pi.