Re: Is it safe to read-only mount a running bhyve image from the host?
- In reply to: Pat Maddox: "Is it safe to read-only mount a running bhyve image from the host?"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 23 Mar 2025 21:36:48 UTC
On Sun, Mar 23, 2025, at 2:11 PM, Pat Maddox wrote: > 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 I got a much better suggestion on discord: snapshot the filesystem on the host. Mount the image file from the snapshot, and proceed. -Pat