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 file system label, but there doesn't seem to be a similar way to find the UUID.


13 Answers 13


Another command that might be available and also works quite well for this is 'blkid'. It's part of the e2fsprogs package. Examples of its 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 an 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

  • 1
    On my Ubuntu computer, I don't need to use sudo. Commented May 5, 2009 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 ) Commented May 5, 2009 at 3:38
  • 3
    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
    Commented Jan 29, 2012 at 3:09
  • @aculich I've updated the answer to included the recent syntax for blkid. Thanks for mentioning it. Commented Mar 27, 2012 at 19:41
  • 2
    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 Commented Mar 27, 2012 at 23:48

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 setups 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 usually aren't anymore 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).

[1] devt_from_devname()

  • Correct usage appears to be -i1 or -i 1, as opposed to -i:1, with sgdisk 1.0.1. Commented Dec 29, 2015 at 22:41
  • @CharlesDuffy thanks for finding that error. I've edited the answer to correct it. Commented Dec 31, 2015 at 3:20

The script-clean way to do this which works on any type of filesystem is:

lsblk -no UUID <device-containing-FS>

Or, given the mountpoint (or any file within it):

lsblk -no UUID $(df -P <file> | awk 'END{print $1}')

The output is the UUID, the whole UUID, and nothing but the UUID.

  • 1
    It's better than blkid in the answer from @christopher-cashell, because you don't need to become root. For a mount point or a file better do: lsblk -no UUID $(findmnt -n -o SOURCE --target <file>) .
    – marcz
    Commented Dec 18, 2018 at 13:12
  • @marcz That fails on btrfs subvolumes: findmnt -n -o SOURCE --target ~ gives: /dev/mapper/vg_svelte-home[/@home]
    – Tom Hale
    Commented Dec 19, 2018 at 1:57
  • Right @tom-hale, lsblk -no UUID $(findmnt -n -o SOURCE --target <file> | cut -d[ -f1) should get rid of the subvolume when present.
    – marcz
    Commented Dec 20, 2018 at 12:22

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

/sbin/tune2fs -l /dev/sda1
  • 4
    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. Commented May 2, 2009 at 16:54
  • 1
    This results in my case into Couldn't find valid filesystem superblock.
    – Michel
    Commented Nov 7, 2016 at 15:34

This seems to work for me:

sudo dumpe2fs /dev/sda1 | grep UUID

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 it should work for any Linux distribution 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
  • 1
    This doesn't work on my Fedora 10 laptop.
    – Eddie
    Commented May 2, 2009 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. Commented May 2, 2009 at 17:13
  • "/lib/udev/vol_id /dev/sda2" appears to work. Few people will have /lib/udev in their path.
    – Eddie
    Commented May 2, 2009 at 17:20
  • On my Ubuntu computer there is a symbolic link from /sbin/vol_id to /lib/udev/vol_id Commented May 3, 2009 at 16:59
  • 5
    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. Commented Dec 31, 2015 at 3:51

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


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.

  • This will work on any computer running a recent enough devfs.
    – Eddie
    Commented May 2, 2009 at 17:13

The simplest and best way to find the UUID of a filesystem:

blkid /dev/sda1
  • 1
    Does this add anything to the accepted answer?
    – chicks
    Commented May 27, 2021 at 15:14

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' \;
ls -l /dev/disk/by-uuid | grep `lsblk | grep "/" | awk '{print $1}'` | awk '{print $9}'

The above seems to work on most (all I have found) Linux systems over many years. It may have flaws, I don't know. I would prefer to get the serial number but ... this is the UUID of the root filesystem.

If anyone has a way to get the serial number without needing to be root (as mine is) and not installing "unusual" packages that are different in different versions of Unix I would appreciate it - always can learn something. And I am aware I am mixing things - the is the root file system UUID, not a disk.

The purpose, BTW, is to generate a unique number per machine that cannot be modified (like a disk serial number and like MAC addresses once were long ago).

It is used for encoding of software to a single machine. MAC address was fine until they allowed them to be virtual ... some sleazy customers have simply set their MAC address to a constant (on different networks of course) and avoided paying me.

In AIX there is a single call to get one number that identifies the machine. It does not care if the hardware changes or software updates occur so I have no idea how they do it ... If the motherboard changes, then the number changes, so I think they hide it there. And that is beyond rare.

  • Something seems to be missing near "the is the root file system". Commented Mar 8, 2023 at 12:47
  • OK, the OP has left the building - "Last seen more than 5 years ago" Commented Mar 8, 2023 at 12:47

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

sudo vol_id -u /dev/sda1

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
  • No longer applicable as of Ubuntu 9.10 as vol_id has been removed. Commented Dec 31, 2015 at 3:52
sudo grep swap /etc/fstab
## Output like:
# swap was on /dev/sda6 during installation
# UUID=34e3f31b-16ec-4c84-8f4d-339f38d04a3b none swap sw 0 0

sudo lsblk -f -l| grep SWAP
## Output like:
sda6 swap 34e3f31b-16ec-4c84-8f4d-339f38d04a3b [SWAP]
  • An explanation would be in order. For example, what is the conclusion? How does it answer the question? What is the gist? Please respond by editing (changing) your answer, not here in comments (***** ***** without ***** ***** "Edit:", "Update:", or similar - the answer should appear as if it was written today). Commented Mar 8, 2023 at 12:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .