From owner-freebsd-fs@FreeBSD.ORG Wed Oct 31 20:21:13 2012 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 67255903 for ; Wed, 31 Oct 2012 20:21:13 +0000 (UTC) (envelope-from lists@jnielsen.net) Received: from ns1.jnielsen.net (secure.freebsdsolutions.net [69.55.234.48]) by mx1.freebsd.org (Postfix) with ESMTP id 2D7408FC14 for ; Wed, 31 Oct 2012 20:21:12 +0000 (UTC) Received: from [10.10.1.32] (office.betterlinux.com [199.58.199.60]) (authenticated bits=0) by ns1.jnielsen.net (8.14.4/8.14.4) with ESMTP id q9VK1W6O056558 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT) for ; Wed, 31 Oct 2012 16:01:32 -0400 (EDT) (envelope-from lists@jnielsen.net) From: John Nielsen Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Subject: creating a bootable ZFS image Message-Id: Date: Wed, 31 Oct 2012 14:01:42 -0600 To: freebsd-fs@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 6.2 \(1499\)) X-Mailer: Apple Mail (2.1499) X-DCC-x.dcc-servers-Metrics: ns1.jnielsen.net 104; Body=1 Fuz1=1 Fuz2=1 X-Virus-Scanned: clamav-milter 0.97.5 at ns1.jnielsen.net X-Virus-Status: Clean X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Oct 2012 20:21:13 -0000 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=3Dcontinue, = 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=3Dwait, 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