The previous administrator of a server that is now under my supervision made a mistake. He accidentally created a LVM volume (no more than pvcreate, I think, though not sure) on a disk that actually contained an Ext4 partition with data. How do I recover data from a mistake like this? I'm ready to read ext4 documentation and roll out my own, but perhaps I don't need to? A few tools that I tried were unable to find an Ext4 filesystem on it, so I guess I need something more serious.
How to recover data from a messed up drive (LVM written on top of Ext4)
data-recoveryext4
Best Answer
If you run
mkfs.ext4 -n /the/partition
it will print out what a EXT4 formatted drive would look like on that system.Of note is that it will tell you where the superblock locations are.
Using this information, attempt to mount the drive using an alternative superblock..
Providing only the headers of the partition were destroyed this may work.
If that doesn't work however, you can try to fix the filesystem using
fsck.ext4
by specifying the superblock address. Backup the data with dd or something before you do this.This may just end up overwriting the bad superblock with one of the known good ones, which could be enough to get the entire disk remounted. Then again you may lose key inodes (like your root filesystem inode). Mileage may vary.