FOUND file in device by hex content using wxHexEditor
Just having a play around, this turned out to be not as clear cut as expected.
so I created a file and entered some text, used xxd to get the hex values, and then opened the device /dev/sdb1 in wxhexeditor and tried to find my file, but it's not finding it. Inode is 19, so it should be right at the start of the first block group, but after several minutes, no joy. (drive is ext4.)
I thought this was going to be an easy task, just multiply the inode by the block size, open the device with wxhexeditor, and scroll to the line corresponding to the calculated byte, copy out the hex values and convert to ascii and voila, there's the 'hello world'... except no.
What am I missing here? Drive isn't encrypted, nothing silly like that.
Duh, I didn't click that offset needed to be multiplied by the block size.
If I go to offset 4660742*4096=19090399232 in wxhexeditor, indeed I see the file contents:
Final conclusion:
After some more testing, I have concluded: you cannot easily calculate the offset using the inode. Finding files across the disk requires using the inode tables to get the offset and actual file location. So an inode does not correlate with a physical/logical sequential disk location.
I created a new file, it received inode 21, but the offset was smaller than inode 19.
Was that a good use of 3 hours of my life? Well... I still have no idea what's up with the Kardashians, so.. I guess?
Luthis, you're doing God's work here. You are learning by experimentation and then, importantly, documenting and sharing what you've learned. There is absolutely zero wrong and only good to be had in either of those and in combining them, you're doing service to our entire community.
Not much related, but I want to chime in to express my gratitude for what I consider the most underrated piece of software in the FOSS ecosystem. Better known hex editors pale in comparison to wxHexEditor in terms of features and user interface. I suggest you to tweak the colors for better viewing (I can share my configuration file) and to upgrade to the latest unstable revision because many important fixes landed since the last stable version.