utmapp / UTM

Virtual machines for iOS and macOS
https://getutm.app
Apache License 2.0
26.59k stars 1.33k forks source link

Need to recover files on VirtFS disk that crashed and won't boot #4987

Closed daryl-williams closed 1 year ago

daryl-williams commented 1 year ago

Describe the issue
I installed an Ubuntu 22.04 UTM VM on an M1 MacBook Air to do some software development and the VM crashed and now won't boot. Using grub I am able to see my software using the ls and cat commands and the files seem to be ok. I would like to know if there is some way to recover the directory containing my software using grub or some other method.

Configuration

Crash log
Using the Console.App I am unable to find the crash report, but there is an error message printed when trying to restart the VM: QEMU exited from an error: qemu-aarch64-softmmu: -drive if=pflash,unit=1,file=/Volumes/OS X Snow Leopard 10.6.8/UTM/SongBook.utm/Data/efi_vars.fd: Could not read image for determining its format: Input/output error.

Debug log
I am unable to find the debug log after clicking the debug option, however I found a report under Diagnostic Reports I can attach if it would be useful.

Upload VM
I have attached the compressed config.plist.

If I can provide more information please let me know. Any help would;d be much appreciated.

Regards,

Daryl

ktprograms commented 1 year ago

You can create or use another Linux VM to do this.

Install qemu (through brew), and you'll get the qemu-nbd binary, which you can use to serve the file like this: qemu-nbd -f qcow2 <path-to-disk-image>

Then in the VM install nbd-client if it isn't already installed, then run

  1. sudo modprobe nbd
  2. sudo nbd-client <ip_of_host> /dev/nbd0 -nofork
  3. sudo mount /dev/nbd0 /mnt/

After that, you can access the files inside /mnt/ and can copy them to your host.

daryl-williams commented 1 year ago

Hi @ktprograms,

Thanks for your response. I tried to follow your instructions but when I ran the nbd-client command I got the following message:

E: option eaten by 42 mice

Here are the steps I too:

  1. Installed new UTM Ubuntu VM

  2. On the host (my MacBook Air) I ran the command:

    $ qemu-nbd -f qcow2 /Volumes/OS\ X\ Snow\ Leopard\ 10.6.8/UTM/SongBook.utm/Data/80F9E8D8-80F8-4E91-AD77-24A6BA8E8998.qcow2 The command did not produce any errors. The command did not return to command line and ps shows that it is running.

  3. Booted the new Linux VM and ran the following commands: a. # modprobe nbd b. # nbd-client 192.168.52.114 /dev/nbd0 -nofork // The ip 192.168.52.114 is the MacBook Air This command yielded the error: nbd-client invalid option — ‘o’ E: option eaten by 42 mice I then tried the same command using two dashes with the —no-fork option and this time it produced the: E: option eaten by 42 mice

    c. I then proceeded to try the mount anyway and got the following error:

    mount /dev/nbd0 /mnt/

    This command returned: mount: /mnt: can’t read superblock on /dev/nbd0.

@ktprograms, I appreciate your response and your help. Can you tell if I messed up any of the instructions or if there is anything else I can try?

Thanks again and Best Regards,

Daryl Williams

On Feb 3, 2023, at 01:50, ktprograms @.***> wrote:

You can create or use another Linux VM to do this.

Install qemu (through brew), and you'll get the qemu-nbd binary, which you can use to serve the file like this: qemu-nbd -f qcow2

Then in the VM install nbd-client if it isn't already installed, then run

sudo modprobe nbd sudo nbd-client /dev/nbd0 -nofork sudo mount /dev/nbd0 /mnt/ After that, you can access the files inside /mnt/ and can copy them to your host.

— Reply to this email directly, view it on GitHub https://github.com/utmapp/UTM/issues/4987#issuecomment-1415515019, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH7A5I2CIYFOKYEQCUOLCLWVTIGBANCNFSM6AAAAAAUPQBREU. You are receiving this because you authored the thread.

daryl-williams commented 1 year ago

I'm not sure what I did wrong before but I was able to successfully run the nbd-client 192.168.52.114 /dev/nbd0 -nofork command and it reported the following:

Warning: the oldstyle protocol is no longer supported. This method now uses the new style protocol with a default export Negotiation: ..size = 65536MB Connected /dev/nbd0

and when I try the mount: sudo mount /dev/nbd0 /mnt/ I get the following error:

mount: /mnt: wrong fs type, bad option, bad superblock on /dev/nbd0, missing codepage or helper program or other error.

Using grub I am still able to ls and cat the files I need to recover and they still appear to be ok. Any help would be greatly appreciated.

Daryl

ktprograms commented 1 year ago

The nofork flag isn't important, so you can just remove it.

I didn't realise it wasn't a Linux VM that you needed to recover the files from. What filesystem is on the disk?

As for the mount error, it's probably because the disk has multiple partitions. Run partprobe /dev/nbd0 and then fdisk /dev/nbd0 (both as root/sudo), and then try to mount the correct partition.

daryl-williams commented 1 year ago

Thanks for following up, but I guess I didn’t explain very well. The VM that crashed is indeed using Linux Ubuntu 22.04, the host system is my MacBook laptop. I created a second Linux VM to follow your instructions.I did after a few tries get the nbd-client command to work but thart’s when I got the error:

mount: /mnt: wrong fs type, bad option, bad superblock on /dev/nbd0, missing codepage or helper program or other error.

I’m pretty sure the VM that crashed was using an ext4 filesystem. I ran part probe (as root) and the ran disk but got an error:

fdisk: cannot open /dev/nbd0: Inappropriate ioctl for device

I’m still hoping there’s a way to. Get at those files.

Thanks again for your help.

Daryl

On Feb 3, 2023, at 16:46, ktprograms @.***> wrote:

The nofork flag isn't important, so you can just remove it.

I didn't realise it wasn't a Linux VM that you needed to recover the files from. What filesystem is on the disk?

As for the mount error, it's probably because the disk has multiple partitions. Run partprobe /dev/nbd0 and then fdisk /dev/nbd0 (both as root/sudo), and then try to mount the correct partition.

— Reply to this email directly, view it on GitHub https://github.com/utmapp/UTM/issues/4987#issuecomment-1416564518, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH7A5O26DKFMLLZI7443GTWVWRF7ANCNFSM6AAAAAAUPQBREU. You are receiving this because you authored the thread.

ktprograms commented 1 year ago

The VM that crashed is indeed using Linux Ubuntu 22.04, Oh, sorry. No worries, these instructions should still work.

After partprobe, what nbd devices do you see in /dev/?

daryl-williams commented 1 year ago

Hi @ktprograms,

I forgot to run the qemu-nbd command the first time I tried your suggestion and I think that’s why it failed. I am now running the qemu-nbd command on my laptop and re-tried your suggestion a with somewhat better outcome. There three partitions on the virtual disk:

/dev/nbd0p1 2048 2203647 2201600 1G EDI System /dev/nbd0p2 2203648 6397951 4194304 2G Linux filesystem /dev/nbd0p3 6397952 134215679 127817728 60.9G Linux filesystem

I was able to mount /dev/nbdp01 and see the root filesystem but when I tried to mount /dev/nbd0p3 I got the following error:

mount: /mnt unknow filesystem type ‘LVM2_member’'

I don’t know yjat much about LVM so I guess I’ll start reading up on how to mount an LVM2_member volume…

Thanks again, I appreciate your help.

Daryl

On Feb 3, 2023, at 16:46, ktprograms @.***> wrote:

The nofork flag isn't important, so you can just remove it.

I didn't realise it wasn't a Linux VM that you needed to recover the files from. What filesystem is on the disk?

As for the mount error, it's probably because the disk has multiple partitions. Run partprobe /dev/nbd0 and then fdisk /dev/nbd0 (both as root/sudo), and then try to mount the correct partition.

— Reply to this email directly, view it on GitHub https://github.com/utmapp/UTM/issues/4987#issuecomment-1416564518, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH7A5O26DKFMLLZI7443GTWVWRF7ANCNFSM6AAAAAAUPQBREU. You are receiving this because you authored the thread.

daryl-williams commented 1 year ago

Hi @ktprograms,

Just wanted to let you know I was finally able to recover my files using the instructions you provided. Two of the LVM volumes had the same vg-group name so I had to rename one of them and then I was able to mount the volume using the following commands:

sudo vgdisplay // Showed me both volume groups with the same name. sudo vgrename newgrp-vg // Rename the volume group sudo modprobe dm-mod sudo vgchange -ay sudo lvscan sudo mount /dev/newgrp-vg/ubuntu-lv /mnt

Thanks again for all your help.

Daryl