Cyberwizzard.nl

Welcome to my world

Determining the UUID of a partition

From Wikipedia:

A Universally Unique Identifier (UUID) is an identifier standard used in software construction, standardized by the Open Software Foundation (OSF) as part of the Distributed Computing Environment (DCE).

The intent of UUIDs is to enable distributed systems to uniquely identify information without significant central coordination. Thus, anyone can create a UUID and use it to identify something with reasonable confidence that the identifier will never be unintentionally used by anyone for anything else. Information labeled with UUIDs can therefore be later combined into a single database without needing to resolve name conflicts.

Since CentOS (and Ubuntu and others) use the UUID of partitions to mount or perform other operations on them, I needed to find the UUID of my storage partition. The downside to using UUIDs is obvious: I know the device name (/dev/sdb1) but I have no clue what the UUID of the partition is.

The upside is that if I move the drives around, so my /dev/sdb1 becomes /dev/sda1 for example, everything will still work because the identifiers remained unchanged.

Enough talking, I found 3 ways of finding the UUID of a drive on linux. Note that this is not all of them though, just enough for me.

Option 1: Use /dev

Since the UUID to device mapping needs to be done somewhere for the kernel and system tools, why not use that ourselves?

ls -l /dev/disk/by-uuid

Option 2: Use udev

The 'vol_id' program pulls the information from udev and presents it all in a fairly readable form. For some reason, my Ubuntu 10.10 does not have it anymore but possibly others still do.

vol_id /dev/sdb1

Option 3: Use blkid

The option I tend to use it to use the program called 'blkid'. Which as sole purpose (as its name suggests) is to show the block device ID of a block device *gasp*.

blkid /dev/sdb1