Is UUID of a disk an attribute of the disk or system generated?

1

I am trying automate a task of syncing particular file ext on dozen of linux systems (not in same network) on a external HDD. So logically first part in the task would be to check if the disk is mounted or not. I am thinking of achieving this by recoginizing the disk by its UUID.

So thats the questions : If the UUID (output of blkid for UUID) would be same for the particular disk on all the machines or different?

juggernauthk108

Posted 2016-12-28T09:49:37.610

Reputation: 127

Answers

1

A UUID is system generated, and is globally unique - but if you do a bit copy of a drive the UUID will, of-course, be the same on both drives/all partitions on each drive.

Under Ubuntu (and I am sure most other Linux variants) it can be generated using the uuidgen command. The man page for this command states " The uuidgen program creates (and prints) a new universally unique identifier (UUID) using the libuuid(3) library. The new UUID can reasonably be considered unique among all UUIDs created on the local system, and among UUIDs created on other systems in the past and in the future."

davidgo

Posted 2016-12-28T09:49:37.610

Reputation: 49 152

1

I plugged the same USB flash drive into two different systems and all UUID and PARTUUID information stayed the same across. So it is the same for a particular disk. However it will change when a new partitioning table is created and formatting occurs.

System1:

$ sudo blkid /dev/sdd1
/dev/sdd1: UUID="1243787E34100219" TYPE="ntfs" PARTLABEL="primary" PARTUUID="f2e13711-240b-46e1-a754-02e3427ed8fd"
$ sudo blkid /dev/sdd2
/dev/sdd2: UUID="10BF79B17BE2BB24" TYPE="ntfs" PARTLABEL="primary" PARTUUID="96eb89ca-e013-4fa3-87ca-aca5763f4065"
$ sudo blkid /dev/sdd
/dev/sdd: PTUUID="0d02ca7d-b4bd-47a8-8df8-70c972be025f" PTTYPE="gpt"

System2:

$ sudo blkid /dev/sda1
/dev/sda1: UUID="1243787E34100219" TYPE="ntfs" PARTLABEL="primary" PARTUUID="f2e13711-240b-46e1-a754-02e3427ed8fd"
$ sudo blkid /dev/sda2
/dev/sda2: UUID="10BF79B17BE2BB24" TYPE="ntfs" PARTLABEL="primary" PARTUUID="96eb89ca-e013-4fa3-87ca-aca5763f4065"
$ sudo blkid /dev/sda
/dev/sda: PTUUID="0d02ca7d-b4bd-47a8-8df8-70c972be025f" PTTYPE="gpt"

Serhat Cevikel

Posted 2016-12-28T09:49:37.610

Reputation: 219

Great @jlliagre thanks, I had presented the partitions in different orders. – Serhat Cevikel – 2016-12-28T10:38:30.127