Score:0

ext4 FS image gets corrupted on first mount

cn flag

I"m in the process of replacing my M.2 SSD with a new and larger one. I want to save an image of my existing partitions before I take out my old SSD so that I can refer to it when setting up my new install and make sure I don't lose anything. I only have one SSD slot in my machine so I can't use the SSD itself, so that's what the image files are for.

I thought this would be fairly straightforward, but I'm running into a weird problem. The image creation appears to execute without a problem and I can loop-mount the image without a problem. But after poking around the mounted filesystem for a bit, I get all sorts of errors, such as

"ls:  reading directory <directory> : Bad message"

I created the images with a simple dd command:

dd if=/dev/nvme0n1p5 of=backup.img bs=64kb status=progress

When they were finished being created, I checked the images without mounting them:

fsck.ext4 backup.img

which then reported that the image was clean.

I then mount the image:

mount backup.img <mnt_pnt>

I then do an 'ls -R' command, and I get the "bad message" error mentioned above.

If I then unmount the filesystem and run fsck again, it reports all sorts inode errors.

If I mount the actual partition directly, there are no errors and the files that were listed with the "Bad message" error have no error.

Base system is a Kubuntu 20.04. I made sure to force an fsck on all partitions before beginning the backup. Backups are being placed on a NAS drive mounted via CIFS.

Procedure above is being performed on a Kubuntu 21.20 Live USB system.

What am I doing wrong?

EDIT: I've looked at CloneZilla and fsarchiver. They seem to promise a lot, but my issue is that I don't want to -restore- these filesystems after I've imaged them. I just want to be able to MOUNT them on a new, fresh ubuntu install and extract and files I need. I tried CloneZilla's instructions for doing so (which they themselves state is a work-around hack) and it couldn't mount the image after I decompressed it. fsarchiver I'm not sure about yet.

Score:0
cn flag

In case anyone else runs into this: I ended up using e2image to image the partitions instead of dd directly. It appeared to make the images without any of the issues I listed in my question, and I could mount the images as a loopback device.

br flag
I might also mention that using rsync with the `-ax --numeric-ids` flags is a great tool: you can restore an entire Linux based OS using it, only having to update the `/etc/fstab` with new FS UUIDs and installing a bootloader (grub with chroot method). That saves a TON of space compared to disk images.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.