Sparing most details/reasons, I have a situation in which I'm cloning drives for mass production. Some of them are being installed in servers that only need one disk (in that case this is a non-issue), but some are being installed in servers that will use 2 of them in RAID1.
In another case we're building a tool to assist the admin in replacing a faulty disk by ensuring the new disk is large enough and then copying the MBR and Partition Table, and then adding it to the RAID1. When this happens LILO complains about duplicate volume IDs (which makes sense).
This is why I would like to generate new volume IDs for the partition being added to the RAID1 array. Does it make sense to use sfdisk to rewrite a disks partition table, or is there a more straightforward command/technique to create a new volume id for an existing volume?
Read the mbr from the disk, change the disk signature which is the 4 bytes @ offset 440 in the mbr then write it back to the disk.
Note: I tested this by saving the output of od -x for mbr.dat and newmbr.dat and then running a diff on the 2 text files which shows that only the relevant 4 bytes are changed.