Ubuntu – What’s the difference between USB, UUID, Disk identifier and Vendor ID

mountpointusbuuid

I need a persistent, unique identifier of a USB drive that never changes, to make a mount point folder.
Can you explain the difference between Disk Identifier, Vendor ID and UUID?

Can you also advise how I should set this mount point.

#fdisk -l | cut -f3 -d'/' | cut -f1 -d',' | grep 'Disk identifier:'

gets the Disk identifier.
and

#lsusb 

show me the vendor id
and

#blkid

and

#ls /dev/disk/by-uuid

show me the UUID

I've read about UUID , but couldn't find and comparison between those three
please help

Best Answer

Lets take these in turn:

Disk Identifier:

This applies to an entire hard disk drive (not a single partition). A Disk Identifier/Disk Signature is a 4-byte number that is randomly generated when the Master Boot Record/Partition Table is first created and stored. The Disk Identifier is stored at byte offset 1B8 (hex) through 1BB (hex) in the MBR disk sector. Windows Vista uses the Disk Signature to locate boot devices so changing it can prevent Vista from booting. Apart from being able to display it I am not sure if this is used by Linux.

Vendor ID

Every USB device has a Vendor ID (VID), Product ID (PID) and optionally a serial number. The Vendor ID is intended to identify the manufacturer of a product: all USB devices from the same manufacturer should have the same VID irrespective of what they are so a mouse, a phone, a disk drive, etc. if made from the manufacturer should be the same.

Each manufacturer is supposed to assign a unique PID to each product they make so the VID:PID combination should uniquely identify a particular product (make and model) some manufacturers choose to assign unique serial numbers to their products but others don't so you can not use the VID and PID to uniquely identify a device because if you ever buy another one of the same make and model It will be the same. In addition some manufacturers have been known to use the same PID for different similar models. The output of the lsusb command contains the VID:PID combination.

UUID

A UUID (Universally Unique Identifier) is a 128-bit number. UUIDs are used to identify many different things including some filesystem partitions. Where the UUID is stored for a filesystem depends on the filesystem. Linux ext2/ext3 and Windows NTFS identify filesystems by UUID. UUIDs are generated randomly using either the current time or a random number generator. The UUID is generated and stored when the filesystem is formatted and then does not usually change.

When you copy a partition or disk as raw binary data (for example, with "dd") the Disk Identifier or UUID is also copied. That can result in two disks or two partitions with the same identifier. There are utilities to change the UUID to a new (random) number. There are also utilities to change the Disk Identifier in the Master Boot Record.

The advantage to a UUID is that no matter where you move a filesystem, an operating system can find that particular filesystem. For filesystems that have no UUID the Disk Identifier can at least be used to locate the disk drive.

While it is possible to change the UUID in normal use this its unlikely to change.

Linux can use device names for partitions when UUIDs are not available. I would recommend using the UUID to identify your mount point.

To set the Mount point there are two options for drives that are permanently connected see the FSTAB -Community Documentation or for drives that are not always available if you are happy for it to appear as a subdirectory of /media/ but with a known name see RenameUSBDrive

A USB Drive can be formatted in lots of different formats. Many are formatted FAT by default because its a format that can be read by almost anything. But if this drive is only used on Linux it may be preferable to reformat it ext3 or ext4 see this question How to format a USB or external drive?

Related Question