APFS High Sierra会话期间也可能发生此问题!在使用“磁盘工具”应用程序和diskutil
命令进行更改后,我昨天遇到了这个问题:
sh-3.2# diskutil list
/dev/disk0 (internal, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *500.3 GB disk0
1: EFI EFI 209.7 MB disk0s1
2: FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF 60.0 GB disk0s2
/dev/disk1 (synthesized):
#: TYPE NAME SIZE IDENTIFIER
0: APFS Container Scheme - +60.0 GB disk1
Physical Store disk0s2
1: APFS Volume APPLESSD 47.1 GB disk1s1
2: APFS Volume Preboot 19.4 MB disk1s2
3: APFS Volume Recovery 517.8 MB disk1s3
4: APFS Volume VM 1.1 GB disk1s4
sh-3.2# gpt -r show /dev/disk0
start size index contents
0 1 PMBR
1 1 Pri GPT header
2 32 Pri GPT table
34 6
40 409600 1 GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
409640 117111080 2 GPT part - FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF
117520720 859584307
977105027 32 Sec GPT table
977105059 1 Sec GPT header
我不认为它将在该配置下重新启动(或使用GPT备份表重新启动?不知道)。感谢上面的解释,我可以在实时会话中解决该问题,但是我不得不使用稍微不同的解决方案(该解决方案仅在禁用SIP的情况下才有效,如果启用,则必须重新引导,禁用和使用以前的解决方案。 ,此问题可能与禁用的SIP有关,因此不会在启用的SIP上发生(我不知道。)
即使disk0
卸载,似乎gpt
也不允许在实时会话中修改GPT:
sh-3.2# gpt remove -i 2 disk0
gpt remove: unable to open device 'disk0': Resource busy
因此,我改为使用第三方工具gdisk
(通过自制程序获得)来修改的类型disk0s2
:
sh-3.2# gdisk /dev/disk0
GPT fdisk (gdisk) version 1.0.3
Warning: Devices opened with shared lock will not have their
partition table automatically reloaded!
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Command (? for help): i
Partition number (1-2): 2
Partition GUID code: FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF (Unknown)
Partition unique GUID: B40FA371-D92C-4EBF-B846-B0A9FB6DCD71
First sector: 409640 (at 200.0 MiB)
Last sector: 117520719 (at 56.0 GiB)
Partition size: 117111080 sectors (55.8 GiB)
Attribute flags: 0000000000000000
Partition name: 'Apple_HFS_Untitled_2'
Command (? for help): t
Partition number (1-2): 2
Current type is 'Unknown'
Hex code or GUID (L to show codes, Enter = af00): 7C3457EF-0000-11AA-AA11-00306543ECAC
Changed type of partition to 'Unknown'
Command (? for help): i
Partition number (1-2): 2
Partition GUID code: 7C3457EF-0000-11AA-AA11-00306543ECAC (Unknown)
Partition unique GUID: B40FA371-D92C-4EBF-B846-B0A9FB6DCD71
First sector: 409640 (at 200.0 MiB)
Last sector: 117520719 (at 56.0 GiB)
Partition size: 117111080 sectors (55.8 GiB)
Attribute flags: 0000000000000000
Partition name: 'Apple_HFS_Untitled_2'
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/disk0.
Warning: Devices opened with shared lock will not have their
partition table automatically reloaded!
Warning: The kernel may continue to use old or deleted partitions.
You should reboot or remove the drive.
The operation has completed successfully.
检查出来:
sh-3.2# gpt -r show /dev/disk0
start size index contents
0 1 PMBR
1 1 Pri GPT header
2 32 Pri GPT table
34 6
40 409600 1 GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
409640 117111080 2 GPT part - 7C3457EF-0000-11AA-AA11-00306543ECAC
117520720 859584307
977105027 32 Sec GPT table
977105059 1 Sec GPT header
sh-3.2# diskutil list
/dev/disk0 (internal, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *500.3 GB disk0
1: EFI EFI 209.7 MB disk0s1
2: Apple_APFS Container disk1 60.0 GB disk0s2
/dev/disk1 (synthesized):
#: TYPE NAME SIZE IDENTIFIER
0: APFS Container Scheme - +60.0 GB disk1
Physical Store disk0s2
1: APFS Volume APPLESSD 47.1 GB disk1s1
2: APFS Volume Preboot 19.4 MB disk1s2
3: APFS Volume Recovery 517.8 MB disk1s3
4: APFS Volume VM 1.1 GB disk1s4
然后,最后检查有diskutil verifyDisk disk0
和diskutil verifyVolume disk0s2
没有警告或错误。重新启动成功。