我有一个服务器,它有两个大小相同的磁盘:
/dev/sdb1 1922728752 1613465788 211570908 89% /export/home
/dev/sdc1 1922728752 831068620 993968076 46% /store
在重新启动期间,首先它们将其标签和UUID更改为第二个标签和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"
我试图更改第一个磁盘的标签和UUID:
/dev/sdb1: LABEL="home" UUID="688e53c2-8749-43ae-9823-7e8bc290a9b6" TYPE="ext4" PARTUUID="00054182-01"
并运行fsck,但是在下一次重新引导之后,它被重命名为store
,并带有错误的UUID,数据再次损坏。然后,我注意到两个磁盘的PARTUUID也是相同的,但我没有找到如何更改PARTUUID的方法。
如果磁盘在引导期间没有挂载,则数据不会损坏。当我稍后手动挂载它(即使使用错误的标签、UUID和PARTUUID)时,数据仍然保持完整。
我有几个问题:
发布于 2020-06-14 13:02:07
具有GPT分区表的磁盘的
可以用gdisk
更改分区的PARTUUID。我建议先读man gdisk
。在下面的示例中,我展示了如何在第一个驱动器(Sda)上更改第二个分区的PARTUUID:
$ 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
$
具有msdos分区表的磁盘的
对于具有msdos分区表的磁盘,blkid
根据Disk Signature
(磁盘标识符)和分区号(来源)生成PARTUUID。
不同的磁盘必须始终具有不同的标识符。请参阅/dev/disk/by-partuuid
中的文件,这些文件是设备的链接(例如,/dev/sda1
)。您的两个磁盘都有相同的标识符,并且只有一个分区,而在两个磁盘上都是第一个分区,理论上这将导致在/dev/disk/by-partuuid
中有两个名称相同但目标不同的链接,这是根本不可能的。这可能是您出现问题的原因,您应该明确地更改磁盘标识符之一。
下面是一个如何使用fdisk
更改磁盘签名的示例:
首先用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
现在用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.
现在,请重新检查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
https://askubuntu.com/questions/1250224
复制相似问题