
The Universally Unique Identifier can be used to identify a device independent form its mount point or device name. This is more and more important as many devices today support hot-plugging or are external anyway. Therefore it makes sometimes sense to access a device (for example in fstab) not by device name but by the UUID.
There are several ways to get the UUID. The first one uses the /dev/ directory. While you are on is you might want to check other by-* directories, I never knew of them.
$ ls -l /dev/disk/by-uuid lrwxrwxrwx 1 root root 10 11. Okt 18:02 53cdad3b-4b01-4a6c-a099-be1cdf1acf6d -> ../../sda2
Another way to get the uuid by usage of the tool blkid:
$ blkid /dev/sda1 /dev/sda1: LABEL="/" UUID="ee7cf0a0-1922-401b-a1ae-6ec9261484c0" SEC_TYPE="ext2" TYPE="ext3"
There you also get the label and other information. Quite usefule.
Btw., if you wonder how “unique” this unique is, here a quote from Wikipedia:
1 trillion UUIDs would have to be created every nanosecond for 10 billion years to exhaust the number of UUIDs.
Pretty unique.
Thanks to Linux By Examples for the initial howto.

October 15, 2007 at 14:11
I use the following command:
sudo vol_id /dev/hdb5
and get something like this:
ID_FS_USAGE=filesystem
ID_FS_TYPE=ext3
ID_FS_VERSION=1.0
ID_FS_UUID=c4e17772-8d5f-4cf5-b254-6ea7684c5d6d
ID_FS_UUID_ENC=c4e17772-8d5f-4cf5-b254-6ea7684c5d6d
ID_FS_LABEL=/media/hdb5
ID_FS_LABEL_ENC=\x2fmedia\x2fhdb5
ID_FS_LABEL_SAFE=mediahdb5
October 15, 2007 at 14:48
Alberto, that command was also mentioned at the linked original howto, but Fedora does not provide that binary. So I think that vol_id might be Debian/Ubuntu only and therefore didn’t include it.
October 15, 2007 at 15:16
If it’s not under “/sbin/vol_id”, have you checked as “/lib/udev/vol_id”? It should be there even for Fedora.
“/sbin/vol_id” is available in Ubuntu.
October 15, 2007 at 15:18
“/dev/disk/by-uuid” is not available in Debian.
October 15, 2007 at 16:20
Béranger, it is available under /lib/udev, you’re right, but that is not in PATH.
October 16, 2007 at 11:57
@ Béranger, “/dev/disk/by-uuid” is available in Debian.
October 23, 2007 at 20:13
liquidat, does have any way (not manual) to rebuild fstab after change partitions?
October 23, 2007 at 21:54
Silvio, sorry, I never tried that. But the best would be to start a LiveCD and check the fstab the LiveCD creates on the fly. With the help of that you might find all necessary data to rebuild it, but only by hand.
I know that grml has some scripts to do that but never looked into them.
October 30, 2007 at 17:48
nice that UUID has advantages, but what if I clone a disk?
I have cloned a disk, and opensuse 10.3 can not boot anymore from the clone (identical harddisks). before opensuse 10.2 they did not use UUID and I was happy
October 30, 2007 at 21:29
tgifriday: If you want to clone a disk UUID won’t work because the clone technique does not clone the UUID afaik.
In such cases you want to use labels.
November 7, 2007 at 13:34
Actually, cloning seems to clone UUID, too. At least mirroring does. An example from my machine:
/dev/sdb1: UUID=”aeb1957f-b184-4810-a203-d7a4875da58a” SEC_TYPE=”ext2″ TYPE=”ext3″
/dev/sda1: UUID=”aeb1957f-b184-4810-a203-d7a4875da58a” SEC_TYPE=”ext2″ TYPE=”ext3″
/
Not a happy day…
November 7, 2007 at 15:12
Not good, there should be a flag/option to choose if you want to clone the UUID as well.
Nevertheless, this forum entry says how to change the UUID:
The last step is to verify that everything worked out.
November 13, 2007 at 15:59
Hehe… I have used the command
tune2fs -l “” | grep “UUID” | tail –bytes=37
to simply print out the UUID of a partition. I didn’t realize there was an easier way…
November 13, 2007 at 17:12
February 7, 2008 at 20:20
Hi everybody!!
Somebody knows how can I get UUID or WWLun from disks on HPTru64?
Best Regards,
Alejandro Suaza C.
February 7, 2008 at 22:52
Alejandro, this blog post is about Linux, not about Tru64. If you have problems using Tru64, the best is to ask HP’s customer support or to post the problem (including error messages and a description of what you’ve already tried and why that has failed; not just a question like you did) at an appropriate forum.
A blog is never the place to discuss a problem in detail.
March 29, 2008 at 4:47
Thank you Liquidat, you just save my sanity.
I struggled with restoring grub and then had to deal with a faulty boot sequence because of an erroneous UUID. After running “blkid /dev/sdb2″ and inserting the results in fstab all is well.
Thanks again,
Dean
March 29, 2008 at 16:33
Thank you very helpfull!;)
March 29, 2008 at 16:42
You’re welcome, I’m glad I was able to help
April 18, 2008 at 0:19
Does anybody knows how to get that kind of information from a cdrom? Not only the uuid, but also the label.
May 6, 2008 at 13:30
hi,
just a word to say i’ve translated your post to French
http://www.manga-burgah.net/?2008/05/06/142-uuid-et-fstab
sorry, no trackback, i’ve frozen those features because of heavy spam attacks (and obsolete version of Dotclear
May 6, 2008 at 13:56
oli44: Thanks for pointing out – and the link back to the original plus the name of the original author is all which is needed anyway
August 8, 2008 at 16:31
Also, Though I am a newbie
WHat will happen
If Virtual Operating System image boots over Host Operating System?
Being familiar with Ms-Virtual PC.
Using Ms-Virtual PC software,
Windows XP + Red Hat Linux 9 operated together
on 1 Host Windows XP OS
What will happen to hardware identification like
MAC Address of NIC(s)
Hard Disc Idenfitication etc? then?
May be they will all show same values …
August 8, 2008 at 23:29
I don’t know, I guess it depends on the virtual machine – and since I’m not familiar with MS virtual PC I can’t help you there.