Command Line Basics: List Hard Drives By UUID

March 26, 2010 by
Filed under: command line, HowTo, linux 

Recent versions of Linux use a unique identifier for hard drives in order to make sure they get mounted to the same location all the time. If you've looked into your /etc/fstab file for auto mounting drives, then you're probably already familiar with the long character strings that are used for UUID's.

The question is, how do I find out the UUID for each drive on my computer? Well, there's more than one way to do this, but the simplest is probably the blkid command.

blkid

This will list all of the drives on your system. If you're only interested in finding the UUID of a particular drive partition, then just enter that partition device after the command. For example, to find the UUID of partition 3 on drive "a" enter:

blkid /dev/sda3

Edit: Based on Stefan's comment below, your system may behave differently. You may have to invoke the command like this:

Affiliate Link
blkid -u filesystem /dev/sda3

This can be  useful if you've added a drive to your system, or you've modified the partitions on an existing drive and you want to make appropriate changes to the /etc/fstab file.

Comments

6 Responses to “Command Line Basics: List Hard Drives By UUID”

  1. [...] Command Line Basics: List Hard Drives By UUID [...]

  2. [...] Command Line Basics: List Hard Drives By UUID [...]

  3. Thanks, I did not know this command. I usually just used “ls -l /dev/disk/by-uuid/”.

    Even though “blkid” works fine, “blkid [device]” does not work (it just does not output anything). Any hints?

    • Linerd says:

      Yeah, I just learned the command myself. I've used the same ls command in the past.

      It's funny. I wrote this post on my netbook running Ubuntu Jaunty and it worked fine. Now on my Karmic desktop I have the same issue. Even blkid did nothing at first until I invoked it with sudo. Maybe the default behavior in Jaunty is different. Try something like:

      blkid -u filesystem /dev/sda3

      Take a look at

      blkid -h

      for usage options.

    • Linerd says:

      As a point of interest, here's the version info from blkid -v from Ubuntu Jaunty

      blkid 1.0.0 (12-Feb-2003)

      and from Karmic

      blkid from util-linux-ng 2.16 (libblkid 2.16.0, 10-Feb-2009)

      This would likely explain the difference in behavior.

  4. Story added...

    This story has been submitted to fsdaily.com! If you think this story should be read by the free software community, come vote it up and discuss it here:

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>