Im writing a script to change the UUID of an NTFS partition (AFAIK, it's not there). This means writing 8 bytes from 0x48 to 0x4F (72-79 decimal) from /dev/sdaX (X is # of my section).
If I wanted to change it to a random UUID, I could use this:
dd if=/dev/urandom of=/dev/sdaX bs=8 count=1 seek=9 conv=notrunc
Or I could change /dev/urandom to /dev/sdaY to clone the UUID from another partition.
But ... what if I want to create a personalized UUID? I already saved (and checked the regular expression) in the $UUID variable in hexadecimal string format (16 characters), for example:
UUID="2AE2C85D31835048"
I thought about it:
echo "$UUID" | xxd -r -p | dd of=/dev/sdaX ...
It's just a scratch ... I'm not sure about the exact option to make it work. My question is:
- Is
echo $var | xxd -r | dd really echo $var | xxd -r | dd echo $var | xxd -r | dd echo $var | xxd -r | dd best approach? - What will be the exact command and parameters to make it work?
As for the answers, Im also looking for:
- An explanation of all the options used and what they do.
- If possible, an alternative command to check it in the file and / or screen before changing the section.
I already have a 100-byte ntfs.bin dump file which I can use for tests and check the results with
xxd ntfs.bin
Therefore, any solution that gives me a way to check the results using xxd on the screen, so I can compare with the original ntfs.bin file, will be highly appreciated.
Thanks!
source share