Skip to content

Instantly share code, notes, and snippets.

@chaddupuis
Last active July 13, 2023 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chaddupuis/0e201430d72e37ee91ba40468e8406a4 to your computer and use it in GitHub Desktop.
Save chaddupuis/0e201430d72e37ee91ba40468e8406a4 to your computer and use it in GitHub Desktop.
Recover Data From A Multipass Qemu VM Image That Won't Start on MacOS M1/M2 (using linux)

Multipass on MacOS m1/m2 machines has had some ongoing issues with VM's working for awhile then failing to start. Previously, through some combination of these steps, I could get multipass working again and access my previous builds. After losing some data a couple of times this way, I've decided to ditch multipass for now. Unfortunately, this one time I had some data from an unfinished build that I had to get off one of the vm images that I could no longer start.

I tried a few ways of doing this solely on the mac, but I ended up copying the image file over to a desktop running suse/tumbleweed (distro shouldn't matter for these) and accessing the files there. Here are the general steps:

  • Find your vm image (need sudo). On a mac these should be in /var/root/Library/Application\ Support/multipassd/qemu/vault/instances/ - then in a folder with the name of your vm, grab the .img file and copy it somewhere and chown it to your local account.

  • Copy the file through whatever means necessary to a linux machine and ensure that the qemu tools are installed (on suse this was sudo zypper in qemu). Then follow the steps highlighted in this gist:

modprobe nbd max_part=8
qemu-nbd --connect=/dev/nbd0 /your/image/multipass-vm-image.img
fdisk /dev/nbd0 -l
mount /dev/nbd0p1 /mnt/yourmountpoint

Copy out whatever files you needed from the vm you couldn't start. Then when you are done:

umount /mnt/yourmountpoint
qemu-nbd --disconnect /dev/nbd0
rmmod nbd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment