Linux.com

Home Linux Community Community Blogs General Linux HowTo modify UUID for an NTFS Partition

HowTo modify UUID for an NTFS Partition

Every make the mistake of having used gparted to copy-paste some NTFS partitions on a drive and wind up with multiple partitions w/ the same UUID? For EXT2 / EXT3 this si an easy fix, because you just need to run tune2fs to alter the UUID. But there's no equivelent tool for NTFS.

Well, This very topic recently came up on the mailing list for one of the LUGs I attend and after I shared my solution w/ the list, I thought maybe I should share it here, too.

The *easiest* thing to do is to just alter the label of the disk using a tool like ntfslabel and altering the fstab to use the label instead of the UUID, but sometimes this just isn't enough. Sometimes, you NEED to change the UUID.

Well, that's when we perform surgery on the NTFS superblock. Luckilly MS has actually documented the contents of the superblock pretty well, and explained that the volume serial number is the eight bytes beginning at offset 0x48. Altering that serial number will give you a new UUID. So, here's the trick:

 

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

 

That's it! Nothing to it. Below, see a dump of one of my NTFS superblocks where I've highlighted the serial number:

 

 

adam@adam-laptop:~$ hd block 

00000000  eb 52 90 4e 54 46 53 20  20 20 20 00 02 08 00 00  |.R.NTFS    .....|

00000010  00 00 00 00 00 f8 00 00  3f 00 ff 00 3f 00 00 00  |........?...?...|

00000020  00 00 00 00 80 00 80 00  24 97 ff 04 00 00 00 00  |........$.......|

00000030  00 00 0c 00 00 00 00 00  72 f9 4f 00 00 00 00 00  |........r.O.....|

00000040  f6 00 00 00 01 00 00 00  69 28 05 50 64 05 50 3a  |........i(.Pd.P:|

00000050  00 00 00 00 fa 33 c0 8e  d0 bc 00 7c fb b8 c0 07  |.....3.....|....|

00000060  8e d8 e8 16 00 b8 00 0d  8e c0 33 db c6 06 0e 00  |..........3.....|

00000070  10 e8 53 00 68 00 0d 68  6a 02 cb 8a 16 24 00 b4  |..S.h..hj....$..|

00000080  08 cd 13 73 05 b9 ff ff  8a f1 66 0f b6 c6 40 66  |...s......f...@f|

00000090  0f b6 d1 80 e2 3f f7 e2  86 cd c0 ed 06 41 66 0f  |.....?.......Af.|

000000a0  b7 c9 66 f7 e1 66 a3 20  00 c3 b4 41 bb aa 55 8a  |..f..f. ...A..U.|

000000b0  16 24 00 cd 13 72 0f 81  fb 55 aa 75 09 f6 c1 01  |.$...r...U.u....|

000000c0  74 04 fe 06 14 00 c3 66  60 1e 06 66 a1 10 00 66  |t......f`..f...f|

000000d0  03 06 1c 00 66 3b 06 20  00 0f 82 3a 00 1e 66 6a  |....f;. ...:..fj|

000000e0  00 66 50 06 53 66 68 10  00 01 00 80 3e 14 00 00  |.fP.Sfh.....>...|

000000f0  0f 85 0c 00 e8 b3 ff 80  3e 14 00 00 0f 84 61 00  |........>.....a.|

00000100  b4 42 8a 16 24 00 16 1f  8b f4 cd 13 66 58 5b 07  |.B..$.......fX[.|

00000110  66 58 66 58 1f eb 2d 66  33 d2 66 0f b7 0e 18 00  |fXfX..-f3.f.....|

00000120  66 f7 f1 fe c2 8a ca 66  8b d0 66 c1 ea 10 f7 36  |f......f..f....6|

00000130  1a 00 86 d6 8a 16 24 00  8a e8 c0 e4 06 0a cc b8  |......$.........|

00000140  01 02 cd 13 0f 82 19 00  8c c0 05 20 00 8e c0 66  |........... ...f|

00000150  ff 06 10 00 ff 0e 0e 00  0f 85 6f ff 07 1f 66 61  |..........o...fa|

00000160  c3 a0 f8 01 e8 09 00 a0  fb 01 e8 03 00 fb eb fe  |................|

00000170  b4 01 8b f0 ac 3c 00 74  09 b4 0e bb 07 00 cd 10  |.....<.t........|

00000180  eb f2 c3 0d 0a 41 20 64  69 73 6b 20 72 65 61 64  |.....A disk read|

00000190  20 65 72 72 6f 72 20 6f  63 63 75 72 72 65 64 00  | error occurred.|

000001a0  0d 0a 4e 54 4c 44 52 20  69 73 20 6d 69 73 73 69  |..NTLDR is missi|

000001b0  6e 67 00 0d 0a 4e 54 4c  44 52 20 69 73 20 63 6f  |ng...NTLDR is co|

000001c0  6d 70 72 65 73 73 65 64  00 0d 0a 50 72 65 73 73  |mpressed...Press|

000001d0  20 43 74 72 6c 2b 41 6c  74 2b 44 65 6c 20 74 6f  | Ctrl+Alt+Del to|

000001e0  20 72 65 73 74 61 72 74  0d 0a 00 00 00 00 00 00  | restart........|

000001f0  00 00 00 00 00 00 00 00  83 a0 b3 c9 00 00 55 aa  |..............U.|

 

 

Comments

Subscribe to Comments Feed

Upcoming Linux Foundation Courses

  1. LFD320 Linux Kernel Internals and Debugging
    04 Aug » 08 Aug - Virtual
    Details
  2. LFD405 Embedded Linux Development with Yocto Project
    04 Aug » 07 Aug - Santa Clara, CA
    Details
  3. LFD312 Developing Applications For Linux
    18 Aug » 22 Aug - Virtual
    Details

View All Upcoming Courses


Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board