I'm running Ubuntu, and want to find out the
UUID of a particular filesystem (not partition). I know I can use
e2label /dev/sda1 to find out the filesystem label, but there doesn't seem to be a similar way to find the
Another command that might be available and also works quite well for this is 'blkid'. It's part of the e2fsprogs package. Examples of it's usage:
Look up data on /dev/sda1:
Show UUID data for all partitions:
Show UUID data for all partitions in easier to read format:
(Note: in newer releases,
Show just the UUID for /dev/sda1 and nothing else:
Assuming you want the UUID for sda1, you could try something like this:
Adjust sda1 accordingly. To get the UUIDs for all partitions, drop the greps and cuts, a la:
Sample output for sda1 on my desktop:
Edit: Please note that this solution, while more contrived than the udev->vol_id one, does not require root privileges, will work on any post-2005 or so kernel, and relies on tools present in any Linux distribution which are by default in the path for any user.
The recommended way to do this is to do
For more on using UUIDs, see this article (from ubuntu help, but should work for any linux distro using UUIDs).
As noted in comments to this question, vol_id may not be in your path. On ubuntu it is in /sbin so the above will work. For fedora it appears to need
If other distributions have vol_id in other places then post a comment and I'll add it to this answer.
You can use the following to get the UUID for a particular drive,
or you can use this to list all UUIDs for the attached media,
You can also use this to print all the UUIDs:
or this arguably simpler command, replacing
an adaptation of the second method to print all UUIDs:
For GPT Partitioned Disks Only
On a GPT formatted disk each partition is assigned a GUID, which is a form of UUID, though probably not what the original poster was referring to. Therefore this answer is probably less helpful to the original questioner. Nevertheless I believe there's an important distinction to be noticed.
To get the GUID of partition 1 on GPT formatted disk /dev/sda, as well as its partition label and so on:
or all with:
To boot with the root of the file system being on a certain partition you would use the linux kernel parameter syntax of:
In this case you can specify just the beginning of the UUID--enough to be unique. This parameter is more primitive and can be understood by the kernel earlier in its boot process.
There's a difference in semantics between these:
A disk holds partitions, a partition holds a file system, a file system holds directories and files. For some set-ups and operating systems there are more layers.
The GUID UUID and associated label refer to a partition, but not the partition's contents. A new partition on the same disk, or a partition on a new disk will have a new GUID UUID. The same partition could hold one file system one day and another on a different day. It only exists for GPT formatted disks, but not for legacy partitioned disks. There's usually no more utility here than specifying
The other current answers refer to the UUID of a file system in some containing partition. If the file system is copied, as a whole, to another partition or hard disk that value remains the same. This UUID is useful in finding a moved file system. Therefore this is probably more pertinent to most people. Linux kernel parameter