UUID and Drive Cloning

11,019

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.

Share:
11,019

Related videos on Youtube

Matt Clark
Author by

Matt Clark

I dream;    I design;   I build;    I program;  I repeat; I design;   I build;    I program;  I repeat;   I dream; I build;    I program;  I repeat;   I dream;    I design; I program;  I repeat;   I dream;    I design;   I build; I repeat;   I dream;    I design;   I build;    I program; MClarkDev.com    [email protected]

Updated on September 18, 2022

Comments

  • Matt Clark
    Matt Clark over 1 year

    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?

    • Ƭᴇcʜιᴇ007
      Ƭᴇcʜιᴇ007 about 10 years
      Why not just try it yourself and see if they change?
    • Matt Clark
      Matt Clark about 10 years
      32gb USB to USB across a VM.... :'(
    • Ƭᴇcʜιᴇ007
      Ƭᴇcʜιᴇ007 about 10 years
      If you just want to test if DD changes UUID's or not, then why not just use a small test source disk/partition with little data on it, locally?
    • Matt Clark
      Matt Clark about 10 years
      And the last part is still valid. If the UUID stays the same, how the the system deal with multiple of the same UUID? I guess that works...
    • Ƭᴇcʜιᴇ007
      Ƭᴇcʜιᴇ007 about 10 years
    • Matt Clark
      Matt Clark about 10 years
      I failed to find this in my initial search. Found my answer, and I appreciate the help.
  • Admin
    Admin about 2 years
    "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.