I have broken filesystem inside qnap. When I'm trying to fsck, it going into endless loop on one inode. Unfortunately qnap haven't debugfs command. Is this possible to remove (clear) inode via dd?
1 Answers
It's possible but it's highly dangerous. If you screw it up, you could end up doing more damage. The trick is calculating the offset to the particular inode, given the output of dumpe2fs. Once you calculate the offset it's just:
dd if=/dev/zero of=/dev/BLOCKDEVICE seek=OFFSET bs=1 count=INODESIZE
See the source code of debugfs for the function do_imap:
The starting location of the inode table (which is what ext2fs_inode_table_loc() returns) can be found by the output of dumpe2fs, as is the inode size. Once you find the block number and offset, you can use calculate the OFFSET used in the dd command above via:
OFFSET = (block * BLOCKSIZE) + offset
where block and offset is the values as calculated by do_imap.
You may want to practice seeing if you can properly replicate the calculation of do_imap by hand by practicing using dumpe2fs and then cross-checking with debugfs's imap command on your Linux system (assuming you can run Linux).
All of this being said, it might be useful to try compiling e2fsprogs from scratch for qnap, and then using debugfs built for qnap.
- 19,080
- 1,155