Command Line Basics: List Hard Drives By UUID

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.

[term]blkid[/term]

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:

[term]blkid /dev/sda3[/term]

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

[term]blkid -u filesystem /dev/sda3[/term]

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.

6 thoughts on “Command Line Basics: List Hard Drives By UUID

  1. Pingback: Destillat #26 | duetsch.info - Open Source, Wet-, Web-, Software

  2. Pingback: Links 28/3/2010: Sabayon 5.2 and GIMP Fun | Boycott Novell

  3. Stefan Koch

    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?

    Reply
    1. Linerd Post author

      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:
      [term]blkid -u filesystem /dev/sda3[/term]
      Take a look at
      [term]blkid -h[/term]
      for usage options.

      Reply
    2. Linerd Post author

      As a point of interest, here’s the version info from blkid -v from Ubuntu Jaunty
      [term]blkid 1.0.0 (12-Feb-2003)[/term]
      and from Karmic
      [term]blkid from util-linux-ng 2.16 (libblkid 2.16.0, 10-Feb-2009)[/term]
      This would likely explain the difference in behavior.

      Reply
  4. Pingback: fsdaily.com

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.