7

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?

Oxwivi
  • 17,849

1 Answers1

4

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.

Takkat
  • 142,284
  • Never knew fstab could use labels as well, thanks for the heads up! – Oxwivi Jun 17 '11 at 17:56
  • You did not define any option other than defaults, will a user be able to read/write properly? – Oxwivi Jun 18 '11 at 07:56
  • @Takkat, please answer in this question. – Oxwivi Jun 18 '11 at 08:20
  • While I do know what options defaults specify, I cannot comprehend if it does affect user read/write or not. – Oxwivi Jun 18 '11 at 08:31
  • I ran into a problem. As I said in the question, it was an USB install, and after I did the necessary changes, it says drive for /media/NTFS/ not ready. Do I spin it off into a separate question? By the way, mlabel doesn't work for NTFS. – Oxwivi Jun 20 '11 at 04:24
  • @Takkat, yes, I relabeled successfully, just making a note of it. I've lost count of how many times I've installed and reinstalled, so I'm afraid I've decided to purge NTFS (harddisk replacement took more priority to having a portable storage medium). – Oxwivi Jun 20 '11 at 13:02
  • @Oxwivi: I know how this happens to NTFS partitions :) Added the note to my answer. – Takkat Jun 20 '11 at 13:18