Editing ZFS on Boot

Jump to: navigation, search

Warning: You are not logged in.

Your IP address will be recorded in this page's edit history.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 2: Line 2:
 
== ZFS as Boot ==
 
== ZFS as Boot ==
  
   Status: Beta
+
   Status: Not Ready
 +
 
 
   Most of the commands listed below must be run as root or with '''sudo'''.
 
   Most of the commands listed below must be run as root or with '''sudo'''.
 
=== SIP ===
 
before running the bless command you may have to disable System Integrity Protection [SIP]:
 
boot into recovery mode by holding '''Cmd+R''', open Utilities > Terminal and run
 
    csrutil disable
 
then reboot; to re-enable SIP boot into recovery mode by holding '''Cmd+R''', open Utilities > Terminal and run
 
    csrutil enable
 
 
 
'''Updated for macOS Catalina '''
 
 
This guide assumes you have installed the latest Open ZFS on OS X on the system, both
 
to create and populate the '''rpool''' with data, but that the data copied will have the
 
kexts and prelinked kernels containing OpenZFS kexts.
 
 
=== Install OpenZFS ===
 
 
Download latest OpenZFSonOsX pkg and install.
 
 
=== Partitioning disk ===
 
 
You need generally a 200MB EFI partition, your ZFS partition, then finally a 200MB Apple boot partition.
 
 
''In this example, $NEWDISK is the blank disk to use; set it now''
 
 
(Change /dev/disk1 to your blank disk!)
 
# export NEWDISK=/dev/disk1           
 
# echo $NEWDISK
 
/dev/disk1
 
 
Default '''diskutil''' partitions appear to work:
 
 
# diskutil partitionDisk $NEWDISK GPT ZFS rpool 0b
 
(You can ignore this error: )
 
Could not mount disk1s2 after erase
 
Error: -69832: File system formatter failed
 
 
/dev/disk1 (internal, physical):
 
  #:                      TYPE NAME                    SIZE      IDENTIFIER
 
  0:      GUID_partition_scheme                        *64.4 GB    disk1
 
  1:                        EFI EFI                    209.7 MB  disk1s1
 
  2: FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF              64.1 GB    disk1s2
 
  3:                Apple_Boot Boot OS X              134.2 MB  disk1s3
 
 
=== Setting up ZFS slice 2 ===
 
 
Create the actual pool:
 
 
# sudo zpool create -f -o ashift=12 -O casesensitivity=insensitive \
 
  -O normalization=formD -O atime=off -O compression=zstd \
 
  -O mountpoint=none -O canmount=off rpool ${NEWDISK}s2
 
 
Create minimal datasets for ROOT
 
 
# zfs create -o mountpoint=none -o canmount=off rpool/ROOT
 
# zfs create -o mountpoint=legacy -o com.apple.mimic=hfs rpool/ROOT/Catalina
 
# zpool set bootfs=rpool/ROOT/Catalina rpool
 
 
Optional, create further datasets, perhaps for /Users, and/or, individual users...
 
# sudo zfs create -o mountpoint=/Users -o canmount=off rpool/HOME
 
# sudo zfs create rpool/HOME/username
 
 
Populate the rpool from the running system:
 
 
# mkdir /Volumes/ZFSBoot
 
# /Library/Filesystems/zfs.fs/Contents/Resources/mount_zfs rpool/ROOT/Catalina /Volumes/ZFSBoot
 
# rsync -axH --progress --exclude=".Spotlight-V100" --exclude=".fseventsd" --exclude=".vol" / /Volumes/ZFSBoot/
 
 
.. and wait.
 
 
(It would be neat if we could (ab)use the installer for the OS: ie some version of
 
installer -pkg [path to]/Install macOS Catalina.app/Contents/SharedSupport/InstallInfo.plist -target /Volumes/ZFSBoot -verbose -dumplog
 
but possibly it always insists on partitioning.)
 
 
Update the Boot.plist:
 
 
# vim /Volumes/ZFSBoot/Library/Preferences/SystemConfiguration/com.apple.Boot.plist
 
 
<dict>
 
        <key>Kernel Flags</key>
 
        <string>-v keepsyms=y zfs_boot=rpool</string>
 
        <key>Root UUID</key>
 
        <string>5A465320-626F-6F74-2064-657669636500</string>
 
</dict>
 
 
(The uuid doesnt seem to matter, it just needs to be formatted valid, you can copy the one in the docs, it has nothing to do with your devices.)
 
 
=== Setting up boot slice 3 ===
 
 
These steps require slice 2 copy to have finished.
 
 
# newfs_hfs -J -v "boot" ${NEWDISK}s3
 
# diskutil mount ${NEWDISK}s3
 
# mkdir -p /Volumes/boot/System/Library/CoreServices
 
# mkdir -p /Volumes/boot/com.apple.boot.R/System/Library/PrelinkedKernels
 
# mkdir -p /Volumes/boot/com.apple.boot.R/Library/Preferences/SystemConfiguration
 
# mkdir -p /Volumes/boot/com.apple.boot.R/usr/standalone/i386
 
 
Populate boot:
 
 
# rsync -a /Volumes/ZFSBoot/System/Library/CoreServices/PlatformSupport.plist \
 
/Volumes/boot/System/Library/CoreServices/PlatformSupport.plist
 
# rsync -a /Volumes/ZFSBoot/System/Library/CoreServices/SystemVersion.plist \
 
/Volumes/boot/System/Library/CoreServices/SystemVersion.plist
 
# rsync -a /Volumes/ZFSBoot/System/Library/PrelinkedKernels/prelinkedkernel \
 
/Volumes/boot/com.apple.boot.R/System/Library/PrelinkedKernels/prelinkedkernel
 
# rsync -a /Volumes/ZFSBoot/Library/Preferences/SystemConfiguration/com.apple.Boot.plist \
 
/Volumes/boot/com.apple.boot.R/Library/Preferences/SystemConfiguration/com.apple.Boot.plist
 
# rsync -a /Volumes/ZFSBoot/usr/standalone/i386/ \
 
/Volumes/boot/com.apple.boot.R/usr/standalone/i386/
 
 
Bless the volume:
 
 
# sudo bless --folder /Volumes/boot/System/Library/CoreServices \
 
  --file /Volumes/boot/System/Library/CoreServices/boot.efi \
 
  --bootefi /Volumes/ZFSBoot/System/Library/CoreServices/boot.efi \
 
  --label "ZFS Boot"
 
 
This step does not change the current boot device, unless you add ''--setBoot''. See blessing the boot device to change the startup device.
 
Another useful argument is ''--nextonly'' to just affect one boot, which is great for testing.
 
To get out of trouble, remember that you can
 
hold `Alt` during boot to select disk to boot from.
 
 
 
=== Booting ZFS ===
 
 
Finally, tell your Mac to use the boot helper on boot. You may want to try the ''--nextonly'' option to avoid permanent changes.
 
 
# sudo bless --device ${NEWDISK}s3 --setBoot
 
 
( if you get an error like '''Could not set boot device property: 0xe00002bc''' you should disable SIP, see [[#SIP|SIP]] for instructions)
 
 
# reboot
 
 
( you can re-enable SIP now, see [[#SIP|SIP]] for instructions)
 
 
Additional tricks. If updating the kexts, and you want to update the boot volume as well:
 
 
Mount and update ZFSBoot
 
# mkdir /Volumes/ZFSBoot
 
# /Library/Filesystems/zfs.fs/Contents/Resources/mount_zfs rpool/ROOT/Catalina /Volumes/ZFSBoot
 
 
If you prefer to update the kexts in /Volumes/ZFSBoot/Library/Extensions/
 
# kextcache -c "/Volumes/ZFSBoot/System/Library/PrelinkedKernels/prelinkedkernel" -K "/Volumes/ZFSBoot/System/Library/Kernels/kernel" -l -- "/Volumes/ZFSBoot/System/Library/Extensions"  "/Volumes/ZFSBoot/Library/Extensions/"
 
 
Or if you install new kexts on machine, and then update /Volumes/ZFSBoot/
 
# rsync -ar /Library/Extensions/ /Volumes/ZFSBoot/Library/Extensions/
 
# kextcache -c "/Volumes/ZFSBoot/System/Library/PrelinkedKernels/prelinkedkernel" -K "/System/Library/Kernels/kernel" -l -- "/System/Library/Extensions"  "/Library/Extensions/"
 
 
Also update the tiny boot volume - find the disk it is on, in example, disk1s3. Pick kernel either on "/" or "/Volumes/ZFSBoot/"
 
# diskutil mount disk1s3
 
# mkdir -p /Volumes/boot/com.apple.boot.R/System/Library/Caches/com.apple.kext.caches/Startup
 
# kextcache -c "/Volumes/boot/com.apple.boot.R/System/Library/PrelinkedKernels/prelinkedkernel" -K "/System/Library/Kernels/kernel" -l -- "/System/Library/Extensions" "/Library/Extensions/"
 
 
----
 
 
''' The remaining text is the old guide. '''
 
 
----
 
 
Because you have to compile your own KEXTs, they will not be signed. [https://support.apple.com/en-us/HT204899 System Integrity Protection] (SIP) needs to be disabled for unsigned KEXTs to work.
 
A future version of OpenZFSOnOSX will come with --enable-boot compiled KEXTs and be signed.
 
  
 
=== Disk Layout ===
 
=== Disk Layout ===
Line 180: Line 19:
 
   3        82200576        83886046  823.0 MiB  AB00  Apple boot
 
   3        82200576        83886046  823.0 MiB  AB00  Apple boot
  
* '''s1''' is the system EFI partition, which is used for software updates. You can also add rEFInd boot loader here if desired (optional).
+
'''s1''' is not really used, but added for EFI.
* '''s2''' is the ZFS pool used for booting. Note: You are not limited to using the name '''rpool'''.
+
 
* '''s3''' is the small HFS boot helper which will carry the prelinkedkernel to load the kernel with ZFS.
+
'''s2''' is the ZFS pool used for booting. Note: You are not limited to using the name '''rpool'''.
 +
 
 +
'''s3''' is the small HFS boot which will carry the prelinkedkernel to load the kernel with ZFS.
  
 
The layout need not be exactly this, but:
 
The layout need not be exactly this, but:
  
* The EFI partition (type ef00) should always exist at the beginning of the disk. It is usually 200 MB.
+
The EFI partition should always exist at the beginning of the disk.
* The Apple Boot (type ab00) partition should directly follow the ZFS partition. It should be at least 128 MB but may be as large as you want.
+
 
 +
The Apple Boot (ab00) partition should directly follow the ZFS partition, and while it can be as small as 50 MB, it is better to use 650MB or more (to imitate a Recovery HD).
 +
 
 +
  Note: at this time, the boot helper partition is not updated by the OS
 +
  and must be manually updated. It may be possible to script this in a
 +
  launchd service, or even 'bless' the device so that macOS updates
 +
  it automatically. Additional development is ongoing.
 +
 
 +
  You cannot use '''Startup Disk''' to select the boot disk, see [[#Blessing the boot device|blessing the boot device]].
  
 
=== Populating the ZFS Root '''s2''' ===
 
=== Populating the ZFS Root '''s2''' ===
Line 195: Line 44:
 
Additional research is needed on atime, casesensitivity, and normalization (and probably more).
 
Additional research is needed on atime, casesensitivity, and normalization (and probably more).
 
  # sudo zpool create -f -o ashift=12 -O casesensitivity=insensitive \
 
  # sudo zpool create -f -o ashift=12 -O casesensitivity=insensitive \
   -O normalization=formD -O atime=off -O compression=zstd \
+
   -O normalization=formD -O atime=off -O compression=lz4 \
 
   -O mountpoint=none -O canmount=off rpool disk1s2
 
   -O mountpoint=none -O canmount=off rpool disk1s2
 +
 +
This step will relabel the disks using InvariantDisks paths (by UUID), so they can be located at boot time.
 +
# sudo zpool export rpool
 +
# sudo zpool import -d /var/run/disk/by-id rpool
 +
 +
  Using /dev/disk paths will most likely break!
  
 
==== Root dataset ====
 
==== Root dataset ====
 +
  Note: com.apple.mimic_hfs is known to '''NOT''' be compatible at this time. (It will panic!)
  
 
Create '''ROOT''' and lower just like IllumOS so that you can easy swap OS snapshots and reboot into something else (for example to run softwareupdate).
 
Create '''ROOT''' and lower just like IllumOS so that you can easy swap OS snapshots and reboot into something else (for example to run softwareupdate).
Line 204: Line 60:
 
  # sudo zfs create -o mountpoint=legacy rpool/ROOT/Capitan
 
  # sudo zfs create -o mountpoint=legacy rpool/ROOT/Capitan
 
  # sudo zpool set bootfs=rpool/ROOT/Capitan rpool
 
  # sudo zpool set bootfs=rpool/ROOT/Capitan rpool
 
Note: com.apple.mimic=hfs may be set on the root mountpoint. Testing is still underway for ZFS Root both with or without mimic set.
 
  
 
You probably want to relocate your home folder outside of the root dataset, for example rpool/HOME/username, or on ZVOL for compatibility.
 
You probably want to relocate your home folder outside of the root dataset, for example rpool/HOME/username, or on ZVOL for compatibility.
Line 217: Line 71:
 
==== Install macOS ====
 
==== Install macOS ====
 
Copy over the OS as you see fit, rsync will generally do. (Remember that etc, tmp and var are symlinks into /private)
 
Copy over the OS as you see fit, rsync will generally do. (Remember that etc, tmp and var are symlinks into /private)
  # sudo rsync -axH --exclude=".Spotlight-V100" --exclude=".fseventsd" \
+
  # rsync -axH --exclude=".Spotlight-V100" --exclude=".fseventsd" \
 
   --exclude=".vol" / /Volumes/Capitan/
 
   --exclude=".vol" / /Volumes/Capitan/
  
 
==== Install ZFS ====
 
==== Install ZFS ====
  
Boot support is now included with the binary install versions, so you don't have to compile it yourself.
+
  = Note: Missing branches =
 
+
In you haven't done so already, install homebrew (or macports, but in the example we will stick to homebrew as it's quicker to set-up):
+
# /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
+
 
+
Install automake and libtool (required to compile spl and zfs):
+
# brew install automake libtool
+
  
Create target directory for installation:
 
 
  # sudo mkdir -p /Volumes/Capitan/usr/local
 
  # sudo mkdir -p /Volumes/Capitan/usr/local
 
+
# cd /Volumes/Capitan/usr/local
Use your own repository:
+
# sudo ln -s ../../sbin sbin
 +
 
  # cd $your-zfs-source-area
 
  # cd $your-zfs-source-area
Or clone it one from github:
 
# git clone https://github.com/openzfsonosx/spl.git
 
# git clone https://github.com/openzfsonosx/zfs.git
 
 
Build and install spl:
 
 
  # cd spl
 
  # cd spl
 
  # git fetch --all
 
  # git fetch --all
  # ./autogen.sh
+
# git checkout spl-boot
 +
  # ./autogen
 
  # ./configure --enable-boot
 
  # ./configure --enable-boot
 
  # make
 
  # make
 
  # sudo make install DESTDIR=/Volumes/Capitan
 
  # sudo make install DESTDIR=/Volumes/Capitan
 
Build and install zfs:
 
 
 
  # cd ../zfs
 
  # cd ../zfs
 
  # git fetch --all
 
  # git fetch --all
  # ./autogen.sh
+
# git checkout ldi-boot
  # ./configure --enable-boot  
+
  # ./autogen
 +
  # ./configure --enable-boot --with-spl=../spl
 
  # make
 
  # make
 
  # sudo make install DESTDIR=/Volumes/Capitan
 
  # sudo make install DESTDIR=/Volumes/Capitan
  
==== Edit Boot.plist ====
+
Or use a stage directory for zfs builds
 
+
# make install DESTDIR=/stage_dir
You should set Kernel Flags and Root UUID in the root volume (not the boot helper) as it will be copied to the boot helper automatically. It is located at /Library/Preferences/SystemConfiguration/com.apple.Boot.plist
+
  # rsync -acH /stage_dir/ /Volumes/Capitan/
 
+
More examples of the Boot.plist can be found at [[Boot.plist|com.apple.Boot.plist]]
+
 
+
  # sudo vim /Volumes/Capitan/Library/Preferences/SystemConfiguration/com.apple.Boot.plist
+
 
+
Two keys must be set: '''Kernel Flags''' and '''Root UUID''':
+
 
+
Look for
+
  <key>Kernel Flags</key>
+
  <string></string>
+
 
+
Replace with:
+
  <key>Kernel Flags</key>
+
  <string>-v keepsyms=y zfs_boot=rpool</string>
+
  <key>Root UUID</key>
+
  <string>00000000-0000-0000-0000-000000000000</string>
+
 
+
Any UUID may be used here, I used 5A465320-626F-6F74-2064-657669636500, (which is literally the string "ZFS boot device\0").
+
 
+
See [[Boot.plist]] for more examples.
+
 
+
[[ZVOL boot]] from HFS+ can be accomplished by using the UUID of the partition containing a standard Mac OS install, for compatibility.
+
  
 
=== Setting up boot slice '''s3''' ===
 
=== Setting up boot slice '''s3''' ===
Line 306: Line 126:
 
   /Volumes/boot/com.apple.boot.R/System/Library/PrelinkedKernels/prelinkedkernel
 
   /Volumes/boot/com.apple.boot.R/System/Library/PrelinkedKernels/prelinkedkernel
 
  # sudo rsync -a /Volumes/Capitan/Library/Preferences/SystemConfiguration/com.apple.Boot.plist \
 
  # sudo rsync -a /Volumes/Capitan/Library/Preferences/SystemConfiguration/com.apple.Boot.plist \
   /Volumes/boot/com.apple.boot.R/Library/Preferences/SystemConfiguration/com.apple.Boot.plist
+
   /Volumes/boot/com.apple.boot.R/Library/Preferences/com.apple.Boot.plist
 
  # sudo rsync -a /Volumes/Capitan/usr/standalone/i386/ \
 
  # sudo rsync -a /Volumes/Capitan/usr/standalone/i386/ \
 
   /Volumes/boot/com.apple.boot.R/usr/standalone/i386/
 
   /Volumes/boot/com.apple.boot.R/usr/standalone/i386/
Line 315: Line 135:
 
You may use any label in place of '''ZFS Boot''' here, it will appear at the option-boot screen.
 
You may use any label in place of '''ZFS Boot''' here, it will appear at the option-boot screen.
 
  # sudo bless --folder /Volumes/boot/System/Library/CoreServices \
 
  # sudo bless --folder /Volumes/boot/System/Library/CoreServices \
   --file /Volumes/boot/System/Library/CoreServices/boot.efi \
+
   --file /Volumes/boot/System/Library/CoreServices \
 
   --bootefi /Volumes/Capitan/System/Library/CoreServices/boot.efi \
 
   --bootefi /Volumes/Capitan/System/Library/CoreServices/boot.efi \
 
   --label "ZFS Boot"
 
   --label "ZFS Boot"
Line 321: Line 141:
 
This step does not change the current boot device, unless you add --setBoot. See [[#Blessing the boot device|blessing the boot device]] to change the startup device.
 
This step does not change the current boot device, unless you add --setBoot. See [[#Blessing the boot device|blessing the boot device]] to change the startup device.
  
==== Generate prelinkedkernel ====
+
==== Edit Boot.plist ====
Generate caches for '''kernel'''
+
  
# sudo kextcache -arch x86_64 -local-root -volume-root /Volumes/Capitan \
+
More examples of the Boot.plist can be found at [[Boot.plist|com.apple.Boot.plist]]
  -kernel /Volumes/Capitan/System/Library/Kernels/kernel \
+
  -prelinked-kernel /Volumes/Capitan/System/Library/PrelinkedKernels/prelinkedkernel \
+
  -- /Volumes/Capitan/System/Library/Extensions /Volumes/Capitan/Library/Extensions /Volumes/boot/Library/Extensions
+
  
If you get a symlink error here like;
+
  # sudo vim /Volumes/boot/com.apple.boot.R/Library/Preferences/SystemConfiguration/com.apple.Boot.plist
  symlink("/Volumes/Capitan/System/Library/PrelinkedKernels/prelinkedkernel", "/Volumes/Capitan/System/Library/Caches/com.apple.kext.caches/Startup/kernelcache") failed 17 (File exists) <createPrelinkedKernel 2795>
+
  
Just delete the symlink, and run again, ie;
+
Two changes are needed:
rm /Volumes/Capitan/System/Library/Caches/com.apple.kext.caches/Startup/kernelcache
+
  
 +
Look for
 +
  <key>Kernel Flags</key>
 +
  <string></string>
  
For developers who also have '''development''', or '''debug''' kernels, do the same for each one. For example, caches for '''kernel.development'''
+
Replace with:
 +
  <key>Kernel Flags</key>
 +
  <string>-v keepsyms=y zfs_boot=rpool</string>
 +
  <key>Root UUID</key>
 +
  <string>00000000-0000-0000-0000-000000000000</string>
  
# kextcache -arch x86_64 -local-root -volume-root /Volumes/Capitan \
+
Any UUID may be used here, I used 5A465320-626F-6F74-2064-657669636500, (which is literally the string "ZFS boot device\0").
  -kernel /Volumes/Capitan/System/Library/Kernels/kernel.development \
+
  -prelinked-kernel /Volumes/Capitan/System/Library/PrelinkedKernels/prelinkedkernel.development \
+
  -- /Volumes/Capitan/System/Library/Extensions /Volumes/boot/Library/Extensions
+
  
==== Copy prelinkedkernel to boot helper ====
+
See [[Boot.plist]] for more examples.
  
  # sudo rsync -a /Volumes/Capitan/System/Library/PrelinkedKernels/prelinkedkernel \
+
[[ZVOL boot]] from HFS+ can be accomplished by using the UUID of the partition containing a standard Mac OS install, for compatibility.
   /Volumes/boot/com.apple.boot.R/System/Library/PrelinkedKernels/prelinkedkernel
+
 
 +
==== Generate prelinkedkernel ====
 +
Generate caches for '''kernel'''
 +
 
 +
  # kextcache -arch x86_64 -local-root -volume-root /Volumes/rpool \
 +
  -kernel /Volumes/rpool/System/Library/Kernels/kernel \
 +
  -prelinked-kernel /Volumes/rpool/System/Library/PrelinkedKernels/prelinkedkernel \
 +
   -- /Volumes/rpool/System/Library/Extensions /Volumes/boot/Library/Extensions
 +
 
 +
And if needed, caches for '''kernel.development'''
 +
 
 +
# kextcache -arch x86_64 -local-root -volume-root /Volumes/rpool \
 +
  -kernel /Volumes/rpool/System/Library/Kernels/kernel.development \
 +
  -prelinked-kernel /Volumes/rpool/System/Library/PrelinkedKernels/prelinkedkernel.development \
 +
  -- /Volumes/rpool/System/Library/Extensions /Volumes/boot/Library/Extensions
  
 
==== Set the boot device ====
 
==== Set the boot device ====
Finally, tell your Mac to use the boot helper on boot. You may want to try the '''--nextonly''' option to avoid permanent changes.
+
Finally, tell your Mac to use the boot helper on boot. You may want to try the '''--nextonly’’’ option to avoid permanent changes.
  # sudo bless --device /dev/disk1s3 --setBoot
+
  # sudo bless --device disk1s3 --setBoot
  
 
=== Booting ===
 
=== Booting ===
 
==== Booting on ESX ====
 
==== Booting on ESX ====
  
This is only required if you prefer not to bless the device. If you bless it, it will boot automatically. However, if you skip the blessing part you can easily chose which HDD to boot
+
Booting on ESX, I hit F2 to get the EFI menu up. One of the options is the "EFI Shell (not supported)". Once the EFI shell has been entered
by using the EFI Boot Shell.
+
 
+
Booting on ESX, hit F2 to get the EFI menu up. One of the options is the "EFI Shell (not supported)". Once the EFI shell has been entered
+
  
 
  # map
 
  # map
Line 382: Line 211:
  
 
Which runs (boots) boot.efi, which then locates and loads the prelinkedkernel.
 
Which runs (boots) boot.efi, which then locates and loads the prelinkedkernel.
You can specify boot options here too:
 
 
fs4: boot.efi zfs_boot=rpool -s -v
 
 
To ask it to boot from pool '''rpool''' (using bootfs= property) into single-user mode, with verbose output.
 
 
  
 
==== Booting on VirtualBox ====
 
==== Booting on VirtualBox ====
Line 395: Line 218:
 
It is possible to write a startup.nsh script to do so.
 
It is possible to write a startup.nsh script to do so.
  
[Please provide details on how to disable SIP in startup.nsh]
+
VirtualBox does not like the boot helper as created above. It used to function in a previous version (4.3.x?) but at this time, the easiest option I have found is to clone the contents of BaseSystem.dmg from any MacOS recovery partition.
 
+
VirtualBox does not like the boot helper as created above. There are two options to get a bootable setup:
+
 
+
===== Minimal boot partition for VirtualBox (tested with macOS Sierra) =====
+
# sudo mkdir -p /Volumes/boot//Library/Preferences/SystemConfiguration
+
# sudo mkdir -p /Volumes/boot/System/Library/CoreServices/com.apple.recovery.boot
+
# sudo rsync -a /Volumes/Capitan/Library/Preferences/SystemConfiguration/autodiskmount.plist /Volumes/boot/Library/Preferences/SystemConfiguration/autodiskmount.plist
+
# sudo rsync -a /Volumes/Capitan/Library/Preferences/SystemConfiguration/com.apple.Boot.plist /Volumes/boot/Library/Preferences/SystemConfiguration/com.apple.Boot.plist
+
# sudo rsync -a /Volumes/Capitan/System/Library/CoreServices/PlatformSupport.plist /Volumes/boot/System/Library/CoreServices/PlatformSupport.plist
+
# sudo rsync -a /Volumes/Capitan/System/Library/CoreServices/SystemVersion.plist /Volumes/boot/System/Library/CoreServices/SystemVersion.plist
+
# sudo rsync -a /Volumes/Capitan/System/Library/CoreServices/boot.efi /Volumes/boot/System/Library/CoreServices/boot.efi
+
# sudo rsync -a /Volumes/Capitan/System/Library/CoreServices/bootbase.efi /Volumes/boot/System/Library/CoreServices/bootbase.efi
+
# sudo rsync -a /Volumes/Capitan/System/Library/CoreServices/com.apple.recovery.boot/PlatformSupport.plist /Volumes/boot/System/Library/CoreServices/com.apple.recovery.boot/PlatformSupport.plist
+
# sudo rsync -a /Volumes/Capitan/System/Library/PrelinkedKernels/prelinkedkernel /Volumes/boot/System/Library/PrelinkedKernels/prelinkedkernel
+
 
+
===== Alternative solution using recovery boot base system image =====
+
 
  # diskutil mount disk0s3
 
  # diskutil mount disk0s3
 
  # hdiutil attach -readonly "/Volumes/Recovery HD/com.apple.recovery.boot/BaseSystem.dmg"
 
  # hdiutil attach -readonly "/Volumes/Recovery HD/com.apple.recovery.boot/BaseSystem.dmg"
  
 
Then
 
Then
  # sudo rsync -axH "/Volumes/OS X Base System/" "/Volumes/boot/"
+
  # sudo rsync -axH /Volumes/OS\ X\ Recovery/ /Volumes/boot/
 
Or if you prefer '''asr''':
 
Or if you prefer '''asr''':
  # sudo asr restore -source "/Volumes/OS X Base System/" -target "/Volumes/boot" -erase
+
  # sudo asr restore -source "/Volumes/OS X Recovery" -target "/Volumes/boot" -erase
  # diskutil rename "/Volumes/OS X Base System 1" "boot"
+
  # diskutil rename "/Volumes/OS X Recovery 1" "boot"
  
And the paths used above will change, as we are using a “real” disk layout with '''no com.apple.boot.R''':
+
And the paths used above will change, as we are using a “real” disk layout with no com.apple.boot.R:
 
  # sudo rsync -a /Volumes/Capitan/System/Library/PrelinkedKernels/prelinkedkernel \
 
  # sudo rsync -a /Volumes/Capitan/System/Library/PrelinkedKernels/prelinkedkernel \
 
   /Volumes/boot/System/Library/PrelinkedKernels/prelinkedkernel
 
   /Volumes/boot/System/Library/PrelinkedKernels/prelinkedkernel
Line 433: Line 240:
  
 
Create partitions as above. If you already created a boot helper on one disk, you can clone it with Disk Utility or '''asr''' and edit the [com.apple.Boot.plist] to put a different pool name in '''zfs_boot''' in the '''Kernel flags'''.
 
Create partitions as above. If you already created a boot helper on one disk, you can clone it with Disk Utility or '''asr''' and edit the [com.apple.Boot.plist] to put a different pool name in '''zfs_boot''' in the '''Kernel flags'''.
 
''I was unable to boot Sierra on 2016 MacBookPro with "com.apple.boot.R" setup, but the minimal VirtualBox boot partition solution above has worked just fine.''
 
  
 
Hold '''option''' while powering on or restarting your Mac.
 
Hold '''option''' while powering on or restarting your Mac.
Line 470: Line 275:
  
 
This command actually sets the boot helper to be used on reboot:
 
This command actually sets the boot helper to be used on reboot:
  # sudo bless --device /dev/disk1s3 --setBoot --verbose
+
  # sudo bless --device disk1s3 --setBoot
 
+
This will also work, as it will locate the boot helper following the ZFS partition:
+
# sudo bless --device /dev/disk1s2 --setBoot --verbose
+
 
+
Currently --folder and --mount options will work (partially) but may select the wrong boot helper if there are multiple bootable ZFS pools.
+
(For example, if you have ZFS boot setup on both the internal disk and an external disk.)
+
# sudo bless --folder /Volumes/Capitan --setBoot --verbose
+
# sudo bless --mount /Volumes/Capitan --setBoot --verbose
+

Please note that all contributions to OpenZFS on OS X may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see OpenZFS on OS X:Copyrights for details). Do not submit copyrighted work without permission!

Cancel | Editing help (opens in new window)