Re: FreeBSD guest online disk resize

From: Freddie Cash <fjwcash_at_gmail.com>
Date: Mon, 17 Nov 2025 19:30:45 UTC
On Mon, Nov 17, 2025 at 11:01 AM Alexandre Biancalana <biancalana@gmail.com>
wrote:

> I am using bhyve with several VMs where the VM disks (NVMe) are stored
> on an NFS server and exported to the hypervisor. Occasionally, I need
> to expand the disks due to space constraints. I perform this expansion
> by resizing the VM disk files using the truncate command.
>
> On Linux guests, the disk resize is immediately recognized, and the
> filesystem can be expanded online without issues.
>
> However, on FreeBSD guests, while the NVMe layer recognizes the disk
> resize (confirmed by the appearance of the asynchronous event message
> in dmesg):
>
> nvme2: async event occurred (type 0x2, info 0x00, page 0x04)
>
> and `nvmecontrol devlist` correctly shows the new disk size, there is a
> problem.
>
> The VM disk has no partition table and is formatted entirely with UFS
> and has a ufs label, hence geom_label is in use. Unfortunately, glabel
> list does not recognize the disk resize and still shows the old disk
> size.
>

Are you using UFS filesystem volume labels (-L option to newfs/tunefs) or
GEOM labels create via glabel? They're two different things.

One saves a label within the filesystem metadata, the other stores a label
in the last sector of the disk or partition. The latter can cause issues
when you try to resize disks/partitions/filesystems as you'll overwrite the
label and need to recreate it.

These days, glabel isn't really needed as most filesystems support volume
labels, and the GPT partition scheme supports partition labels.

glabel is still used for viewing labels, through, regardless of where in
the GEOM stack they're created, including filesystem labels.


> Ideally, I would like to perform a disk resize that FreeBSD recognizes
> without requiring a system reboot.
>
> Am I missing a step, or is there a recommended procedure to make
> geom_label recognize the resized disk size dynamically on FreeBSD
> guests?
>

I've never managed to resize virtual disks in any hypervisor, regardless if
it's on Windows, Linux, or FreeBSD, without power cycling the VM. Could be
a configuration issue on my side, but I've always found it to be more
reliable to treat the VM like physical hardware, where it's almost
impossible to increase the size of a disk (aka replace with a larger one)
without powering it off first. :)


-- 
Freddie Cash
fjwcash@gmail.com