creating a bootable ZFS image
John Nielsen
lists at jnielsen.net
Wed Oct 31 20:21:13 UTC 2012
I am working on a script to create a ZFS-only disk image and install FreeBSD 9.1-RC2/RELEASE to it for use as a virtual machine template. Everything works fine up to the point where the image needs to be detached from the build host.
The cleanest (and most logical to me) would be to export the pool on the build host. Doing so frees the md device and removes the pool from the build host, which is what I want. Unfortunately the image will not boot, since the pool is marked inactive. I found a similar thread in 2011 (subject "Booting from a ZFS pool exported on another system") with a patch by PJD, but I don't know if that has ever been tested or committed. (AndI share Kenneth Vestergaard's concern that something else might need to happen to import the pool once the system boots.)
What I am doing instead is creating the pool with -o failmode=continue, installing, unmounting everything, then forcibly detaching the md device. This gives me an image I can use, and it boots and runs fine. Unfortunately, that leaves me with a defunct pool on the build host until I reboot it. Anything I try to do to the pool (destroy, offline, export, etc) returns "cannot open 'zfsroot': pool I/O is currently suspended." (With the default failmode=wait, it's even worse since any command that tries to touch the pool never returns.) The pool state is "UNAVAIL" and the device state is "REMOVED". Once the build host is rebooted the device state changes to UNAVAIL and zpool destroy works as expected.
Obviously I need the VM image to be bootable, and ideally I'd like to be able to run the script multiple times on the build host without changing the pool name or rebooting every time. Is there a way to make that happen? Specifically:
Is it possible to cleanly offline a zpool without exporting it?
If I yank the md device, is there a way to tell zpool to give up on it without rebooting?
Is it possible to boot from an exported filesystem?
Thank you,
John Nielsen
More information about the freebsd-fs
mailing list