Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Oct 2014 10:51:16 -0500
From:      Bryan Venteicher <bryanv@daemoninthecloset.org>
To:        John Nielsen <lists@jnielsen.net>
Cc:        freebsd-virtualization@freebsd.org
Subject:   Re: can a bhyve instance be resized? adding another virtual disk?
Message-ID:  <CAMo0n6S48EHAvrk6fOk7ErcNivhAGLXYezAd=4uDDZwf2%2B8LiQ@mail.gmail.com>
In-Reply-To: <B38B9703-8BC4-4260-945D-8783D2F8765B@jnielsen.net>
References:  <20141015115638.GA72800@potato.growveg.org> <B38B9703-8BC4-4260-945D-8783D2F8765B@jnielsen.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Oct 15, 2014 at 9:38 AM, John Nielsen <lists@jnielsen.net> wrote:

> 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.
> > 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 truncat=
e.
> > 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 ca=
n
> 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), th=
en
> start it up again. That's the easy part.
>
>

Correct - the VirtIO block driver notifies GEOM when it receives that
event, but =E2=80=8Bbhyve doesn't yet report size changes. It is on my todo=
 list
for whenever I have the spare cycles to start hacking on bhyve.=E2=80=8B



> 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 hav=
e
> 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 u=
se
> "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
> > 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
>
> _______________________________________________
> freebsd-virtualization@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
> To unsubscribe, send any mail to "
> freebsd-virtualization-unsubscribe@freebsd.org"
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAMo0n6S48EHAvrk6fOk7ErcNivhAGLXYezAd=4uDDZwf2%2B8LiQ>