-1

How to confirm dd does Not erase the bad blocks list made by e2fsck ?

An old 1500 GB HDD (hard disk drive), without data,
took about 33 hours (1932 minutes) to run this command:

time sudo e2fsck -c -c -k -C 0 /dev/sda1

output

e2fsck 1.46.5 (30-Dec-2021) 
Checking for bad blocks (non-destructive read-write test) 
Testing with random pattern: done                                                  
_1500G_GEXT4: Updating bad block inode. 
Pass 1: Checking inodes, blocks, and sizes 
Pass 2: Checking directory structure                                            
Pass 3: Checking directory connectivity 
Pass 4: Checking reference counts 
Pass 5: Checking group summary information                                      
                                                                               
_1500G_GEXT4: ***** FILE SYSTEM WAS MODIFIED ***** 
_1500G_GEXT4: 11/91578368 files (0.0% non-contiguous), 6031026/366284288 blocks 

real    1932m4.759s 
user    0m2.296s 
sys     0m7.618s

time sudo e2fsck -c -c -k -C 0 /dev/sda1

-c use badblocks(8) program to do a read-only scan

second -c makes it do a non-destructive write+read test,
External Hard Drive bad sectors recover/mark utility in linux

-k When combined with the -c option, any existing bad blocks in the bad blocks list are preserved, and any new bad blocks found by running badblocks(8) will be added to the existing bad blocks list.

-C fd
-C 0 progress of the file system check can be monitored

see man e2fsck

said differently:
Would doing a dd command erase what took 33 hours to achieve?
Does a dd command erase the bad blocks list?
How to confirm dd does Not erase the bad blocks list made by e2fsck ?

A dd command means one or both:
time sudo dd if=/dev/urandom of=/dev/sd_ bs=64K status=progress
time sudo dd if=/dev/zero of=/dev/sd_ bs=64K status=progress

details:

lsblk -ae7 -oType,name,path,size,fsuse%,tran,pttype,fstype,label,partlabel,mountpoints |grep 'sda\|MOUNT'   

TYPE NAME        PATH             SIZE FSUSE% TRAN   PTTYPE FSTYPE LABEL        PARTLABEL            MOUNTPOINTS  
disk sda         /dev/sda         1.4T        sata   gpt                                              
part └─sda1      /dev/sda1        1.4T               gpt    ext4   _1500G_GEXT4 PART_1   

neofetch --stdout |grep 'OS:'
OS: Kubuntu 22.04.2 LTS x86_64

e2fsck -V
e2fsck 1.46.5 (30-Dec-2021)
Using EXT2FS Library version 1.46.5, 30-Dec-2021

--

joseph22
  • 157
  • 1
  • 9
  • 2
    If in your `dd` commands `sd_` is supposed to mean `sda` or `sda1` then any of the commands will destroy the filesystem (the one you have checked with `e2fsck`) along with the bad block inode `man e2fsck` talks about. Is this the "bad blocks list" you are referring to? Keeping the inode *while* destroying the rest of the filesystem makes no sense. Or do you want `dd` not to touch the defective blocks *themselves*? What do you want to achieve? One sane idea is to backup the files and let `dd` try to overwrite *especially the bad sectors* so the disk reallocates them to spare sectors. – Kamil Maciorowski Jun 17 '23 at 17:59
  • /sd_ = /sda -- Kamil asked, What do you want to achieve? -- Achieve HDD with no errors. No read / write errors. How? What command? That lets disk reallocate errors to spare sectors. If dd is done first and reallocates all errors with ```time sudo dd if=/dev/zero of=/dev/sd_ bs=64K status=progress ``` then disk Partitioned GPT and Formatted Ext4 badblocks should be zero after above dd command. Meaning: ```time sudo e2fsck -c -c -k -C 0 /dev/sda1 ``` or ```time sudo e2fsck -fccky /dev/sd_1 ``` or ```time sudo badblocks -wsv -b 4096 -c 65536 -t 0xff "/dev/sd_"``` – joseph22 Jun 17 '23 at 18:43
  • What's so important about a disk without errors, when the errors don't bother anyone? And this might not be achievable. – harrymc Jun 17 '23 at 18:50
  • "Achieve HDD with no errors." – While keeping the data in place? Or while not caring? Your `e2fsck` command kinda suggests the former; your (future) `dd` commands definitely suggest the latter. – Kamil Maciorowski Jun 17 '23 at 18:51
  • Kamil -- While keeping the data in place? -- No data to worry about. recall post ```An old 1500 GB HDD (hard disk drive), without data, ``` If it can be achieved -- no errors found on disk -- then re-purpose disk. – joseph22 Jun 17 '23 at 19:40
  • harrymc -- What's so important about a disk without errors, -- Disk hangs. Computer slows down or Computer hangs. Disk makes clicking sound. If it can be achieved -- no errors found on disk -- then re-purpose disk. – joseph22 Jun 17 '23 at 19:40
  • 1
    Well, you misled me by using `e2fsck -c -c`. The purpose of it is to make the filesystem aware of bad blocks so it won't use them *in the future*; so as if you planned to *keep using the filesystem*. And since it seems to hold 91578368 files… If you want the disk to reallocate the bad sectors then you want `dd` (or whatever) to try to write to them. – Kamil Maciorowski Jun 17 '23 at 19:52
  • 2
    "Disk makes clicking sound." – Sigh… Too bad you reveal this in a "random" comment. This is the most important information. Not only your question is an [XY problem](https://meta.stackexchange.com/a/66378/355310) (you want the disk without errors but you're asking about `dd` and its alleged interaction with `e2fsck`), but it does not state the symptoms. Most likely the disk is dying. – Kamil Maciorowski Jun 17 '23 at 20:02
  • 2
    This doesn't make any sense. Zero filling using dd should reallocate bad blocks, and yes of course it will undo any flagging of bad blocks at file system level. If this is the approach you're suggesting, it's nonsense. Then we didn't even discuss if it's a good idea trusting a drive like that in the first place. – Joep van Steen Jun 17 '23 at 20:18
  • ```Computer slows down or Computer hangs. Disk makes clicking sound.``` was happening before running command ```time sudo e2fsck -c -c -k -C 0 /dev/sda1``` since running above command for 33 hours the drive is quiet, no clicking sound, hence the question about relationship between ```e2fsck``` and ```dd```. Suggestions? What command to do? – joseph22 Jun 17 '23 at 20:40
  • This question is a train wreck, I vote close. – Joep van Steen Jun 20 '23 at 13:24

2 Answers2

4

What do you want to achieve? -- Achieve HDD with no errors.

That lets disk reallocate errors to spare sectors.

Reallocation of sectors does not heal a dammaged disk. The reallocation process is masking the dammaged sectors up.

What you are doing is effectively window dressing on file system level. When partitioning and formating the disk it will look clean but on firmware level you might have a big mess.

Computer slows down or Computer hangs. Disk makes clicking sound.

The clicking sound is an indication of a hardware issue. All symptoms put together your disk is dying, replace it.

Running ´smartmontools´ to compile SMART information will most likely deliver some additional arguments not to use this disk anymore.

r2d3
  • 3,298
  • 1
  • 8
  • 24
0

You should replace this disk if it is getting bad blocks. Problems will arise in short time.

However solution for you to go around bad blocks is to use dd into file on file system on that disk, not on whole disk. File system will know where are the bad blocks and will go beside them.

pbies
  • 2,757
  • 3
  • 21
  • 23