Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 UUID.

share|improve this question
Thanks for all the answers, I'm sure I will use them all in different circumstances. – Brad Gilbert May 5 '09 at 3:45
Note that the title used to be "How do I find the UUID of a partition". That question only makes sense when using a GPT partition table. Here's an an answer to that question. – Alastair Irvine Mar 1 '15 at 6:59
up vote 77 down vote accepted

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:

topher@crucible:~$ sudo blkid /dev/sda1
/dev/sda1: UUID="727cac18-044b-4504-87f1-a5aefa774bda" TYPE="ext3"

Show UUID data for all partitions:

topher@crucible:~$ sudo blkid
/dev/sda1: UUID="727cac18-044b-4504-87f1-a5aefa774bda" TYPE="ext3"
/dev/sdb: UUID="467c4aa9-963d-4467-8cd0-d58caaacaff4" TYPE="ext3"

Show UUID data for all partitions in easier to read format: (Note: in newer releases, blkid -L has a different meaning, and blkid -o list should be used instead)

topher@crucible:~$ sudo blkid -L
device     fs_type label    mount point    UUID
/dev/sda1 ext3             /              727cac18-044b-4504-87f1-a5aefa774bda
/dev/sdc  ext3             /home          467c4aa9-963d-4467-8cd0-d58caaacaff4

Show just the UUID for /dev/sda1 and nothing else:

topher@crucible:~$ sudo blkid -s UUID -o value /dev/sda1
share|improve this answer
On my Ubuntu computer, I don't need to use sudo. – Brad Gilbert May 5 '09 at 3:28
Just typing blkid, got me exactly what I wanted, but not quite what I asked for. ( I'm accepting it anyway, because I am sure I will use it often ) – Brad Gilbert May 5 '09 at 3:38
On newer versions of Ubuntu the equivalent command for blkid -L is now blkid -o list; the -L option has been changed to -L label to look up a device that uses the specified label. – aculich Jan 29 '12 at 3:09
@aculich I've updated the answer to included the recent syntax for blkid. Thanks for mentioning it. – Christopher Cashell Mar 27 '12 at 19:41
Excellent, I never knew about blkid; I've always just done ls -l /dev/disk/by-uuid. On Gentoo, blkid is in sys-apps/util-linux – AdmiralNemo Mar 27 '12 at 23:48

The easiest way to do this for ext2/ext3/ext4 is:

/sbin/tune2fs -l /dev/sda1
share|improve this answer
This will work provided your filesystem is formatted as ext2, ext3 or ext4. Most filesystems are one of these but not all. It will also not work for swap partitions. See my answer for a universal way. – Hamish Downer May 2 '09 at 16:54

The recommended way to do this is to do

sudo vol_id -u /dev/sda2

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

sudo /lib/udev/vol_id -u /dev/sda2

If other distributions have vol_id in other places then post a comment and I'll add it to this answer.

share|improve this answer
This doesn't work on my Fedora 10 laptop. – Eddie May 2 '09 at 17:10
This is a much better solution than mine. Eddie, vol_id is located in /lib/udev. mish, could you edit your answer to prefix the full path in front of vol_id? /lib/udev isn't in root's path by default on any distribution I'm aware of. – Mihai Limbăşan May 2 '09 at 17:13
"/lib/udev/vol_id /dev/sda2" appears to work. Few people will have /lib/udev in their path. – Eddie May 2 '09 at 17:20
On my Ubuntu computer there is a symbolic link from /sbin/vol_id to /lib/udev/vol_id – Brad Gilbert May 3 '09 at 16:59
vol_id has been dropped from Ubuntu as of Karmic (9.10) so isn't useful or relevant anymore. It went through a lot of contortions to get there as vol_id was at one point built to replace blkid. – Alain O'Dea Dec 31 '15 at 3:51

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:

sudo sgdisk -i 1 /dev/sda

or all with:

ls -l /dev/disk/by-partuuid

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 root=/dev/sda1 or root=8:1.

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 root=UUID=87654321-4321-4321-a567-123456789012 refers to this.

I believe root=LABEL= and root=UUID= are implemented by early userspace, the init code I saw the other day on my system translated these parameters to /dev/disk/by-uuid and /dev/disk/by-label (links I believe are created by udev in userspace on my system).


share|improve this answer
Correct usage appears to be -i1 or -i 1, as opposed to -i:1, with sgdisk 1.0.1. – Charles Duffy Dec 29 '15 at 22:41
@CharlesDuffy thanks for finding that error. I've edited the answer to correct it. – John S Gruber Dec 31 '15 at 3:20

Assuming you want the UUID for sda1, you could try something like this:

for v in /dev/disk/by-uuid/* ; do echo "`readlink $v`: $v" | grep ../sda1 | cut -d\: -f2 | cut -d/ -f5 ; done

Adjust sda1 accordingly. To get the UUIDs for all partitions, drop the greps and cuts, a la:

for v in /dev/disk/by-uuid/* ; do echo "`readlink $v`: $v" ; done

Sample output for sda1 on my desktop:

[mihailim@home ~]$ for v in /dev/disk/by-uuid/* ; do echo "`readlink $v`: $v" | grep ../sdb3 | cut -d\: -f2 | cut -d/ -f5 ; done

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.

share|improve this answer
This will work on any computer running a recent enough devfs. – Eddie May 2 '09 at 17:13

This seems to work for me:

sudo dumpe2fs /dev/sda1 | grep UUID
share|improve this answer

You can use the following to get the UUID for a particular drive,

sudo vol_id -u /dev/sda1

or you can use this to list all UUIDs for the attached media,

ls /dev/disk/by-uuid
share|improve this answer
No longer applicable as of Ubuntu 9.10 as vol_id has been removed. – Alain O'Dea Dec 31 '15 at 3:52

You can also use this to print all the UUIDs:

for disk in /dev/disk/by-uuid/*; do 
    basename "$(readlink "$disk")"
    basename "$disk"

or this arguably simpler command, replacing sda1 with the device you'd like to search for:

find /dev/disk/by-uuid -type l -exec sh -c "readlink {} | grep -o $disk && basename {}" \;

an adaptation of the second method to print all UUIDs:

find /dev/disk/by-uuid -type l -exec sh -c 'basename $(readlink {}); basename {}; echo' \;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.