Permanently mounting an external USB hard drive on a Raspberry Pi

Find the external drive using fstab

pi@raspberrypi:/mnt$ sudo fdisk -l

Disk /dev/mmcblk0: 7964 MB, 7964983296 bytes
4 heads, 16 sectors/track, 243072 cylinders, total 15556608 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000827fa

Device Boot Start End Blocks Id System
/dev/mmcblk0p1 2048 1671875 834914 e W95 FAT16 (LBA)
/dev/mmcblk0p2 1679360 15491071 6905856 85 Linux extended
/dev/mmcblk0p3 15491072 15556607 32768 83 Linux
/dev/mmcblk0p5 1687552 1810431 61440 c W95 FAT32 (LBA)
/dev/mmcblk0p6 1818624 15491071 6836224 83 Linux

Disk /dev/sda: 3000.6 GB, 3000592982016 bytes
255 heads, 63 sectors/track, 364801 cylinders, total 5860533168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000af53a

Device Boot Start End Blocks Id System
/dev/sda1 2048 2930266111 1465132032 83 Linux
/dev/sda2 2930266112 1565565871 1465133528 83 Linux

 

You want to mount it using its UUID instead of its /dev address because USB drives get mounted at different addresses on each boot while the UUID will be the same.

sudo blkid

/dev/mmcblk0p1: LABEL="RECOVERY" UUID="3394-996E" TYPE="vfat"
/dev/mmcblk0p3: LABEL="SETTINGS" UUID="7cc3c451-5b28-4fea-8eec-f7c2725966fb" TYPE="ext4"
/dev/mmcblk0p5: LABEL="boot0" UUID="019E-DE96" TYPE="vfat"
/dev/mmcblk0p6: LABEL="root" UUID="cc9b7456-235e-4718-8e53-faa76242e5f3" TYPE="ext4"
/dev/sda1: UUID="cda18eda-8de5-43a1-a629-6737f5752f15" SEC_TYPE="ext2" TYPE="ext3"

Add the drive to the file system table:

sudo vi /etc/fstab

UUID=cda18eda-8de5-43a1-a629-6737f5752f15 /mnt/hdd1 ext3 defaults,errors=remount-ro 0 1

Reboot and the drive should be mounted!