What is the UUID of my disks?

On cloud machines, you cannot always guarantee the device names when you mount “external disks” onto your VM after an upgade, so in the fstab you can use UUIDs instead of device names:-

#
# /etc/fstab
# Created by anaconda on Sun May 6 03:02:21 2018
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=9b3b19ba-d5f5-46e7-94b2-e8315074c75f / ext4 errors=remount-ro,discard 1 1
UUID=25d51bb1-77ce-4d9b-998a-c9ed97dad693 /home ext4
UUID=582078d7-715e-43fc-b038-c233a09c6ffb /var/lib/mysql ext4

but how do you come by the UUID?

# ls -al /dev/disk/by-uuid/
total 0
drwxr-xr-x 2 root root 100 Aug 18 15:55 .
drwxr-xr-x 5 root root 100 Aug 18 15:33 ..
lrwxrwxrwx 1 root root 9 Aug 18 15:55 25d51bb1-77ce-4d9b-998a-c9ed97dad693 -> ../../sdb
lrwxrwxrwx 1 root root 9 Aug 18 15:55 582078d7-715e-43fc-b038-c233a09c6ffb -> ../../sdc
lrwxrwxrwx 1 root root 10 Aug 18 15:34 9b3b19ba-d5f5-46e7-94b2-e8315074c75f -> ../../sda1

Here you can see after a reboot, the UUID stay true but the drive letters have changed.

# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        40G  2.4G   36G   7% /
devtmpfs        3.8G     0  3.8G   0% /dev
tmpfs           3.8G     0  3.8G   0% /dev/shm
tmpfs           3.8G  8.5M  3.8G   1% /run
tmpfs           3.8G     0  3.8G   0% /sys/fs/cgroup
/dev/sdb         50G   53M   47G   1% /var/lib/mysql
/dev/sdc        296G   65M  281G   1% /home
tmpfs           764M     0  764M   0% /run/user/1000

Author: Andrew

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.