ZFS on Boot

From OpenZFS on OS X
Revision as of 00:59, 18 June 2016 by Lundman (Talk | contribs)

Jump to: navigation, search

ZFS as Boot

Status: Not Ready


Disk Layout

Play disk: disk1


Created the following partition on the test boot disk:

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          411647   200.0 MiB   EF00  EFI System
   2          411648         2508799   1024.0 MiB  AF00  Apple HFS/HFS+
   3         2508800         3737599   600.0 MiB   AB00  Recovery HD
   4         3737600        83886046   38.2 GiB    BF01  Solaris /usr & Mac ZFS
s1 is not really used, but added for EFI.
s2 is the small HFS boot, which will carry the kernel (and the kext caches) to load the kernel with ZFS. This then imports and mounts the ZFS slice.
s3 is currently not used, but created in case we want it in future
s4 is the ZFS pool used for booting.

Setting up boot slice s2

Regular HFS filesystem, and populated thusly; (Volume named boot here) In this case, we have both the kernel and kernel.development. But normal users will only have kernel. These are rsynced from the (normal) booted OS.

# diskutil mount disk1s2
# mdutil -i off /Volumes/boot
# cd /Volumes boot
./usr/standalone/i386/boot.efi
./System/Library/Kernels/kernel
./System/Library/Kernels/kernel.development
./System/Library/PrelinkedKernels/prelinkedkernel
./System/Library/PrelinkedKernels/prelinkedkernel.development
./System/Library/Caches/com.apple.kext.caches/Startup/IOKitPersonalities_x86_64.ioplist.gz
./System/Library/Caches/com.apple.kext.caches/Startup/kernelcache
./System/Library/Caches/com.apple.kext.caches/Startup/kernelcache.development
./System/Library/Caches/com.apple.kext.caches/Startup/KextPropertyValues_OSBundleHelper_x86_64.plist.gz
./System/Library/Caches/com.apple.kext.caches/Startup/KextPropertyValues_PGO_x86_64.plist.gz
./System/Library/CoreServices/boot.efi
./System/Library/CoreServices/SystemVersion.plist
# cat SystemVersion.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
       <key>ProductBuildVersion</key>
       <string>15F34</string>
       <key>ProductCopyright</key>
       <string>1983-2016 Apple Inc.</string>
       <key>ProductName</key>
       <string>Mac OS X</string>
       <key>ProductUserVisibleVersion</key>
       <string>10.11.5</string>
       <key>ProductVersion</key>
       <string>10.11.5</string>
</dict>
</plist>

Now we install the ZFS kexts and rebuild the kernel caches

# mkdir -p /Volumes/boo/Library/Extensions
# cd your-source-directory-for-zfs
# cd spl/module/spl
# make install DESTDIR=/Volumes/boot/
# cd ../../../zfs/module/zfs
# make install DESTDIR=/Volumes/boot/

Technically, that will also install some extra stuff which isn't needed into the boot slice but that fine.

Generate caches for kernel

kextcache -arch x86_64 -local-root -all-loaded -kernel /Volumes/boot/System/Library/Kernels/kernel -prelinked-kernel /Volumes/boot/System/Library/PrelinkedKernels/prelinkedkernel -mkext /Volumes/boot/System/Library/Caches/com.apple.kext.caches/Startup/kernelcache -volume-root / /System/Library/Extensions /Library/Extensions /Volumes/boot/Library/Extensions/

And if needed, caches for kernel.development

kextcache -arch x86_64 -local-root -all-loaded -kernel /Volumes/boot/System/Library/Kernels/kernel.development -prelinked-kernel /Volumes/boot/System/Library/PrelinkedKernels/prelinkedkernel.development -mkext /Volumes/boot/System/Library/Caches/com.apple.kext.caches/Startup/kernelcache.development -volume-root / /System/Library/Extensions /Library/Extensions /Volumes/boot/Library/Extensions/

Here there will be steps for blessing the boot, and setting up EFI etc. But we will use EFI Shell to boot for now.


Populating the ZFS Boot