creating a bootable ZFS image

John Nielsen lists at jnielsen.net
Thu Nov 1 20:54:23 UTC 2012


On Oct 31, 2012, at 4:30 PM, Fabian Keil <freebsd-listen at fabiankeil.de> wrote:

> John Nielsen <lists at jnielsen.net> wrote:
> 
>> 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.
> 
> Did you try "zpool clear [-F] $pool" after reattaching the md?
> 
> It often works for me in situations where other zpool subcommands
> just hang like you described above.

Thanks for the response. I haven't tried that since I don't want to reattach [a copy of] the md if I don't have to. However, this suggestion prompted me to come up with the following, which will work until something better comes along. It takes advantage of ZFS on the build host to make a temporary snapshot of the zfs where the image file is located. Could also be adapted to use a zvol instead of an image file.

# zfs unmount imageroot (and its children)
... modify mount points, etc for target ...
# zfs snapshot buildhostpool/images at mkimage_tmp
# zpool destroy imageroot
# md config -d -u ${MD}
# zfs rollback buildhostpool/images at mkimage_tmp
# zfs destroy buildhostpool/images at mkimage_tmp

No orphaned zpool or busy md device on the build host, but all the bits are still intact on the image after rolling back the snapshot.

Thanks,

JN



More information about the freebsd-fs mailing list