Ubuntu 16.04: Mount USB storage on boot

This article will describe mounting USB device automatically on boot. This USB device is attached to /dev/sdh1 and /dev/sdh1 is mounted to /mnt directory.

1 USB storage issue

Block device where USB storage device will be attached depends on timing. The timing means indefinite. USB device was attached to /dev/sdc1 before reboot. USB device will be attached to /dev/sdd1 after reboot.

So USB storage needs UUID mount. UUID does not depends on timing. You can get UUID of USB device with blkid command.

2 blkid

The blkid commands output as below.

$ sudo blkid
<device>: <uuid> <fstype>

Grep UUID of USB device attached to /dev/sdh1.

$ sudo blkid | grep "^/dev/sdh1:"
/dev/sdh1: UUID="e801fc70-a741-48da-b82d-d55b7668a573" TYPE="xfs"

3 /etc/fstab

Add UUID mount entry to /dev/fstab.

$ echo 'UUID="e801fc70-a741-48da-b82d-d55b7668a573" /mnt xfs defaults 0 0' \
| sudo tee -a /etc/fstab

Now USB device can be mount automatically on boot.