Difference between revisions of "ZVOL boot"

From OpenZFS on OS X
Jump to: navigation, search
m (Create zvol)
 
(3 intermediate revisions by one user not shown)
Line 2: Line 2:
  
 
Using the same steps to create the boot helper partition as [[ZFS on Boot]], you may install Mac OS X onto a ZVOL device and use it as your boot volume.
 
Using the same steps to create the boot helper partition as [[ZFS on Boot]], you may install Mac OS X onto a ZVOL device and use it as your boot volume.
 +
 +
==== Disable bootfs ====
 +
 +
zvol boot does not currently co-exist with zfs boot (planned to be fixed). The presence of the '''bootfs''' property will take precedence at boot time.
 +
 +
You will need to clear bootfs when using zvol boot:
 +
 +
# <nowiki>sudo zpool set bootfs='' poolname</nowiki>
 +
 +
Using two single quotes will remove the previous bootfs.
  
 
==== Create zvol ====
 
==== Create zvol ====
Line 11: Line 21:
  
 
Erase and create a volume
 
Erase and create a volume
 +
 +
With partition map:
 
  # diskutil eraseDisk JHFS+ MacOS ${zvol}
 
  # diskutil eraseDisk JHFS+ MacOS ${zvol}
 +
  Note: direct OS install may only be allowed with a partition map, testing needed
 +
 +
Without partitions:
 +
# diskutil eraseVolume JHFS+ MacOS ${zvol}
 +
 +
Alternate method, also without partitions and using zvol symlink:
 +
# newfs_hfs -J -v "MacOS" /var/run/zfs/zvol/rpool/ZVOL/MacOS
  
 
==== Clone root ====
 
==== Clone root ====
Line 40: Line 59:
  
 
==== Setup boot helper ====
 
==== Setup boot helper ====
 +
 +
Boot helper can be setup similar to the boot helper for [[ZFS on Boot]] with some differences.
 +
 +
Root UUID must be set to the Volume UUID of the zvol. You can retrieve this by:
 +
 +
# diskutil info diskN | grep "Volume UUID"
 +
 +
For a volume directly within a zvol, or
 +
 +
# diskutil info diskNsN | grep "Volume UUID"
 +
 +
For a zvol with a partition map.
 +
 +
Kernel Flags should contain "zfs_boot=poolname"
 +
 
See [[Boot.plist]] for sample plist files.
 
See [[Boot.plist]] for sample plist files.
 +
 +
At this time zfs_boot=poolname/zvol or poolname/dataset/zvol will only import the zpool "poolname" and does not check or mount the zvol specified. Correctly setting Root UUID to match will inform the OS to locate the root volume.
 +
 +
In the future, it will be possible to specify a zvol by name, which will then be inspected for matching volume UUID and presented for mount. This would prevent any duplicate UUID clashes due to `zfs clone` copies. To do so will require an additional property zfs_root_uuid=<uuid>, or perhaps zfs_root_partition=N, so that the OS does not try to automatically load the first matching volume.

Latest revision as of 07:40, 11 July 2016

ZVOL Boot[edit]

Using the same steps to create the boot helper partition as ZFS on Boot, you may install Mac OS X onto a ZVOL device and use it as your boot volume.

Disable bootfs[edit]

zvol boot does not currently co-exist with zfs boot (planned to be fixed). The presence of the bootfs property will take precedence at boot time.

You will need to clear bootfs when using zvol boot:

# sudo zpool set bootfs='' poolname

Using two single quotes will remove the previous bootfs.

Create zvol[edit]

# zfs create -sV 80g rpool/ZVOL/MacOS

Get the diskN for that device

# zvol=`ioreg -trn "ZVOL rpool/ZVOL/MacOS Media" | grep "BSD Name" | awk -F'"' '{print $4}'`
  (it would be nice if we could just # zfs get zvol-disk rpool/ZVOL/MacOS)

Erase and create a volume

With partition map:

# diskutil eraseDisk JHFS+ MacOS ${zvol}
  Note: direct OS install may only be allowed with a partition map, testing needed

Without partitions:

# diskutil eraseVolume JHFS+ MacOS ${zvol}

Alternate method, also without partitions and using zvol symlink:

# newfs_hfs -J -v "MacOS" /var/run/zfs/zvol/rpool/ZVOL/MacOS

Clone root[edit]

Clone an existing Mac OS

# rsync -axH --exclude=".Spotlight-V100" --exclude=".fseventsd" \
 --exclude=".vol" "/Volumes/Macintosh HD/" "/Volumes/MacOS/"

Or use Apple System Restore

# asr --source "/Volumes/Macintosh HD" --target "/Volumes/MacOS" --erase

New install[edit]

It is possible, but requires a few steps, to install Mac OS onto a ZVOL with the standard Apple installer. Download the installer from the App Store, and create an installer flash drive. Boot into the Installer, with a standard Mac OS disk available Macintosh HD (that has ZFS installed).

From Utilities->Terminal you can:

# kextload "/Volumes/Macintosh HD/Library/Extensions/spl.kext"
# kextload "/Volumes/Macintosh HD/Library/Extensions/zfs.kext"

At that point you need access to the zpool and zfs commands, which require the libzfs and libzpool libraries. To work around the install environment, simply:

# chroot "/Volumes/Macintosh HD"
# zpool import

Or if necessary

# /usr/local/sbin/zpool import

This worked with El Capitan Install 10.11 and the signed O3x from Downloads. I don't remember which version of O3x, but I believe it was 1.4.5 or so.

Setup boot helper[edit]

Boot helper can be setup similar to the boot helper for ZFS on Boot with some differences.

Root UUID must be set to the Volume UUID of the zvol. You can retrieve this by:

# diskutil info diskN | grep "Volume UUID"

For a volume directly within a zvol, or

# diskutil info diskNsN | grep "Volume UUID"

For a zvol with a partition map.

Kernel Flags should contain "zfs_boot=poolname"

See Boot.plist for sample plist files.

At this time zfs_boot=poolname/zvol or poolname/dataset/zvol will only import the zpool "poolname" and does not check or mount the zvol specified. Correctly setting Root UUID to match will inform the OS to locate the root volume.

In the future, it will be possible to specify a zvol by name, which will then be inspected for matching volume UUID and presented for mount. This would prevent any duplicate UUID clashes due to `zfs clone` copies. To do so will require an additional property zfs_root_uuid=<uuid>, or perhaps zfs_root_partition=N, so that the OS does not try to automatically load the first matching volume.