fstab and UUID

Recently, I added a USB removable hard drive I added to my primary desktop. To make it simple to mount, I added a line in my /etc/fstab with the appropriate sdx device which I determined via dmesg. The problem is, upon reboot, the OS wouldn’t always assign the external hard drive to the same sdx device as I had in my /etc/fstab.

Thus I needed to find the UUID of the drive, and add that entry to my /etc/fstab. I used the command blkid:

>> blkid /dev/sdc1
/dev/sdc1: UUID="5afb0e5d-0f87-4606-89bd-110f0fc06d63" TYPE="jfs"

Then in my /etc/fstab, I created the following entry:

UUID=5afb0e5d-0f87-4606-89bd-110f0fc06d63 /media/drive jfs users,umask=0000 0 0

Worked like a charm.

Also, I discovered another way to determine the UUID of a device.

>>ls -l /dev/disk/by-uuid/
lrwxrwxrwx 1 root root 10 Dec 19 13:58 266ad007-52c6-450c-934d-4564f57341d3 -> ../../sdb1
lrwxrwxrwx 1 root root 10 Dec 19 23:24 5afb0e5d-0f87-4606-89bd-110f0fc06d63 -> ../../sdc1
lrwxrwxrwx 1 root root 10 Dec 19 13:58 93e27cd4-5c14-4e1d-8d7e-c4ec1a973ed9 -> ../../sda1
lrwxrwxrwx 1 root root 10 Dec 19 13:58 d2ead8a9-e3be-4e1c-81b8-a8be81790d30 -> ../../sda2