RyanServer711 Posted August 5, 2022 Share Posted August 5, 2022 I had some issues with my server. Longs story short, I now have a seemingly corrupted qcow2 image file. Every time I try to use it it either doesn't load or crashes my system. Tried to copy it to my windows machine but it fails part way through. Is there any way to open it up or search through the files? I'm desperately trying to get my backups hidden inside and really don't want to start from scratch again. Any help would be greatly appreciated. Quote Link to comment
ghost82 Posted August 5, 2022 Share Posted August 5, 2022 (edited) You can use qemu-nbd command line. First backup your qcow2 file. Then in a terminal: Load kernel module: modprobe nbd max_part=8 Create nbd0 block device: qemu-nbd --connect=/dev/nbd0 /replace/with/path/to/file.qcow2 Use fdisk to list partitions and see if you get any output: fdisk -l /dev/nbd0 Yiu can also use fsck to try to repair partitions: fsck /dev/nbd0p1 nbd0p1 being partition 1. You can also mount the partition (in this example nbd0p1) somewhere: mount /dev/nbd0p1 /mnt/somepoint/ Once done, disconnect: qemu-nbd --disconnect /dev/nbd0 Edited August 5, 2022 by ghost82 Quote Link to comment
RyanServer711 Posted August 5, 2022 Author Share Posted August 5, 2022 I did the first 2 commands and received this on the 3rd. fdisk -1 /dev/nbd0 fdisk: invalid option -- '1' I tried the first 2 again and received this message. I assume this means the first 2 commands worked. qemu-nbd: Failed to blk_new_open '/mnt/disks/00000000000000001358/domains/home_assistant/haos_ova-7.5.qcow2': Failed to get "write" lock Is another process using the image [/mnt/disks/00000000000000001358/domains/home_assistant/haos_ova-7.5.qcow2]? Quote Link to comment
RyanServer711 Posted August 5, 2022 Author Share Posted August 5, 2022 I tried fsck /dev/nbd0p1 and received this message. fsck /dev/nbd0p1 fsck from util-linux 2.37.4 fsck.fat 4.2 (2021-01-31) Dirty bit is set. Fs was not properly unmounted and some data may be corrupt. 1) Remove dirty bit 2) No action [12?q]? Should I go ahead and try to remove dirty bit? Thanks for the help btw 👍 Quote Link to comment
AceRimmer Posted August 5, 2022 Share Posted August 5, 2022 6 hours ago, RyanServer711 said: I had some issues with my server. Longs story short, I now have a seemingly corrupted qcow2 image file. Every time I try to use it it either doesn't load or crashes my system. Tried to copy it to my windows machine but it fails part way through. Is there any way to open it up or search through the files? I'm desperately trying to get my backups hidden inside and really don't want to start from scratch again. Any help would be greatly appreciated. I've had loads of trouble in the past with the HA qcow2 image corrupting. I've always kept a spare backup qcow2 after i've set HA how i need it, and while you are at it run the Google drive backup pluygin on HA. Its also saved me before to load back an old config. On a few occasions its been the boot config which got messed up on the VM, so diving into the virtual bios and resetting the boot device has fixed it, but normally i just blow away the old qcow2 and recover from the backup image. Quote Link to comment
RyanServer711 Posted August 5, 2022 Author Share Posted August 5, 2022 So loading a fresh install would have my backups in there? I thought they would be inside the corrupted qcow2? I've done regular backup within home assistant but I didn't think they left the VM unless specifically done so. Quote Link to comment
RyanServer711 Posted August 5, 2022 Author Share Posted August 5, 2022 I assumed they were lost in the corrupted qcow2. Either way I'm learning a very good lesson in backing up my stuff Quote Link to comment
ghost82 Posted August 5, 2022 Share Posted August 5, 2022 (edited) is something using the qcow2 file?is the vm completely shutdown? If so, try to remove the "dirty bit". Edited August 5, 2022 by ghost82 Quote Link to comment
ghost82 Posted August 5, 2022 Share Posted August 5, 2022 1 hour ago, RyanServer711 said: fdisk -1 it's -l not -1 Quote Link to comment
RyanServer711 Posted August 5, 2022 Author Share Posted August 5, 2022 Interesting, i'll try that. Quote Link to comment
RyanServer711 Posted August 5, 2022 Author Share Posted August 5, 2022 (edited) This is what I have with the correct list command Device Start End Sectors Size Type /dev/nbd0p1 2048 67583 65536 32M EFI System /dev/nbd0p2 67584 116735 49152 24M Linux filesystem /dev/nbd0p3 116736 641023 524288 256M Linux filesystem /dev/nbd0p4 641024 690175 49152 24M Linux filesystem /dev/nbd0p5 690176 1214463 524288 256M Linux filesystem /dev/nbd0p6 1214464 1230847 16384 8M Linux filesystem /dev/nbd0p7 1230848 1427455 196608 96M Linux filesystem /dev/nbd0p8 1427456 67108830 65681375 31.3G Linux filesystem Also I did the dirty bit removal on this copy of qcow2 Edited August 5, 2022 by RyanServer711 Quote Link to comment
RyanServer711 Posted August 5, 2022 Author Share Posted August 5, 2022 Wait?!? Is the VM running out of memory? Isn't the default cap lower than 32G? Quote Link to comment
Solution ghost82 Posted August 5, 2022 Solution Share Posted August 5, 2022 data should be in the larger partition, nbd0p8, try to mount it somewhere. Quote Link to comment
RyanServer711 Posted August 5, 2022 Author Share Posted August 5, 2022 Crashed it, is there a recommended mount point? I just picked a folder in my backup share on my array. /mnt/disk1/backup/HATEST I'm going to try again Quote Link to comment
RyanServer711 Posted August 5, 2022 Author Share Posted August 5, 2022 SUCCESS! I found the directory my backup are in! 1 Quote Link to comment
RyanServer711 Posted August 5, 2022 Author Share Posted August 5, 2022 I'm back up and running! Thanks for all th help. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.