9

I have a server with two disks of the same size:

/dev/sdb1      1922728752 1613465788 211570908  89% /export/home
/dev/sdc1      1922728752  831068620 993968076  46% /store

During reboot first of them changed its LABEL and UUID to the LABEL and UUID of the second one, which resulted in damaged data:

/dev/sdb1: LABEL="store" UUID="9a353d19-b638-4fed-9aa1-9525dd891da4" TYPE="ext4" PARTUUID="00054182-01"
/dev/sdc1: LABEL="store" UUID="9a353d19-b638-4fed-9aa1-9525dd891da4" TYPE="ext4" PARTUUID="00054182-01"

I tried to change the LABEL and UUID of the first disk:

/dev/sdb1: LABEL="home" UUID="688e53c2-8749-43ae-9823-7e8bc290a9b6" TYPE="ext4" PARTUUID="00054182-01"

and ran the fsck, but after next reboot it was renamed back to store with the wrong UUID and the data got corrupted again. I then noticed that also PARTUUIDs of the two disks are identical, but I didn't find a way how to change PARTUUID.

The data doesn't get corrupted, if the disk is not mounted during boot. When I mount it later manually (even with wrong LABEL, UUID and PARTUUID) the data remains intact.

I have several questions:

  1. What could cause this error? I suspect some HW failure. A short circuit on the disk cable? I didn't look inside, but I guess that the two disks are connected by one data cable.
  2. Is there a way to change PARTUUID? I wonder whether this could solve the problem.
mook765
  • 18,644
Hana
  • 121

1 Answers1

21

For disks with GPT partition table:

You can change the PARTUUID of a partition with gdisk. I'd recommend to read man gdisk first. In the following example I show how I changed the PARTUUID of the second partition on my first drive (sda):

$ sudo gdisk /dev/sda
[sudo] password for mook: 
GPT fdisk (gdisk) version 1.0.5

Partition table scan: MBR: protective BSD: not present APM: not present GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): x # enter x to change to experts menu

Expert command (? for help): c # enter c to change PARTUUID Partition number (1-2): 2 # enter the number of the partition you want to change Enter the partition's new unique GUID ('R' to randomize): r New GUID is 76349364-D66C-4C19-B422-237A0D2DB9F5

Expert command (? for help): m # enter m to go back to main menu

Command (? for help): w # enter w to write the change to disk

Command (? for help): q # enter q to exit gdisk $


For disks with msdos partition table:

For disks with msdos-partition-table blkid produces a PARTUUID based on the Disk Signature(Disk identifier) and the partition number (Source).

Different disks must always have different identifiers. See the files in /dev/disk/by-partuuid which are links to the devices (e.g. /dev/sda1). Both of your disks /dev/sdb and /dev/sdc have the same identifier which leads to the same PARTUUID for two different partitions. This would theoretically result in two links with the same name but different targets in /dev/disk/by-partuuid which is not possible at all. Probably this is the reason for your problems and you should definitely change one of the disk identifiers.

Here an example how we can change the disk signature using fdisk:

First check the disk identifier with fdisk -l:

~$ sudo fdisk -l /dev/sdc
[sudo] password for mook: 
Disk /dev/sdc: 7.25 GiB, 7776239616 bytes, 15187968 sectors
Disk model: USB FLASH DRIVE 
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: 0x60123f75

Device Boot Start End Sectors Size Id Type /dev/sdc1 2048 15187967 15185920 7.2G 83 Linux

Now change the disk identifier with fdisk:

~$ sudo fdisk /dev/sdc
[sudo] password for mook:

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

Command (m for help): x # enter x to go to expert menu

Expert command (m for help): i # enter i to change identifier

Enter the new disk identifier: 0x60123f76

Disk identifier changed from 0x60123f75 to 0x60123f76.

Expert command (m for help): r # enter r to return to main menu

Command (m for help): w # enter w to write change to MBR

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

Now recheck with fdisk -l:

$ sudo fdisk -l /dev/sdc
Disk /dev/sdc: 7.25 GiB, 7776239616 bytes, 15187968 sectors
Disk model: USB FLASH DRIVE 
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: 0x60123f76

Device Boot Start End Sectors Size Id Type /dev/sdc1 2048 15187967 15185920 7.2G 83 Linux

mook765
  • 18,644