Raspberry Pi: How to mount a USB hard disk

After connecting the drive to the Pi, we first need to find out where it is located. One way to do this is via the blkid command, which lists the block devices on the PI. Below is the output I get when entering this command.

$ sudo blkid
/dev/mmcblk0p1: LABEL="boot" UUID="3725-1C05" TYPE="vfat" PARTUUID="80ea9ce7-01"
/dev/mmcblk0p2: LABEL="rootfs" UUID="fd695ef5-f047-44bd-b159-2a78c53af20a" TYPE="ext4" PARTUUID="80ea9ce7-02"
/dev/mmcblk0: PTUUID="80ea9ce7" PTTYPE="dos"
/dev/sda1: LABEL="Elements SE" UUID="2E1C78611C78264D" TYPE="ntfs" PARTLABEL="Elements SE" PARTUUID="0f520684-2030-4069-8d8e-45b4197ba26d"

Having found the device you could now mount it manually with the following command.

$ sudo mount /dev/sda1 /mnt

I’m going to make the assumption that you want the drive to mount automatically however. To accomplish this we first need to modify the /etc/fstab file. To do this I’m going to use nano as shown below.

$ sudo nano /etc/fstab

Now enter the details for your drive. Mine is shown in the last line of the file. When you’ve finished type <ctrl>X to exit and save, then follow the on screen instructions. Make sure you set the location of the drive according to the location you determined above, /dev/sda1 in my case.

proc                  /proc           proc    defaults                 0       0
PARTUUID=80ea9ce7-01  /boot           vfat    defaults                 0       2
PARTUUID=80ea9ce7-02  /               ext4    defaults,noatime         0       1
/dev/sda1             /mnt            ntfs    auto,uid=1000,pid=1000   0       0

You now need to tell Linux to mount all the file system mentioned in the /etc/fstab file. You do this by typing the following.

$ sudo mount -a

If you now try to list the conents of the drive you may receive a message telling you that you do not have permission to open the /mnt directory. If that is the case then you can change the directory permissions via the chmod command.

$ sudo chmod 777 /mnt

Which should allow you to finally see the contents of the disk.

$ ls /mnt
Movies  $RECYCLE.BIN  System Volume Information  TV Shows

To gain the most use from mounting the disk you probably need to install the ntfs-3g package. This is required if you want to write as well as read the drive. You can do this with the following command.

$ sudo apt-get install ntfs-3g