Open a file in a specific block on Linux

For debugging purposes, I want to open the file on a specific predefined block. For example, if I suspect that a particular block is damaged, I want to write and read it, and I would rather do it in user mode while the section is installed.

Is there a way to say Linux: "Hey, open this new file on block 4579 if it is free."

Yes, I can edit the block device directly, but this can cause the file system to crash if a disk is installed.

General answers are welcome, but even the answer for ext filesystems families is good enough.

+4
source share
1 answer

For example, if I suspect that a particular block is damaged, I want to write and read it ... Is there a way to tell Linux: "Hey, open this new file on block 4579 if it is free."

Yes, you can use the basic block device as a file and search for it in this file. This seems appropriate given your β€œdebugging” option. Please note that writing to this block may destroy the integrity of the file system above (even for writing just read content).

Otherwise, no, file systems are designed to hide , often mask the layout of the device real geometry and as such there is no such mechanism to give clues about where the file should be created.

+2
source

All Articles