Robot Butler
  Making those complicated tasks nice and easy.
  A hub for guides, walkthroughs and general information.
Follow us on Twitter RSS Feed
Linux Finding the UUID of a Drive
Pubish Date 2010-09-11 14:13:03 Category Linux Author Benjamin Hodgetts Comments 0 comments
The benefits of identifying a drive by UUID are that the UUID only changes if you format the drive, you don't need to worry about adding another hard drive to your computer and suddenly your fstab or custom mount scripts mounting the wrong drive or even worse, a drive being wrongly formatted or partitioned.

There are several applications you can use to find out the UUID of a drive, these are blkid and vol_id. Both will tell you the UUID of a drive but vol_id also works for USB devices and gives you a little more output than blkid. Many newer distributions of Linux have dropped vol_id in favour of blkid so you may not have much choice which you use.

They both work in the same fashion, you simply run the command followed by the target drive partition. Both need to be run as root to have sufficient permission to do this (either via sudo or switching to root via su before hand). Examples and their output below:

$ blkid /dev/sdg1 /dev/sdg1: LABEL="Seagate-1.5TB" UUID="029df206-885c-47cc-9dae-f702fa2df529" TYPE="ext4"

$ vol_id /dev/sdg1 ID_FS_USAGE=filesystem ID_FS_TYPE=ext4 ID_FS_VERSION=1.0 ID_FS_UUID=029df206-885c-47cc-9dae-f702fa2df529 ID_FS_LABEL=Seagate-1.5TB ID_FS_LABEL_SAFE=Seagate-1.5TB

blkid should be in its own package on most Linux distributions. vol_id used to be part of UDev.


If you need to find out which package these applications belong to (if you need to install them) then you can normally use your package manager to search for the name. If this turns up nothing then you can use different methods depending on your distribution:

Ubuntu and Debian: Install apt-file if you haven't already and use 'apt-file search appname'
Gentoo: The command 'equery belongs appname' will tell you the parent package
Fedora, CentOS and RedHat: Just use 'rpm -qf appname'

Replacing 'appname' in each example with the app you're looking for, for example blkid or vol_id.

Comments

No comments yet.

Post a Comment

    Name
    Email (not displayed)

The name of this website is Robot...      


Info STATISTICS

  • 14 categories
  • 50 articles
  • 137 comments

Site, design and code by Benjamin Hodgetts.