9

I'm trying to setup /etc/fstab to automatically mount two external NTFS hard drives on boot, and decided to use the UUIDs as reference instead of the device names.

Strangely, blkid reports that both hard disks have the exact same UUID, so I am unable to add both entries into the file. Here's what it shows for the two disks:

/dev/sdc1: LABEL="Hank's Legacy" UUID="D8249BB8249B97D8" TYPE="ntfs" PARTUUID="61bf885b-01"

/dev/sdb1: LABEL="Hank's Mainframe" UUID="D8249BB8249B97D8" TYPE="ntfs" PARTUUID="f865b797-01"

I read that tune2fs cannot be used to modify the UUID for NTFS partitions, because this is technically not a UUID, but a serial number. Any suggestions on how I can mount the two disks without causing conflicts?

Maythux
  • 84,289
Phani K
  • 475
  • Nothing to add to the various responses you already got below. However the fact that two drives should end up with the same UUID is improbable that it strikes me as practically impossible. So 1 question: have you at one point or another performed a bit to bit copy of one drive to the other (using dd for instance) ? – Cbhihe Jun 30 '15 at 11:03
  • @Cbhihe, see my answer. It is possible (though extremely rare) if drives are factory-formatted... – Fabby Jun 30 '15 at 11:19
  • 1
    @Fabby: I had seen your answer. I stand by my comment especially because we don't now whether Phanindra_K bought identical drives, at the same time, with almost identical S/N, etc... etc... The probability for that happening is infitesimal. I am just curious to see whether there is another explanation. Usually the error or the glitch occurs between chair and keyboard. – Cbhihe Jun 30 '15 at 11:24
  • @Cbhihe: Yes, these were two identical hard drives purchased in the same order. I've never done a disk-to-disk copy on them. – Phani K Jul 07 '15 at 14:59
  • 1
    In that case, as improbable as that may be, you may have exactly what @Fabby suggested. Hope you are now passed the problem. It may look a bit scary because you may think that your entire drive is in danger, but in fact, I definitely would use the solution you chose. Change the UUID of one drive. The label change is just icing on the cake. When push comes to shove, what is important in terms of physical volume management is the UUID, especially if you manage a large number of UUIDs. -ced. – Cbhihe Jul 07 '15 at 18:30
  • @Cbhihe: I'm an old fart: I've seen this multiple times before... It's a mistake HDD manufacturers make from time to time. If you've been running a data centre with 1000s of servers and 10000 hard disks, I've seen this with: DOS, Windows and Unix! (only about 10 times in one and the same server, but still: not 0) ;-) – Fabby Jul 07 '15 at 19:44

3 Answers3

14

To mount an NTFS drive we can also use a disk label only. We can safely change the label from Windows or by using ntfslabel Install ntfslabel. See

Needless to say that by using ntfslabel we can also change a partition's UUID (aka serial number). To avoid negative effects on the UUID dependent Windows file allocation we should only change the upper part of the UUID (which is not used by Windows):

sudo ntfslabel --new-half-serial[=ssssssss] /dev/sdXN

Example:

enter image description here

Takkat
  • 142,284
  • Good one if the user is an advanced user! Otherwise "copy all data to one drive, reformat the other" is easier for a beginning user! ;-) (Upvoted!) – Fabby Jun 30 '15 at 11:28
  • Actually the OP apparently already has a label for their drives. So it's just an edit of the fstab - udisks mount to /media should already use the label. – Takkat Jun 30 '15 at 11:31
  • 1
    Thank you for this answer! @Fabby: I knew this was an option, but there's simply too much data in those drives to do multiple copy-overs. :) – Phani K Jul 02 '15 at 16:17
  • 1
    @PhanindraK: As you've never accepted any answer on this site before: If this answer helped you, don't forget to click the grey at the left of this text, which means Yes, this answer is valid! ;-) – Fabby Jul 02 '15 at 16:51
  • Takkat: I have strong doubts that what you propose is really about changing the UUID of any partition. This looks, smells and sounds like changing some serial number pertaining to a drive sdX , not the UUID of a partition on any drive. Phanindra_K's question is about UUID changing, which is what @Ron addresses more correctly imho. – Cbhihe Jul 07 '15 at 19:33
  • @Cbhihe: thanks for the notice. For NTFS the partiton's serial number is used as the UUID for Ubuntu. We can change this number as shown above but we should not change the whole serial number as this may e.g. invalidate a Windows license key. – Takkat Jul 07 '15 at 20:09
  • Just to be clear, the device in the example above should be /dev/sdXN where you substitute you own values for X and N, not /dev/sdX. Presumably ntfslabel would not permit you to corrupt the MBR but I'm not going to risk it to test! – Chris Good Aug 20 '15 at 05:21
  • @ChrisGood: thank you for this valuable point. Edited the post to better make clear that we are talking about partitions here. – Takkat Aug 20 '15 at 05:42
3

Interesting! There is a way to modify the UUID of ntfs partition by modifying the superblock as documented here. It says that volume serial number is the eight bytes beginning at offset 0x48 in an ntfs formatted drive/partition so, altering it will change the serial number/UUID. To reproduce it:

dd if=/dev/sda# of=my_block bs=512 count=1

ghexedite2 my_block (or what ever hex editor you like. Alter a byte or two between 0x48 and 0x4f, inclusive)

dd if=my_block of=/dev/sda# bs=512 count=1

I have not tried this myself, but looks interesting.

Note: dd is Disk Destroy :) so use with caution!

Ron
  • 20,638
  • I am veeery wary when I use dd to directly access disks.. so I wouldn't use your solution unless I know EXACTLY what I'm modifying. You're right about Disk Destroy and I can't afford to do that with these disks! – Phani K Jul 02 '15 at 16:47
  • However, reading this was very educational.. so thank you for the information! – Phani K Jul 02 '15 at 16:48
  • 1
    @Phanindra_K: Understandably you are cautious, but to take the feeling of danger away from all this just see this at https://www.linux.com/community/blogs/133-general-linux/289198. It is hard to do better at explaining what Ron suggested, which btw IS the right solution to your problem. – Cbhihe Jul 07 '15 at 19:42
0

This is somehow strange, anyway inorder to use your hdds you can use the /dev/sdX instead of UUID, so you can add then both HDD.

/dev/sdb1 /mount-point ntfs defaults,uid=USER_ID,rw  0  0

It's advised to read this: How do I correctly mount a NTFS partition in /etc/fstab?

Maythux
  • 84,289