Find the UUID of a drive in Linux
I recently switched my home file server from Gentoo to Ubuntu and noticed that, by default, Ubuntu uses UUIDs to identify hard drives in /etc/fstab.
That’s cool, because I’ve had some issues in the past with USB drives grabbing different device names than I expected. Using a truly unique identifier (or at least one that’s unlikely to be duplicated) such as a UUID helps out with that.
So how do you find the UUID of a device? Easy! You can either use:
root@europa:/root# blkid
/dev/sda1: UUID="3f467d1c-12bd-459e-be63-20e313faad88" TYPE="ext3"
/dev/sda5: TYPE="swap" UUID="cfe7d582-aa62-469b-8f4f-40927d013748"
/dev/sdb1: UUID="da488135-3744-487e-89e2-4898653db209" SEC_TYPE="ext2" TYPE="ext3"
/dev/sdc1: UUID="d438941d-e928-4ec1-9b96-eead147cd23e" TYPE="ext3"
Or if you need to find the UUID of a specific device, you can use this:
root@europa:/root# vol_id -u /dev/sdc1
d438941d-e928-4ec1-9b96-eead147cd23e
Copy and paste the UUID into /etc/fstab, add your mounting options, and you’re done.
I'm an engineer, but sometimes I like to pretend I'm a programmer. Current obsessions include Ruby and Project Euler. 
