OSX: 使用命令列對FileVault2分區恢複

來源:互聯網
上載者:User

FileVault 2必須有Recovery HD分區,因為它依賴於它作為系統初啟動。如果今後什麼時候或者誤操作刪除了Recovery HD分區,那麼你的機器就無法啟動鳥。 是否使用蘋果的辦法重新獲得一個Recovery HD就可以了呢?原理上說不行,因為還記得當初加密的時候的密鑰嗎?它也丟了,丟了就無法解密了。所以呢,我們需要另闢途徑來恢複它。

一般步驟:

基於一個FileVault 2是基於CoreStorage邏輯卷管理技術的事實,我們可以從CoreStorage入手。

先看看一個被加密過的磁碟回變成什麼樣子,注意其中的Unlocked行,後面會提到:

$ diskutil coreStorage listCoreStorage logical volume groups (1 found)|+-- Logical Volume Group 26B67367-CF79-4D1E-884C-BB96FDD79D19    =========================================================    Name:         FileVault    Sequence:     1    Free Space:   0 B (0 B)    |    +-< Physical Volume A446F211-3BCB-47F4-8EB2-7174AF4CD408     |   ----------------------------------------------------     |   Index:    0     |   Disk:     disk4s2     |   Status:   Online     |   Size:     9896046592 B (9.9 GB)     |     +-> Logical Volume Family 8D077574-ADC1-4979-9F1E-FF901FC20D86        ----------------------------------------------------------        Sequence:               8        Encryption Status:      Unlocked        Encryption Type:        AES-XTS        Encryption Context:     Present        Conversion Status:      Complete        Has Encrypted Extents:  Yes        Conversion Direction:   -none-        |        +-> Logical Volume BD95F022-812D-366A-909C-286E5443D88E            ---------------------------------------------------            Disk:               disk5            Status:             Online            Sequence:           4            Size (Total):       125505781760 B (125.5 GB)            Size (Converted):   125505781760 B (125.5 GB)            Revertible:         Yes (unlock and decryption required)            LV Name:            FileVault            Volume Name:        FileVault            Content Hint:       Apple_HFS

它原來看上去是這個樣子的:

diskutil info disk0s2   Device Identifier:        disk0s2   Device Node:              /dev/disk0s2   Part of Whole:            disk0   Device / Media Name:      Macintosh HD   Volume Name:              Macintosh HD   Escaped with Unicode:     Macintosh%FF%FE%20%00HD   Mounted:                  Yes   Mount Point:              /   Escaped with Unicode:     /   File System Personality:  Journaled HFS+   Type (Bundle):            hfs   Name (User Visible):      Mac OS Extended (Journaled)   Journal:                  Journal size 16384 KB at offset 0x1ab63000   Owners:                   Enabled   Partition Type:           Apple_HFS   OS Can Be Installed:      Yes   Media Type:               Generic   Protocol:                 SATA   SMART Status:             Verified   Volume UUID:              BD95F022-812D-366A-909C-286E5443D88E   Total Size:               125.5 GB (125505781760 Bytes) (exactly 245128480 512-Byte-Blocks)   Volume Free Space:        62.2 GB (62152081408 Bytes) (exactly 121390784 512-Byte-Blocks)   Device Block Size:        512 Bytes   Read-Only Media:          No   Read-Only Volume:         No   Ejectable:                No   Whole:                    No   Internal:                 Yes   Solid State:              No


其它的都不重要,重要的是他的Volume UUID,也就是 "BD95F022-812D-366A-909C-286E5443D88E",

另外加密時的密鑰也不要忘了,密鑰這個樣子:


現在使用下面的命令來解密吧:

$ diskutil coreStorage revert BD95F022-812D-366A-909C-286E5443D88E -passphrase 2NTO-LQGA-RMXG-LFQO-B8NR-XTCT

解密之後的時這樣子的:

$ diskutil coreStorage listNo CoreStorage logical volume groups found


鎖住的卷
注意:在10.8.4之後,每個加密的FV2磁碟都會是鎖住的(Locked), 在list命令中可以看到:

Encryption Status:      Locked

這樣在解密前需要先解鎖:

$ diskutil coreStorage unlockVolume BD95F022-812D-366A-909C-286E5443D88E -passphrase 2NTO-LQGA-RMXG-LFQO-B8NR-XTCT

FileVaultMaster.keychain檔案?

如果加密時使用的是FileVaultMaster.keychain,那麼只能使用它來解密,

首先,找到並在記憶體中開啟它:

security unlock-keychain /path/to/FileVaultMaster.keychain

之後使用"-recoveryKeychain /path/to/FileVaultMaster.keychain" 替換上面的 "-passphrase 2NTO-LQGA-RMXG-LFQO-B8NR-XTCT"


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.