Is it safe to read-only mount a running bhyve image from the host?

6 views
Skip to first unread message

Pat Maddox

unread,
Mar 23, 2025, 5:12:46 PM3/23/25
to freebsd-...@freebsd.org
I'm running a bhyve VM (freebsd guest), and want to back up individual files from the VM. I thought I would need to use SSH, or possibly stop the VM and mount the image from the host.

However, I tried mounting the image while the VM was running... and to my surprise, it worked (I was expecting a kernel panic):

1. `mdconfig -a /vm/myvm/myvm.img`
2. `zpool import -f -o readonly=on -t -R /tmp/myvm-root -d /dev/md0p2 zroot myvm-root`

I was then able to read the files from the host _as of the time I ran `mdconfig`_. So if I add / edit / delete files in the VM, the host doesn't see it until I unmount and remount.

Is this a wonderful feature that lets me back up individual files from a running VM? Or a giant footgun that will eventually corrupt my VM image?

Pat

Pat Maddox

unread,
Mar 23, 2025, 5:37:52 PM3/23/25
to freebsd-...@freebsd.org
I got a much better suggestion on discord: snapshot the filesystem on the host. Mount the image file from the snapshot, and proceed. -Pat

Reply all
Reply to author
Forward
0 new messages