映像整个源分区。这个分区非常小
通常没有安装。只需将分区复制到文件即可。
Steelhead:recover davidanderson$ sudo dd if=/dev/disk1s3 of=recovery.binary bs=40960
21220+1 records in
21220+1 records out
869175296 bytes transferred in 44.563133 secs (19504358 bytes/sec)
Steelhead:recover davidanderson$ ls -l
total 1697608
-rw-r--r-- 1 root staff 869175296 Jul 20 11:53 recovery.binary
为新的恢复分区腾出空间。
Steelhead:recover davidanderson$ diskutil resizevolume /dev/disk2s2 limits
For device disk2s2 MacintoshHD:
Current size: 50.9 GB (50856046592 Bytes)
Minimum size: 5.5 GB (5524418560 Bytes)
Maximum size: 50.9 GB (50856046592 Bytes)
Steelhead:recover davidanderson$ diskutil resizevolume /dev/disk2s2 45G
Started partitioning on disk2s2 MacintoshHD
Verifying the disk
Verifying file system
Checking Journaled HFS Plus volume
Checking extents overflow file
Checking catalog file
Checking multi-linked files
Checking catalog hierarchy
Checking extended attributes file
Checking volume bitmap
Checking volume information
The volume MacintoshHD appears to be OK
File system check exit code is 0
Resizing
Finished partitioning on disk2s2 MacintoshHD
/dev/disk2
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *51.2 GB disk2
1: EFI EFI 209.7 MB disk2s1
2: Apple_HFS MacintoshHD 45.0 GB disk2s2
在上创建新的恢复分区 /dev/disk2
。 新的
分区必须与现有的Recover完全相同
划分。
Steelhead:recover davidanderson$ sudo gdisk /dev/disk2
Password:
GPT fdisk (gdisk) version 1.0.1
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): n
Partition number (3-128, default 3):
First sector (34-100000006, default = 88300264) or {+-}size{KMGTP}:
Last sector (88300264-100000006, default = 100000006) or {+-}size{KMGTP}: +1697608
Current type is 'Apple HFS/HFS+'
Hex code or GUID (L to show codes, Enter = AF00): AB00
Changed type of partition to 'Recovery HD'
Command (? for help): x
Expert command (? for help): a
Partition number (1-3): 3
Known attributes are:
0: system partition
1: hide from EFI
2: legacy BIOS bootable
60: read-only
62: hidden
63: do not automount
Attribute value is 0000000000000000. Set fields are:
No fields set
Toggle which attribute field (0-63, 64 or <Enter> to exit): 49
Have enabled the 'Undefined bit #49' attribute.
Attribute value is 0002000000000000. Set fields are:
49 (Undefined bit #49)
Toggle which attribute field (0-63, 64 or <Enter> to exit):
Expert 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/disk2.
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.
Steelhead:recover davidanderson$ sudo gpt -r show /dev/disk2
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 87890624 2 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
88300264 1697608 3 GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
89997872 10002135
100000007 32 Sec GPT table
100000039 1 Sec GPT header
弹出并重新连接 /dev/disk2
。如果你不能这样做的话
重启Mac。
Steelhead:recover davidanderson$ diskutil eject /dev/disk2
Disk /dev/disk2 ejected
将保存的图像复制到新的恢复分区。因为这是一个
精确复制,使用 hfs.util
命令生成新的UUID密钥
对于HFS文件系统。
当使用El Capitan(OS X 10.11)时,完整的路径 hfs.util
命令是 System/Library/Filesystems/hfs.fs/Contents/Resources/hfs.util
。
Steelhead:recover davidanderson$ sudo dd if=recovery.binary of=/dev/disk2s3 bs=40960
Password:
21220+1 records in
21220+1 records out
869175296 bytes transferred in 52.127608 secs (16673992 bytes/sec)
Steelhead:recover davidanderson$ /System/Library/Filesystems/hfs.fs/hfs.util -k disk2s3; echo
78A8438E-2299-3AF0-AD9E-3AC225B0554A
Steelhead:recover davidanderson$ /System/Library/Filesystems/hfs.fs/hfs.util -s disk2s3
Steelhead:recover davidanderson$ /System/Library/Filesystems/hfs.fs/hfs.util -k disk2s3; echo
0F4F5893-D9E1-3512-9B2B-2AEA0DE9FDE3
弹出并重新连接 /dev/disk2
。如果你不能这样做的话
重启Mac。
Steelhead:recover davidanderson$ diskutil eject /dev/disk2
Disk /dev/disk2 ejected
尝试恢复任何剩余的可用空间。
下面是第一次尝试。该 diskutil resizevolume /dev/disk2s2 R
命令失败。
另请注意 diskutil resizevolume /dev/disk2s2 limits
命令
报告错误的最大尺寸。
Steelhead:recover davidanderson$ diskutil resizevolume /dev/disk2s2 R
Started partitioning on disk2s2 MacintoshHD
Verifying the disk
Verifying file system
Checking Journaled HFS Plus volume
Checking extents overflow file
Checking catalog file
Checking multi-linked files
Checking catalog hierarchy
Checking extended attributes file
Checking volume bitmap
Checking volume information
The volume MacintoshHD appears to be OK
File system check exit code is 0
Resizing
Error: -69742: The requested size change for the target disk or a related disk is too small;
please try a different disk or partition, or make a larger change
Steelhead:recover davidanderson$ diskutil resizevolume /dev/disk2s2 limits
For device disk2s2 MacintoshHD:
Current size: 45.0 GB (44999999488 Bytes)
Minimum size: 5.5 GB (5524459520 Bytes)
Maximum size: 45.0 GB (44999999488 Bytes)
再试一次,但这次计算分区的大小 /dev/disk2s2
应该。
Steelhead:recover davidanderson$ sudo gpt -r show /dev/disk2
Password:
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 87890624 2 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
88300264 1697608 3 GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
89997872 10002135
100000007 32 Sec GPT table
100000039 1 Sec GPT header
Steelhead:recover davidanderson$ expr 10002135 \* 512 / 100000000 + 450
501
Steelhead:recover davidanderson$ diskutil resizevolume /dev/disk2s2 50.1G
Started partitioning on disk2s2 MacintoshHD
Verifying the disk
Verifying file system
Checking Journaled HFS Plus volume
Checking extents overflow file
Checking catalog file
Checking multi-linked files
Checking catalog hierarchy
Checking extended attributes file
Checking volume bitmap
Checking volume information
The volume MacintoshHD appears to be OK
File system check exit code is 0
Resizing
Waiting for the disks to reappear
Finished partitioning on disk2s2 MacintoshHD
/dev/disk2
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *51.2 GB disk2
1: EFI EFI 209.7 MB disk2s1
2: Apple_HFS MacintoshHD 50.1 GB disk2s2
3: Apple_Boot recovery 869.2 MB disk2s3
Steelhead:recover davidanderson$ sudo gpt -r show /dev/disk2
Password:
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 97851560 2 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
98261200 1697608 3 GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
99958808 41199
100000007 32 Sec GPT table
100000039 1 Sec GPT header
这次尝试成功了。在实践中,你永远无法恢复所有的免费
空间。请注意新的Recovery分区 /dev/disk2s3
是
自动重新定位。