Gentoo Archives: gentoo-user

From: Grant Edwards <grant.b.edwards@×××××.com>
To: gentoo-user@l.g.o
Subject: [gentoo-user] Re: e2fsck -c when bad blocks are in existing file?
Date: Tue, 08 Nov 2022 14:28:16
Message-Id: tkdp1i$1v2$1@ciao.gmane.io
In Reply to: Re: [gentoo-user] e2fsck -c when bad blocks are in existing file? by Michael
1 On 2022-11-08, Michael <confabulate@××××××××.com> wrote:
2 > On Tuesday, 8 November 2022 03:31:07 GMT Grant Edwards wrote:
3 >> I've got an SSD that's failing, and I'd like to know what files
4 >> contain bad blocks so that I don't attempt to copy them to the
5 >> replacement disk.
6 >>
7 >> According to e2fsck(8):
8 >>
9 >> -c This option causes e2fsck to use badblocks(8) program to do
10 >> a read-only scan of the device in order to find any bad blocks. If any
11 >> bad blocks are found, they are added to the bad block inode to prevent
12 >> them from being allocated to a file or directory. If this option is
13 >> specified twice, then the bad block scan will be done using a
14 >> non-destructive read-write test.
15 >>
16 >> What happens when the bad block is _already_allocated_ to a file?
17
18 > Previously allocated to a file and now re-allocated or not, my understanding
19 > is with spinning disks the data in a bad block stays there unless you've dd'ed
20 > some zeros over it. Even then read or write operations could fail if the
21 > block is too far gone.[1] Some data recovery applications will try to read
22 > data off a bad block in different patterns to retrieve what's there. Once the
23 > bad block is categorized as such it won't be used by the filesystem to write
24 > new data to it again.
25
26 Thanks. I guess I should have been more specific in my question.
27
28 What does e2fsck -c do to the filesystem structure when it discovers a
29 bad block that is already allocated to an existing inode?
30
31 Is the inode's chain of block groups left as is -- still containing
32 the bad block that (according to the man page) "has been added to the
33 bad block inode"? Presumably not, since a block can't be allocated to
34 two different inodes.
35
36 Is the "broken" file split into two chunks (before/after the bad
37 block) and moved to the lost-and-found?
38
39 Is the man page's description only correct when the bad block is
40 currently unallocated?
41
42 --
43 Grant

Replies

Subject Author
RE: [gentoo-user] Re: e2fsck -c when bad blocks are in existing file? Laurence Perkins <lperkins@×××××××.net>