# Replicate MBR disk with random UUIDs?

**URL:** <https://forums.rockylinux.org/t/replicate-mbr-disk-with-random-uuids/4057>\
**Category:** Rocky Linux Help & Support\
**Created:** [September 14, 2021, 9:31am UTC](https://forums.rockylinux.org/t/replicate-mbr-disk-with-random-uuids/4057 "2021-09-14T09:31:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![microlinux](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/microlinux/32/1244_2.png) [@microlinux](https://forums.rockylinux.org/u/microlinux)\
**Post date:** [September 14, 2021, 9:31am UTC](https://forums.rockylinux.org/t/replicate-mbr-disk-with-random-uuids/4057/1 "2021-09-14T09:31:05Z")

</div>

Hi,

First a little bit of context. Let’s say I have a server with several identical hard disks, and I want to setup a software RAID array. In that case I partition the first disk, and then I replicate my partitioning scheme. Here’s what this would look like with two disks with a GPT partitioning scheme:

```auto
# sgdisk /dev/sda --replicate /dev/sdb
# sgdisk --randomize-guids /dev/sdb
# gdisk -l /dev/sdb

```

Now how would I do that with an MBR-based partitioning ? Here’s how I can clone my disk:

```auto
# sfdisk --dump /dev/sda | sfdisk /dev/sdb
# fdisk -l /dev/sdb

```

Unfortunately my second disk will have the exact same UUIDs as the first one. And the `sfdisk` command doesn’t seem to have an equivalent option for `--randomize-guids` like `sgdisk`.

Any suggestions ?

---

<div class="post-metadata">

**Author:** ![iwalker](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/iwalker/32/2599_2.png) [@iwalker](https://forums.rockylinux.org/u/iwalker)\
**Post date:** [September 14, 2021, 9:55am UTC](https://forums.rockylinux.org/t/replicate-mbr-disk-with-random-uuids/4057/2 "2021-09-14T09:55:27Z")

</div>

You can do it like this:

```auto
/dev/vdb1: PARTUUID="88da3c19-01"
/dev/vdc1: PARTUUID="88da3c19-01"

```

I ran blkid so that you could see I did the sfdisk commands just like you.

```auto
[root@rocky ~]# fdisk -l /dev/vdc
Disk /dev/vdc: 20 GiB, 21474836480 bytes, 41943040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x88da3c19

Device Boot Start End Sectors Size Id Type
/dev/vdc1 2048 41943039 41940992 20G fd Linux raid autodetect

```

note the disk identifier `0x88da3c19`, and I will change this to `0x88da3c20`

```auto
[root@rocky ~]# fdisk /dev/vdc

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): x

Expert command (m for help): i

Enter the new disk identifier: 0x88da3c20

Disk identifier changed from 0x88da3c19 to 0x88da3c20.

Expert command (m for help): r

Command (m for help): w

The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

```

And with blkid:

```auto
[root@rocky ~]# blkid
/dev/vdb1: PARTUUID="88da3c19-01"
/dev/vdc1: PARTUUID="88da3c20-01"

```

then when you start creating the array:

```auto
mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/vdb1 /dev/vdc1

```

and now, blkid:

```auto
/dev/vdb1: UUID="debb8a3c-82ba-0da3-bcb5-925473ec1193" UUID_SUB="4bee41a8-5188-1f44-578f-52d4591cdd8f" LABEL="rocky:0" TYPE="linux_raid_member" PARTUUID="88da3c19-01"
/dev/vdc1: UUID="debb8a3c-82ba-0da3-bcb5-925473ec1193" UUID_SUB="c71fbc20-5722-3310-c7a8-2e15958b76e4" LABEL="rocky:0" TYPE="linux_raid_member" PARTUUID="88da3c20-01"

```

---

<div class="post-metadata">

**Author:** ![microlinux](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/microlinux/32/1244_2.png) [@microlinux](https://forums.rockylinux.org/u/microlinux)\
**Post date:** [September 14, 2021, 10:01am UTC](https://forums.rockylinux.org/t/replicate-mbr-disk-with-random-uuids/4057/3 "2021-09-14T10:01:40Z")

</div>

I think I just found a nifty little hack that’s dead simple. When cloning the disk partitioning scheme, I just leave out the UUID information:

```auto
# sfdisk --dump /dev/sda | grep -v ^label-id | sfdisk /dev/sdb
# fdisk -l /dev/sdb

```

I just gave it a spin, and it works like a charm.

---

<div class="post-metadata">

**Author:** ![iwalker](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/iwalker/32/2599_2.png) [@iwalker](https://forums.rockylinux.org/u/iwalker)\
**Post date:** [September 14, 2021, 10:17am UTC](https://forums.rockylinux.org/t/replicate-mbr-disk-with-random-uuids/4057/4 "2021-09-14T10:17:59Z")

</div>

Cool, nice workaround. To be honest, when I created arrays before, never even thought about the PARTUUID. Even today, I created the array straight after the sfdisk, and it worked just fine. Obviously the standard UUID for the partitions were different which was probably more important. Although these were commands I used years ago, like around 2007-2010 when I decided to convert my system from standard partitions to raid array without having to reinstall from scratch. This was even before I encountered UUID’s in fstab or even using blkid, so perhaps that was why I didn’t even take it into account up until now 🙂

---

<div class="post-metadata">

**Author:** ![microlinux](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/microlinux/32/1244_2.png) [@microlinux](https://forums.rockylinux.org/u/microlinux)\
**Post date:** [September 14, 2021, 10:29am UTC](https://forums.rockylinux.org/t/replicate-mbr-disk-with-random-uuids/4057/5 "2021-09-14T10:29:25Z")

</div>

Same here. I only looked at this stuff more closely because the Rocky Linux 8.4 installer loudly complained about identical UUIDs on my hard disks and then exited.

---

<div class="post-metadata">

**Author:** ![brian](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/brian/32/5777_2.png) [@brian](https://forums.rockylinux.org/u/brian)\
**Post date:** [August 25, 2023, 4:05am UTC](https://forums.rockylinux.org/t/replicate-mbr-disk-with-random-uuids/4057/6 "2023-08-25T04:05:26Z")

</div>


