From owner-freebsd-virtualization@FreeBSD.ORG Wed Oct 15 14:38:47 2014 Return-Path: Delivered-To: freebsd-virtualization@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6C977DEA for ; Wed, 15 Oct 2014 14:38:47 +0000 (UTC) Received: from webmail2.jnielsen.net (webmail2.jnielsen.net [50.114.224.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "webmail2.jnielsen.net", Issuer "freebsdsolutions.net" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 30AA2F5C for ; Wed, 15 Oct 2014 14:38:46 +0000 (UTC) Received: from [192.168.2.46] (c-50-160-123-105.hsd1.ut.comcast.net [50.160.123.105]) (authenticated bits=0) by webmail2.jnielsen.net (8.14.9/8.14.9) with ESMTP id s9FEcbYs047131 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) for ; Wed, 15 Oct 2014 08:38:40 -0600 (MDT) (envelope-from lists@jnielsen.net) X-Authentication-Warning: webmail2.jnielsen.net: Host c-50-160-123-105.hsd1.ut.comcast.net [50.160.123.105] claimed to be [192.168.2.46] Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) Subject: Re: can a bhyve instance be resized? adding another virtual disk? From: John Nielsen In-Reply-To: <20141015115638.GA72800@potato.growveg.org> Date: Wed, 15 Oct 2014 08:38:37 -0600 Content-Transfer-Encoding: quoted-printable Message-Id: References: <20141015115638.GA72800@potato.growveg.org> To: freebsd-virtualization@freebsd.org X-Mailer: Apple Mail (2.1878.6) X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "Discussion of various virtualization techniques FreeBSD supports." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Oct 2014 14:38:47 -0000 On Oct 15, 2014, at 5:56 AM, freebsd-lists@potato.growveg.org wrote: > Can a bhyve instance be resized? I'm talking about the disk.=20 > Say your end user needs more diskspace. They have 32GB. They need = 64GB. > How do you do it? I presume one has to stop the guest, then use = truncate. > What about if the guest OS isn't freebsd, and they use say ext2 or 3? = Will > ext3 start yelling at me because I've resized it? This isn't specific to FreeBSD or bhyve. Virtio block devices actually = can support online resizing, but I don't know if bhyve allows that yet = (I'm assuming it doesn't). In which case, yes, stop the guest and resize = whatever its volume lives on (if a raw file then truncate would work), = then start it up again. That's the easy part. The harder part (but much easier than it used to be) is resizing = everything else. If using partitions they need to be extended first (and = if using GPT the backup partition table needs to be moved first of all, = a la "gpart recover".) On FreeBSD this is pretty straightforward with = gpart: sysctl kern.geom.debugflags=3D16 gpart resize -i $number_of_last_partition $underlying_block_device You should probably reboot at this point so the kernel forgets about the = old partition table. Then you get to resize the filesystem. If you are using ZFS or if you = have FreeBSD 9.2 or newer and UFS then you can do it while it is = mounted. Otherwise you may need to boot from another source to do the = resize. For UFS use growfs a la "growfs = /dev/$block_special_for_partition". For ZFS use "zpool online -e $zpool = $zdev" For ext[234] on Linux, use "resize2fs /dev/$block_special". (If using = LVM then you need to first resize the LV with lvextend). For XFS use = "xfs_growfs $mountpoint". You can also resize btrfs but I don't know the = command off the top of my head. That should be it. > What if they just want another disk? How does one refer to a=20 > newly created virtual disk from a guest? How is it mounted to the = guest? Just add a "-d /path/to/new/device" to your vmrun.sh or the = corresponding -s to bhyve when you start the VM. It will show up as a = new block device in the guest (e.g. /dev/vtbd1), you can partition = and/or put filesystems on it as you choose and mount them normally = and/or add them to /etc/fstab, etc. JN