Sample Header Ad - 728x90

Does badblock "fix" blocks on an SD card?

1 vote
2 answers
52 views
I have an old 16GB SD card that started giving I/O errors, known it's gone bad, I dumped all the content to an image file to see what I could restore, and the Disk manager alerted me that 16.1MB were unreadable and replaced with zero. To do some post-mortem autopsy, I ran badblocks -n /dev/sdx (read only analysis). After ~18 hours, it reported 309 blocks as bad. To do some other testing, I erased just the partition table (it was two partitions, FAT32 + ext4) and ran badblocks -w /dev/sdx (read/write analysis). To my surprise, this time it took <6 hours and reported no bad blocks. I ran the read only analysis once again and also reported very quickly no bad sector. How is that possible? I was under the impression that badblocks checks for _physical_ blocks damage, and that in a flash device, if a block is reported as "bad", it's because the flash chip already ran out of space space to replace damaged blocks, but since removing the partition seemingly fixed the issues, it may look like they were some software corruption. After running badblocks these 3 times, I created a new partition table and a new partition, and filling it with data from /dev/zero reported no I/O error whatsoever. From what I can see, these are the possible explanations: * badblocks checks for FS bad blocks and my FS was corrupted, not the SD card flash itself * badblocks somewhat marked these blocks that are now automatically ignored by the hardware controller and/or the FS * the SD card noticed the bad memory area while badblocks was finding them and now replaced them with fresh ones. If so, why didn't it do when I got I/O errors from reading the files? Which one is the more likely?
Asked by Mauro F. (133 rep)
Jul 24, 2025, 10:40 AM
Last activity: Jul 24, 2025, 11:51 AM