mounting/exporting/importing a zfs volume

Frank Leonhardt freebsd-doc at fjl.co.uk
Mon Feb 11 23:22:27 UTC 2019


On 11/02/2019 17:03, Victor Sudakov wrote:
> Dear Colleagues,
>
> vm-bhyve keeps virtual machines on zfs volumes with volmode=dev. How can
> I access/mount the filesystems within the volume when the virtual host
> is offline?
>
> If I kept virtual disks in raw files, I could access them as devices
> with mdconfig. But:
>
> root at newserv:~ # mdconfig -a -f /dev/zvol/zroot/vm/mail/disk0
> mdconfig: /dev/zvol/zroot/vm/mail/disk0 is not a regular file
> root at newserv:~ #
>
> Also, how can I exchange those zfs volumes for use with other
> hypervisors? They are not real raw disk files so I cannot use
> sysutils/vmdktool etc.
>
I don't know this, but I'll guess(!)

If you've set volmode to dev then you get a cdev device in devfs, and 
you'll never get it to mount. Try using geom instead (which IIRC is the 
default).

HOWEVER, I suspect you're doing this because you're hoping that a ZFS 
volume is faster than a file.  I went through this, in the hope it 
wouldn't do CoW and would therefore be a lot better for databases. I was 
disappointed! Bascially, it's no better than a ZFS file. If that was 
your plan, use a UFS partition. I don't use ZFS volumes any more; I 
think they're more useful on Solaris. A md mapped on to a ZFS file seems 
to be the BSD way, and for VMs just use a file in its own dataset. You 
can then clone the dataset. Just what you need for nearly identical VMs.

Regards, Frank.




More information about the freebsd-virtualization mailing list