首页 > 代码库 > OSX: 命令行制作U盘Recovery HD

OSX: 命令行制作U盘Recovery HD

使用命令行操作,非常easy,可是操作不当非常危急!

免责声明:假设操作不当造成的数据丢失,本人概不负责。


为什么?

不是有OSX恢复磁盘助理嘛?是的。假设仅仅想使用GUI的软件。能够去苹果官方站点:http://support.apple.com/kb/DL1433?viewlocale=zh_CN

唯一的原因就是:生命不息,折腾不止;只是还有另外一个诱因,就是看看究竟官方的恢复磁盘助理的原理,换句话说,用自己的办法达到相同的效果。


前提:你有一个工作的Recovery HD,你的Mac支持U盘启动。


1. 准备一个空白的不小于1GB的U盘。事实上650MB的就能够。

2. 执行命令,并记住各个參数:

diskutil list

我的机器是:

$ diskutil list

/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *160.0 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            159.7 GB   disk0s2
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 GB     disk1
   1:                  Apple_HFS A                       346.9 MB   disk1s1
   2:                 Apple_Boot Recovery HD             693.8 MB   disk1s2
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *120.0 GB   disk2
   1:                        EFI EFI                     209.7 MB   disk2s1
   2:                  Apple_HFS OSX94                   29.5 GB    disk2s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk2s3
   4:                  Apple_HFS Data                    58.0 GB    disk2s4
   5:                  Apple_HFS OSX10DP                 23.5 GB    disk2s5
   6:                 Apple_Boot Recovery HD             650.0 MB   disk2s6
   7:                  Apple_HFS _OSX10DPInstaller_      7.3 GB     disk2s7

我要操作的是disk1这个盘。源Recovery HD是disk2s6。它是OS X 10.10 DP3的恢复盘。

3. 创建U盘恢复分区

执行命令和显示:

$ sudo -s
$ diskutil partitionDisk disk1 1 GPT jhfs+ Recovery\ HD 100%

Started partitioning on disk1
Unmounting disk
Creating the partition map
Waiting for the disks to reappear
Formatting disk1s1 as Mac OS Extended (Journaled) with name Recovery HD
Initialized /dev/rdisk1s1 as a 992 MB case-insensitive HFS Plus volume with a 8192k journal
Mounting disk
Finished partitioning on disk1
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 GB     disk1
   1:                  Apple_HFS Recovery HD             1.0 GB     disk1s1

4. 制作:

$ diskutil unmountDisk disk1

Unmount of all volumes on disk1 was successful

$ gpt remove -b 40 disk1
disk1s1 removed

$ gpt add  -b 40 -t 426F6F74-0000-11AA-AA11-00306543ECAC disk1
disk1s1 added

$ gpt -r show disk1
    start     size  index  contents
        0        1         PMBR
        1        1         Pri GPT header
        2       32         Pri GPT table
       34        6         
       40  2032634      1  GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
  2032674       32         Sec GPT table
  2032706        1         Sec GPT header

$ dd if=/dev/dsik1s6 of=/dev/disk1s1

$ diskutil mount disk1s1
$ bless --folder /Volumes/Recovery HD/com.apple.recovery.boot

5. 验证:

$ diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *160.0 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            159.7 GB   disk0s2
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 GB     disk1
   1:                 Apple_Boot Recovery HD             1.0 GB     disk1s1
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *120.0 GB   disk2
   1:                        EFI EFI                     209.7 MB   disk2s1
   2:                  Apple_HFS OSX94                   29.5 GB    disk2s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk2s3
   4:                  Apple_HFS Data                    58.0 GB    disk2s4
   5:                  Apple_HFS OSX10DP                 23.5 GB    disk2s5
   6:                 Apple_Boot Recovery HD             650.0 MB   disk2s6
   7:                  Apple_HFS _OSX10DPInstaller_      7.3 GB     disk2s7

6. 測试:

技术分享





OSX: 命令行制作U盘Recovery HD