VMWare - 将磁盘添加到现有磁盘后,GPT PMBR -GPT PMBR 大小不匹配将通过 w(rite) 进行纠正

VMWare - 将磁盘添加到现有磁盘后,GPT PMBR -GPT PMBR 大小不匹配将通过 w(rite) 进行纠正

我们已向 VMware fusion VM 添加了一个新磁盘。以下是 fdisk -l 输出:

Disk /dev/loop1: 91.4 MiB, 95805440 bytes, 187120 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


Disk /dev/loop2: 93.8 MiB, 98336768 bytes, 192064 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


GPT PMBR size mismatch (41943039 != 104857599) will be corrected by w(rite).
Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 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: gpt
Disk identifier: FE4C7C3C-6CA1-4416-B62E-5E6A50867C2A

Device     Start      End  Sectors Size Type
/dev/sda1   2048     4095     2048   1M BIOS boot
/dev/sda2   4096 41940991 41936896  20G Linux filesystem


biot@biot:~$ sudo parted -l
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 53.7GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name  Flags
 1      1049kB  2097kB  1049kB                     bios_grub
 2      2097kB  21.5GB  21.5GB  ext4


Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0
has been opened read-only.
Model: NECVMWar VMware SATA CD01 (scsi)                                   
Disk /dev/sr0: 875MB
Sector size (logical/physical): 2048B/2048B
Partition Table: mac
Disk Flags: 

Number  Start  End    Size    File system  Name   Flags
 1      2048B  6143B  4096B                Apple
 2      659MB  662MB  2523kB               EFI


biot@biot:~$ 


biot@biot:~$ sudo parted /dev/sda unit s print
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 104857600s
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start  End        Size       File system  Name  Flags
 1      2048s  4095s      2048s                         bios_grub
 2      4096s  41940991s  41936896s  ext4

biot@biot:~$ sudo gdisk -l /dev/sda
GPT fdisk (gdisk) version 1.0.3

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

Found valid GPT with protective MBR; using GPT.
Disk /dev/sda: 104857600 sectors, 50.0 GiB
Model: VMware Virtual S
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): FE4C7C3C-6CA1-4416-B62E-5E6A50867C2A
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 104857566
Partitions will be aligned on 2048-sector boundaries
Total free space is 62918589 sectors (30.0 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048            4095   1024.0 KiB  EF02  
   2            4096        41940991   20.0 GiB    8300  

我们如何才能在不丢失现有数据的情况下解决这个问题?提前谢谢 BR

答案1

在其上运行fdisk并用于w保存现有的分区表而不进行任何更改。

所有 GPT 磁盘都有一个“保护性 MBR”,其中包含一个覆盖整个磁盘(或尽可能多的磁盘)的虚拟分区。如果您扩大磁盘,此分区仍将指示旧磁盘大小,直到 fdisk 对其进行调整。

这对磁盘上存储的数据没有影响;它只是为了防范旧的仅限 MBR 的磁盘分区工具。

答案2

我们已经完成了。但是 /dev/sda2 挂载点是 20G(和以前一样)而不是 50G。我们该怎么办?

biot@biot:~$ sudo fdisk /dev/sda

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

GPT PMBR size mismatch (41943039 != 104857599) will be corrected by w(rite).
GPT PMBR size mismatch (41943039 != 104857599) will be corrected by w(rite).

Command (m for help): w
GPT PMBR size mismatch (41943039 != 104857599) will be corrected by w(rite).

The partition table has been altered.
Syncing disks.

biot@biot:~$ sudo fdisk -l
Disk /dev/loop0: 93.8 MiB, 98336768 bytes, 192064 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


Disk /dev/loop1: 91.4 MiB, 95805440 bytes, 187120 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


Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 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: gpt
Disk identifier: FE4C7C3C-6CA1-4416-B62E-5E6A50867C2A

Device     Start      End  Sectors Size Type
/dev/sda1   2048     4095     2048   1M BIOS boot
/dev/sda2   4096 41940991 41936896  20G Linux filesystem
biot@biot:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            955M     0  955M   0% /dev
tmpfs           198M  1.4M  196M   1% /run
/dev/sda2        20G   11G  8.0G  58% /
tmpfs           986M     0  986M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           986M     0  986M   0% /sys/fs/cgroup
/dev/loop0       94M   94M     0 100% /snap/core/8935
/dev/loop1       92M   92M     0 100% /snap/core/8689
tmpfs           198M     0  198M   0% /run/user/1000

答案3

您需要通过 fdisk 重新创建 sda2 分区。因此,首先删除它,然后重新创建它,这样它将覆盖您通过 VMWare 添加的整个可用空间。请记住,您无法更改起始扇区,否则您将丢失数据(默认情况下,fdisk 应覆盖起始扇区和结束扇区)。然后,当然您需要调整 fs 的大小。

相关内容