Ubuntu – Constant UUID on USB install


I've got an Ubuntu install on a USB with a separate NTFS partition, can I expect the same UUID for the partition if I removed and reattached the USB to a computer?

Best Answer

Usually the UUID of an external drive does not change. However under certain circumstances (e.g. by switching to another USB port) the UUID may become different.

Therefore we can mount drives using their label. Because we define the label by ourselves it will not change. However we need to take care to make unique labels for our drives.

Mounting by labels can also be done in the Fstab by adding a line similar to this:

LABEL="ExternalExt3"   /media/usb-ext3   ext3   defaults   0   2

To add or change a label we may use:

  • for FAT32:

    sudo mlabel -i /dev/sdc1 ::"my_label"
  • for NTFS:

    sudo ntfslabel /dev/sdc1 my_label
  • for ext2/3/4:

    sudo e2label /dev/sdc1 my_label

(adapt the values in the given examples to your system!). NTFS partitions can also be labeled with gparted.