Lin, HongYi - Dell Team
2023-Aug-04 22:37 UTC
[Libguestfs] debug a corrupted VHDX file with libguestfs
Hi I am using libguestfs-1.46.2 on Ubuntu 22.04 I already enabled export LIBGUESTFS_DEBUG=1 export LIBGUESTFS_TRACE=1 I want to mount a vhdx file (which is known to be corrupted) with root at HenrikUbuntu2204:/mnt/sdj# guestmount -a c1eef115-00000006-ec888b8d-64888b8d-00155000-4a448456 -m /dev/sda1 --ro /mnt/sdk/ where I can see the following error message from output [ 46.629055] EXT4-fs (sda1): ext4_check_descriptors: Block bitmap for group 524288 not in group (block 0)! [ 46.629656] EXT4-fs (sda1): group descriptors corrupted! command: mount returned 32 I want to actually add debug logs into ext4_check_descriptors with printk To print out the hex values of superblock in the corrupted vhdx file I tried to recompile Ubuntu kernel and add some printk messages, they don't show up in dmesg when I run root at HenrikUbuntu2204:/mnt/sdj# guestmount -a c1eef115-00000006-ec888b8d-64888b8d-00155000-4a448456 -m /dev/sda1 --ro /mnt/sdk/ I guess the following messages are from libvirt / KVM ? [ 46.629055] EXT4-fs (sda1): ext4_check_descriptors: Block bitmap for group 524288 not in group (block 0)! [ 46.629656] EXT4-fs (sda1): group descriptors corrupted! How do I use printk to add logs in the kernel messages from libguestfs? Regards Henrik Internal Use - Confidential -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://listman.redhat.com/archives/libguestfs/attachments/20230804/8890ed30/attachment-0001.htm>
Richard W.M. Jones
2023-Aug-07 12:12 UTC
[Libguestfs] debug a corrupted VHDX file with libguestfs
On Fri, Aug 04, 2023 at 10:37:50PM +0000, Lin, HongYi - Dell Team wrote:> I tried to recompile Ubuntu kernel and add some printk messages, they don?t > show up in dmesg when I run > > root at HenrikUbuntu2204:/mnt/sdj# guestmount -a > c1eef115-00000006-ec888b8d-64888b8d-00155000-4a448456 -m /dev/sda1 --ro /mnt/ > sdk/ > > > I guess the following messages are from libvirt / KVM ? > > [ 46.629055] EXT4-fs (sda1): ext4_check_descriptors: Block bitmap for group > 524288 not in group (block 0)! > > [ 46.629656] EXT4-fs (sda1): group descriptors corrupted!These messages are from the kernel. However you will need to tell libguestfs to use your recompiled kernel. This can be done easily by setting some environment variables. This is what I do when I want to test a new kernel: rm -rf /tmp/kernel/* make make INSTALL_MOD_PATH=/tmp/kernel modules_install # In case the kernel modules are built with debug symbols: find /tmp/kernel/ -name '*.ko' -exec strip --strip-debug {} \; modules=`echo /tmp/kernel/lib/modules/*/` export SUPERMIN_KERNEL=$PWD/arch/x86/boot/bzImage export SUPERMIN_MODULES=$modules rm -rf /var/tmp/.guestfs-`id -u`/ Then run guestmount in the usual way. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-builder quickly builds VMs from scratch http://libguestfs.org/virt-builder.1.html