If a hdd bad sector happens in the metadata for /home/user/me
on an ext4
fs would that mean data loss for all subdirectories?
Background:
I know that many users are satisfied with the ext4 filesystem, and are even reluctant to change to more "recently" developed alternatives (e.g. BTRFS), claiming increased risk of data loss. Indeed when regarding the time the code for ext4 is around today some results to find bugs speak.
With this introduction, my question is:
What is the resistence that ext4
filesystem has against a bad sector from a block device. A bad sector could swallow 4K bytes, which I imagine to "wreak havoc" if those 4K happen to swallow some directory information high up in the direcotry structure (i.e. /home/user/me
directory).
I am aware that superblocks (being even more basic source of information are kept in a redundant form in ext4, so I imaging a bad block would be repairable there, I am though unsure if it would be automatically dedected)
So my question: Can ext4 resists loosing Bad block in its meta data?
I am aware that a bad block in the data/files content will always mean loosing those 512/4K sector (however I am using parchive as a remedy there).
Best Answer
After some investigation into the matter "if
ext4
can handle a read error from a block devices" my preliminary conclusion is: only partially redundance exists in ext4Here are some findings of my "look into"
ext4
's "safety featurs" (based on Ext4 wiki and "Inode Structure in EXT4 filesystem" )ext4
stores file contents "data blocks" and filesystem "meta-data blocks" separately. To the best of my understandingext4
takes only provisions for some repair/redundancy with regards to latter.ext4
superblockblock group descriptors
information.ext4
feature is hence protected that supercedes in part the older Indirect Block Addressing (IBA) ), the older IBA blocks are not, as is stated:What ext4 can hence recover from on unreadable disc sector (512/4K)
filespec
<inode-number>
indebuge2fs
.inode table
. Each entry in the inode table (the table being split up and the parts being writen into the Block groups that form theext4
disk layout) occupies (padded) 256 bytes. Hence a unreadable sector should mean the loss of 2 to 16 files only. Additionally With the checksum features any corruption within the inode table should be if not necessarily correctable, however not go unnotices.What are bad sector induced troubles
ext4
seems not to protect againstadditionally methods used
in order to test and prove some of the enumerated challenges with the
ext4
disk layout (in regards to its resistance to bad sectors) the following tools are handydebugfs <blockdev>
which allows accessing files via filespec (either filepath, or in case of problems via inode number in< >
)truncate
,dd
,losetup
,mount
andmkfs.ext4
to createext4
filesystems to play with.dumpe2fs
,tune2fs
which provide informationdm-setup
to assemble a virtual block device simulating a read error like this: where as the exmample shows the block device sector is 512 andext4
block size is 1024 hence and hence the LBA sector 2902,2903 are unreadable.