Skip to main content
Welcome guest. | Register | Login | Post

Get UUID of a mounted partition

I've been looking for it so I thought that this time it'd be a good idea to post it as a tip for future reference, both for myself and others.

Sometimes when you manually mount a new partition in operating systems and distributions that use UUIDs in /etc/fstab to mount partitions on boot you would want to get the UUID of the newly mounted partition so that you can add it in /etc/fstab for mounting at boot so you don't have to do it all the time manually.

So, it's simple. The blkid command will list some of the devices (partitions) with their UUIDs, but it seems it only lists those already included in fstab. Therefore even more useful should be ls -l /dev/disk/by-uuid/ which will list all currently mounted partitions with their UUIDs, including those not in /etc/fstab, which is exactly what we need. Smiling

Hopefully this will be useful to someone.

Cheers

Comments

UDev, which should be part

 

UDev, which should be part of more or less every distro by now, can also help you with this.
It brings a little tool called vol_id, which you should be able to find in /lib/udev.

Here's a call and it's output:

Quote:

[root@thinkpad ~]# /lib/udev/vol_id /dev/sda1
ID_FS_USAGE=filesystem
ID_FS_TYPE=ext3
ID_FS_VERSION=1.0
ID_FS_UUID=dd250544-b058-48b1-b3f2-1024dd0243ef
ID_FS_UUID_ENC=dd250544-b058-48b1-b3f2-1024dd0243ef
ID_FS_LABEL=/boot
ID_FS_LABEL_ENC=\x2fboot
ID_FS_LABEL_SAFE=boot

A disadvantage about this is that it seems you have to be root for this.

Great! Thanks for sharing

Great! Thanks for sharing this. Smiling

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.