У меня есть сервер с двумя дисками одинакового размера:
/dev/sdb1 1922728752 1613465788 211570908 89% /export/home
/dev/sdc1 1922728752 831068620 993968076 46% /store
Во время перезагрузки первый из них изменил свои LABEL и UUID на LABEL и UUID второго, что привело к повреждению данных:
/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"
Я попытался изменить LABEL и UUID первого диска:
/dev/sdb1: LABEL="home" UUID="688e53c2-8749-43ae-9823-7e8bc290a9b6" TYPE="ext4" PARTUUID="00054182-01"
и запустил fsck, но после следующей перезагрузки он был снова переименован в store
с неправильным UUID, и данные снова были повреждены. Затем я заметил, что PARTUUID двух дисков идентичны, но я не нашел способа изменить PARTUUID.
Данные не повреждаются, если диск не примонтирован во время загрузки. Когда я позже монтирую его вручную (даже с неправильным LABEL, UUID и PARTUUID), данные остаются нетронутыми.
У меня несколько вопросов:
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 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 have the same identifier and only one partition and on both disks it's the first partition, 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 definetely 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