8

When cloning a drive (using dd), will the UUID's for each partition change, or are they hardware specific? or does cloning it preserve the UUID as well?

What happen if a system detected two devices with the same UUID?

Matt Clark
  • 2,019
  • 3
  • 23
  • 35

1 Answers1

12

UUIDs are not hardware-specific but stored in the partition's filesystem. That means cloning a disk or partition with dd will result in the same UUID.

You can assign a new UUID by using:

  • tune2fs -U random <device> (ext2/ext3/ext4)
  • xfs_admin -U generate <device> (xfs)
  • reiserfstune -u $(uuidgen) <device> (reiserfs)
  • mkswap -U $(uuidgen) <device> (swap)

Having duplicated UUIDs doesn't necessarily lead to errors. However booting and mounting a device by UUID will become ambiguous and may lead to the wrong device being used.

scai
  • 1,032
  • 10
  • 18
  • 1
    "However booting and mounting a device by UUID will become ambiguous and may lead to the wrong device being used." Yes. This can become really dangerous when a cloned disk is used as backup. You need to double check that /home is really the disk you think it is. A "backup" done in the wrong direction can wipe out data from both disks. – Eric Duminil Apr 29 '22 at 13:45