Mount a USB drive on Raspberry Pi

SD cards can hold a lot of data these days. I bought a 64GB micro SD for €15 the other day. While that is more then enough for the OS and most work, it’s not enough for my backups.
So in this guide we are mounting a 4TB external hard drive with a USB cable.

Sidenote, If you have a new drive I recommend to format it as ext4, that is not part of this tutorial. It’s easier to do on a your main Latop/Computer with an interface.

Boot up your Pi, login and plug in your drive.

Find the USB drive before mounting

First we run the command: sudo blkid
The output should look like this.

List of drive
List of available drives

This is a list of all avialable drives. The first , the /dev/mmcblk0 are part of the Rasberry itself. External drives should be like /dev/sda or similar. In my case it’s also easy to identify by the label.
The important thing to note is the UUID. Copy that, we will need it in the next steps.

Mounting the drive

Before we mount the drive it’s important to know where we are going to mount the drive. Traditional places are /media/* and /mnt/* So we will create a directory inside there:

sudo mkdir /media/4TB

Finally we simply mount the directory.

sudo mount /dev/sda /media/4TB

And that’s it.

The result before and after mounting a drive
Before mounting the folder is empty, after you see the folders I already had on the drive.

Mount a drive on startup

The method above is ease, but has one major downside. If the Pi ever is rebooted you will have to manually mount again.
Try it out now: sudo reboot now and log in again, and check your folder, it should be empty.

Before we start we need the UUID from the drive. You can find it in with this command: sudo blkid
Now open the fstab file where all mount points are stored.

sudo nano /etc/fstab

Inside add the following line, replace the UUID and optinal the path where you want to mount your drive. I’m mounting it at /media/4TB
I’m also amusing the drive is formatted ext4, if not adjust that accordingly

UUID=12272d4a-c58e-4b32-a908-ed8bf737db54    /media/4TB   ext4    defaults,errors=remount-ro 0       1

To test that is works you can mount it with: sudo mount -a
If that works reboot the system and check again: sudo reboot now

For more details about the fstab and it’s options check this this fstab page