Han*_*ana 8 partitioning boot mount
我有一台具有两个相同大小的磁盘的服务器:
/dev/sdb1 1922728752 1613465788 211570908 89% /export/home
/dev/sdc1 1922728752 831068620 993968076 46% /store
Run Code Online (Sandbox Code Playgroud)
在重新启动期间,第一个将其 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"
Run Code Online (Sandbox Code Playgroud)
我尝试更改第一个磁盘的 LABEL 和 UUID:
/dev/sdb1: LABEL="home" UUID="688e53c2-8749-43ae-9823-7e8bc290a9b6" TYPE="ext4" PARTUUID="00054182-01"
Run Code Online (Sandbox Code Playgroud)
并运行 fsck,但在下次重新启动后,它被重命名回store
错误的 UUID,并且数据再次损坏。然后我注意到两个磁盘的 PARTUUID 也是相同的,但我没有找到如何更改 PARTUUID 的方法。
如果在引导期间未安装磁盘,则数据不会损坏。当我稍后手动安装它时(即使使用错误的 LABEL、UUID 和 PARTUUID),数据仍然完好无损。
我有几个问题:
moo*_*765 15
您可以使用 更改分区的 PARTUUID gdisk
。我建议先阅读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
$
Run Code Online (Sandbox Code Playgroud)
对于具有 msdos-partition-table 的磁盘,blkid
根据Disk Signature
(磁盘标识符)和分区号(源)生成 PARTUUID。
不同的磁盘必须始终具有不同的标识符。/dev/disk/by-partuuid
查看其中包含设备链接的文件(例如/dev/sda1
)。您的两个磁盘/dev/sdb
都/dev/sdc
具有相同的标识符,这导致两个不同的分区具有相同的 PARTUUID。理论上,这会导致两个具有相同名称但目标不同的链接,这/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
Run Code Online (Sandbox Code Playgroud)
现在使用以下命令更改磁盘标识符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.
Run Code Online (Sandbox Code Playgroud)
现在重新检查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
Run Code Online (Sandbox Code Playgroud)