RHEL- Find UUID of Hard Disks

CinderblockAnyone who has added and removed multiple disks from a RedHat server knows very well that your disks may not always enumerate exactly the same way after a reboot. You then have to resort to mounting up your filesystems to a temporary mount point to see exactly whats in them, and were they really need to be mounted.

Want to know if UUIDS are being used on your linux box, well just cat /etc/fstab, and if you see somthing similar to what’s below, then you are using UUIDS, instead of traditional disk device names.

UUID=3fa4603e-9874-4f47-ae1c-3f7715a54238 /                       ext4    defaults,user_xattr        1 1
UUID=483c34a4-b3ec-4860-854f-b9e5b6a6efac /boot                   ext4    defaults        1 2
UUID=7cab6648-b3f3-4aaa-bb2b-d32b78156aab /var                    ext4    defaults        1 2
UUID=7b05f0a9-18d5-42e5-b259-78ba3a8cc1b7 swap                    swap    defaults        0 0

One way of mapping device UUIDS back to device names is the blkid command — usage and output below.

[root@fedora15 ~]# blkid
/dev/sda1: UUID=”483c34a4-b3ec-4860-854f-b9e5b6a6efac” TYPE=”ext4″
/dev/sda2: LABEL=”_Fedora-15-x86_6″ UUID=”3fa4603e-9874-4f47-ae1c-3f7715a54238″ TYPE=”ext4″
/dev/sda3: UUID=”7b05f0a9-18d5-42e5-b259-78ba3a8cc1b7″ TYPE=”swap”
/dev/sdb1: UUID=”7cab6648-b3f3-4aaa-bb2b-d32b78156aab” TYPE=”ext4″
/dev/sdb2: UUID=”rJfNaK-e3Xp-n3qm-4aXM-BfKF-g7sg-Kwm33a” TYPE=”LVM2_member”
/dev/sdc1: LABEL=”raid1″ UUID=”34ed4ffd-cc4a-4b40-892f-6d7714fe7f4e” TYPE=”ext3″
/dev/mapper/vm_vg-v1: UUID=”2d96aa43-b5b8-4185-8014-323ad8a07a0d” TYPE=”ext4″

You can also do an ls on the following directory and get the same information.

[root@fedora15 ~]# ls -l /dev/disk/by-uuid
total 0
lrwxrwxrwx 1 root root 10 Sep 25 21:41 2d96aa43-b5b8-4185-8014-323ad8a07a0d -> ../../dm-0
lrwxrwxrwx 1 root root 10 Sep 25 20:51 34ed4ffd-cc4a-4b40-892f-6d7714fe7f4e -> ../../sdc1
lrwxrwxrwx 1 root root 10 Sep 25 20:51 3fa4603e-9874-4f47-ae1c-3f7715a54238 -> ../../sda2
lrwxrwxrwx 1 root root 10 Sep 25 20:51 483c34a4-b3ec-4860-854f-b9e5b6a6efac -> ../../sda1
lrwxrwxrwx 1 root root 10 Sep 25 20:51 7b05f0a9-18d5-42e5-b259-78ba3a8cc1b7 -> ../../sda3
lrwxrwxrwx 1 root root 10 Sep 25 20:51 7cab6648-b3f3-4aaa-bb2b-d32b78156aab -> ../../sdb1

If you are so inclined, you can also get the UUID and filesystem label (if there is one) with the tune2fs command

tune2fs -l /dev/sda1

Filesystem volume name:   <none>
Last mounted on:          /boot
Filesystem UUID:          483c34a4-b3ec-4860-854f-b9e5b6a6efac
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)


Oh and if you are running Fedora 15 and are wondering what the heck rootfs is (as I was), here is an explanation. More junk that I hope never gets into RHEL.

Oh and if you are really bored, and would like to know more about what a UUID is go here

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s