ZFS如何在OS X上与加密一起使用?


9

理想:

我将首先回答应该对发布和beta版本有用 ZEVO 在OS X 10.7.4上。它不符合上述理想,但它是值得深思的。

希望Mountain Lion和更高版本的OS X能够在这些领域提供更好的支持。

在以下任何一种情况下,可以添加或改进答案:

  • 发布OS X 10.8
  • 对ZEVO的改进
  • 对ZFS的改进( 加密ZFS 目前仅限于Oracle Solaris)。

Answers:


10

OS X 10.7.4用于加密的核心存储,用于ZFS的ZEVO

目标:一个物理磁盘,五个卷。五个非加密中的一个,一个用密码加密,三个用不同的密码加密。

初始点:

  • / dev / disk2 - 物理磁盘
  • / dev / disk2s2 - 要保留的JHFS +卷,不受保护
  • / dev / disk2s3 - 要销毁的片,可以通过加密和ZFS重用。

提示

以来 HFS +对所有元数据更新(通过I / O保持)具有单个全局锁定,它对磁盘延迟非常敏感 。因此,虽然在单个磁盘上混合使用ZFS和JHFS + 可能 ,对于大多数用例,文件系统混合是 推荐的。

此示例还使用了压缩和子文件系统。

命令摘要

diskutil coreStorage create pusscats /dev/disk2s3
diskutil coreStorage createVolume 370260EF-D772-4739-BAF6-F4CD6F49A60D jhfs+ Billski 50% -passphrase
diskutil coreStorage createVolume 370260EF-D772-4739-BAF6-F4CD6F49A60D jhfs+ Pickle 100% -passphrase
diskutil unmount disk3 && diskutil unmount disk4
sudo zpool create -O casesensitivity=insensitive -O normalization=formD Billski /dev/disk3
sudo zpool create -O casesensitivity=insensitive -O normalization=formD -O compression=on Pickle /dev/disk4
zfs create Pickle/button
zfs create Pickle/button/nose
sudo chown gjp22 /Volumes/Billski
sudo chown gjp22 /Volumes/Pickle
zpool export Billski && zpool export Pickle
diskutil unmount /Volumes/slice\ two

输出,在终端

sh-3.2$ diskutil list disk2
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *8.0 GB     disk2
   1:                        EFI                         209.7 MB   disk2s1
   2:                  Apple_HFS slice two               1.5 GB     disk2s2
   3:                  Apple_HFS slice three             6.0 GB     disk2s3
sh-3.2$ diskutil coreStorage create pusscats /dev/disk2s3
Started CoreStorage operation
Unmounting disk2s3
Touching partition type on disk2s3
Adding disk2s3 to Logical Volume Group
Creating Core Storage Logical Volume Group
Switching disk2s3 to Core Storage
Waiting for Logical Volume Group to appear
Discovered new Logical Volume Group "370260EF-D772-4739-BAF6-F4CD6F49A60D"
Core Storage LVG UUID: 370260EF-D772-4739-BAF6-F4CD6F49A60D
Finished CoreStorage operation
sh-3.2$ diskutil coreStorage createVolume 370260EF-D772-4739-BAF6-F4CD6F49A60D jhfs+ Billski 50% -passphrase
Passphrase for new volume:
Confirm new passphrase:
Started CoreStorage operation
Waiting for Logical Volume to appear
Formatting file system for Logical Volume
Initialized /dev/rdisk3 as a 3 GB HFS Plus volume with a 8192k journal
Mounting disk
Core Storage LV UUID: 22CF33F0-9EB1-424C-AFFA-FFA45A75A828
Core Storage disk: disk3
Finished CoreStorage operation
sh-3.2$ diskutil coreStorage createVolume 370260EF-D772-4739-BAF6-F4CD6F49A60D jhfs+ Pickle 100% -passphrase
Passphrase for new volume:
Confirm new passphrase:
Started CoreStorage operation
Waiting for Logical Volume to appear
Formatting file system for Logical Volume
Initialized /dev/rdisk4 as a 3 GB HFS Plus volume with a 8192k journal
Mounting disk
Core Storage LV UUID: 500E7D8F-27A3-4704-BF9F-5AE5D6BB6982
Core Storage disk: disk4
Finished CoreStorage operation
sh-3.2$ diskutil unmount disk3 && diskutil unmount disk4
Volume Billski on disk3 unmounted
Volume Pickle on disk4 unmounted
sh-3.2$ sudo zpool create -O casesensitivity=insensitive -O normalization=formD Billski /dev/disk3
Password:
sh-3.2$ sudo zpool create -O casesensitivity=insensitive -O normalization=formD -O compression=on Pickle /dev/disk4
sh-3.2$ zfs create Pickle/button
cannot mount '/Volumes/Pickle/button': failed to create mountpoint
filesystem successfully created, but not mounted
sh-3.2$ zfs create Pickle/button/nose
cannot mount '/Volumes/Pickle/button/nose': failed to create mountpoint
filesystem successfully created, but not mounted
sh-3.2$ sudo chown gjp22 /Volumes/Billski
sh-3.2$ sudo chown gjp22 /Volumes/Pickle
sh-3.2$ zpool export Billski && zpool export Pickle
sh-3.2$ diskutil unmount /Volumes/slice\ two
Volume slice two on disk2s2 unmounted
sh-3.2$ clear

此时,卸载所有物理磁盘卷后,您可以断开磁盘连接。重新连接应该允许使用子文件系统:

sh-3.2$ zfs list
NAME                  USED   AVAIL   REFER  MOUNTPOINT
Billski             1.04Mi  2.37Gi   684Ki  /Volumes/Billski
Pickle              1.87Mi  2.37Gi   472Ki  /Volumes/Pickle
Pickle/button        808Ki  2.37Gi   412Ki  /Volumes/Pickle/button
Pickle/button/nose   396Ki  2.37Gi   396Ki  /Volumes/Pickle/button/nose
sh-3.2$ clear





sh-3.2$ mount | grep /dev/
/dev/disk1 on / (hfs, local, journaled)
/dev/disk0s2 on /Volumes/11E53 (hfs, local, journaled)
/dev/disk2s2 on /Volumes/slice two (hfs, local, nodev, nosuid, journaled, noowners)
/dev/disk4 on /Volumes/Billski (zfs, local, journaled)
/dev/disk6 on /Volumes/Pickle (zfs, local, journaled)
/dev/disk6s1 on /Volumes/Pickle/button (zfs, local, journaled)
/dev/disk6s1s1 on /Volumes/Pickle/button/nose (zfs, local, journaled)
sh-3.2$ clear





sh-3.2$ ls -l /Volumes
total 40
drwxr-xr-x@ 32 root   wheel  1156  3 Jun 09:08 11E53
lrwxr-xr-x   1 root   admin     1  4 Jun 15:17 11E53-2012-06-03 -> /
drwxr-xr-x   5 root   wheel     5  4 Jun 22:27 Billski
drwxr-xr-x   6 root   wheel     6  4 Jun 22:33 Pickle
drwxrwxr-x   7 gjp22  staff   306  4 Jun 21:41 slice two
sh-3.2$ clear





sh-3.2$ diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *160.0 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:                  Apple_HFS 11E53                   25.0 GB    disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
   4:          Apple_CoreStorage                         25.0 GB    disk0s4
   5:                 Apple_Boot Recovery HD             650.0 MB   disk0s5
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                  Apple_HFS 11E53-2012-06-03       *24.7 GB    disk1
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *8.0 GB     disk2
   1:                        EFI                         209.7 MB   disk2s1
   2:                  Apple_HFS slice two               1.5 GB     disk2s2
   3:          Apple_CoreStorage                         6.0 GB     disk2s3
   4:                 Apple_Boot Boot OS X               134.2 MB   disk2s4
/dev/disk3
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *2.9 GB     disk3
   1:                        EFI                         209.7 MB   disk3s1
   2:                        ZFS                         2.6 GB     disk3s2
/dev/disk4
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:             zfs_pool_proxy Billski                *2.6 GB     disk4
/dev/disk5
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *2.9 GB     disk5
   1:                        EFI                         209.7 MB   disk5s1
   2:                        ZFS                         2.6 GB     disk5s2
/dev/disk6
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:             zfs_pool_proxy Pickle                 *2.6 GB     disk6
   1:       zfs_filesystem_proxy button                  2.5 GB     disk6s1
   2:       zfs_filesystem_proxy nose                    2.5 GB     disk6s1s1
sh-3.2$ clear





sh-3.2$ diskutil coreStorage list
CoreStorage logical volume groups (2 found)
|
+-- Logical Volume Group ED97CA61-2077-45CE-9CBB-8AA0A7600CB5
|   =========================================================
|   Name:         b
|   Sequence:     1
|   Free Space:   0 B (0 B)
|   |
|   +-< Physical Volume 5C79B2B6-CE01-4F02-9222-2AD898791AC5
|   |   ----------------------------------------------------
|   |   Index:    0
|   |   Disk:     disk0s4
|   |   Status:   Online
|   |   Size:     24999997440 B (25.0 GB)
|   |
|   +-> Logical Volume Family 7A9C5B98-287F-4F6B-9F9C-9641EFBC16E1
|       ----------------------------------------------------------
|       Sequence:               11
|       Encryption Status:      Unlocked
|       Encryption Type:        AES-XTS
|       Encryption Context:     Present
|       Conversion Status:      Complete
|       Has Encrypted Extents:  Yes
|       Conversion Direction:   -none-
|       |
|       +-> Logical Volume 3A130C9E-63AE-4F00-A1C3-E750B1570381
|           ---------------------------------------------------
|           Disk:               disk1
|           Status:             Online
|           Sequence:           5
|           Size (Total):       24681226240 B (24.7 GB)
|           Size (Converted):   -none-
|           Revertible:         Yes (unlock and decryption required)
|           LV Name:            11E53-2012-06-03
|           Volume Name:        11E53-2012-06-03
|           Content Hint:       Apple_HFS
|
+-- Logical Volume Group 370260EF-D772-4739-BAF6-F4CD6F49A60D
    =========================================================
    Name:         pusscats
    Sequence:     1
    Free Space:   0 B (0 B)
    |
    +-< Physical Volume F64F6909-25BF-4638-8647-CD058D60968B
    |   ----------------------------------------------------
    |   Index:    0
    |   Disk:     disk2s3
    |   Status:   Online
    |   Size:     6020829184 B (6.0 GB)
    |
    +-> Logical Volume Family 4D42970B-FAB7-4EFE-B120-2057A9A7A7E5
    |   ----------------------------------------------------------
    |   Sequence:               2
    |   Encryption Status:      Unlocked
    |   Encryption Type:        AES-XTS
    |   Encryption Context:     Present
    |   Conversion Status:      NoConversion
    |   Has Encrypted Extents:  Yes
    |   Conversion Direction:   -none-
    |   |
    |   +-> Logical Volume 22CF33F0-9EB1-424C-AFFA-FFA45A75A828
    |       ---------------------------------------------------
    |       Disk:               disk3
    |       Status:             Online
    |       Sequence:           2
    |       Size (Total):       2934915072 B (2.9 GB)
    |       Size (Converted):   -none-
    |       Revertible:         No
    |       LV Name:            Billski
    |       Content Hint:       Apple_HFS
    |
    +-> Logical Volume Family 3A009EF4-4B3D-4BC8-8B47-EFE88B2BA12A
        ----------------------------------------------------------
        Sequence:               2
        Encryption Status:      Unlocked
        Encryption Type:        AES-XTS
        Encryption Context:     Present
        Conversion Status:      NoConversion
        Has Encrypted Extents:  Yes
        Conversion Direction:   -none-
        |
        +-> Logical Volume 500E7D8F-27A3-4704-BF9F-5AE5D6BB6982
            ---------------------------------------------------
            Disk:               disk5
            Status:             Online
            Sequence:           2
            Size (Total):       2934910976 B (2.9 GB)
            Size (Converted):   -none-
            Revertible:         No
            LV Name:            Pickle
            Content Hint:       Apple_HFS
sh-3.2$ clear





sh-3.2$ zpool status
  pool: Billski
 state: ONLINE
 scan: none requested
config:

    NAME                                         STATE     READ WRITE CKSUM
    Billski                                      ONLINE       0     0     0
      GPTE_7CBD336C-568A-41AE-8E61-291CBD8EF783  ONLINE       0     0     0  at disk3s2

errors: No known data errors

  pool: Pickle
 state: ONLINE
 scan: none requested
config:

    NAME                                         STATE     READ WRITE CKSUM
    Pickle                                       ONLINE       0     0     0
      GPTE_25BF8159-FB8D-4589-B52A-184F6675176E  ONLINE       0     0     0  at disk5s2

errors: No known data errors
sh-3.2$ 

最终结果,在Finder中

A ZFS hierarchy in Finder

Finder recognition of multiple volumes, at eject time

已知的问题

在CoreStorage世界中的内容提示 Apple_HFS 将不是真的 ZFS 最终结果。我已经要求Apple允许更合适的提示。

在解锁时,系统可能似乎拒绝密码短语(可能是因为内容提示不匹配)。出现拒绝时:

  1. 等待
  2. 解锁的卷(和任何子文件系统)应该挂载
  3. 逃离密码对话。

如果您愿意,可以使用Keychain Access将钥匙串添加到Core Storage逻辑卷的UUID的密码短语中。

山狮不再支持 diskutil eraseDisk 在Core Storage逻辑卷上放置分区映射 -

gpes3e-gjp4:~ gjp22$ diskutil list /dev/disk4 && diskutil list /dev/disk5
/dev/disk4
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *8.0 GB     disk4
   1:                        EFI                         209.7 MB   disk4s1
   2:          Apple_CoreStorage test                    7.7 GB     disk4s2
   3:                 Apple_Boot Boot OS X               134.2 MB   disk4s3
/dev/disk5
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                  Apple_HFS test                   *7.3 GB     disk5
gpes3e-gjp4:~ gjp22$ diskutil unmount /dev/disk5
Volume test on disk5 unmounted
gpes3e-gjp4:~ gjp22$ sudo zpool create -O casesensitivity=insensitive -O normalization=formD Billski /dev/disk5

Unable to begin erase operation: Placing a partition map on a Core Storage logical volume is not supported (-69671)
diskutil eraseDisk failed, exit status 1
gpes3e-gjp4:~ gjp22$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.8.5
BuildVersion:   12F37
gpes3e-gjp4:~ gjp22$ 

- 感谢mgrosman 警报

维修

考虑到Apple的Core Storage设计主要用于内容提示 Apple_HFS和错误 fsck_cs

  • 我不知道'强迫'是否有其他类型( ZFSzfs_pool_proxyzfs_filesystem_proxy 等等)可能会削弱人的能力 fsck_cs 在遇到困难时进行修理。

谨慎行事。


格雷厄姆 - 你坚强地保持一个伟大的FS存活并让人们知道你仍然可以使用它,你真是太神奇了。显然不是为了胆小的人,但这确实非常酷。
bmike

@GrahamPerrin你能看一下吗? apple.stackexchange.com/questions/89049/...
GJ.

也许是互补的,虽然我不急于更新上面的答案: FileVault 2加密磁盘,我的主目录位于不同的驱动器上 (2011-09-23)
Graham Perrin
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.