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
--
ddcommandssd_is supposed to meansdaorsda1then any of the commands will destroy the filesystem (the one you have checked withe2fsck) along with the bad block inodeman e2fscktalks 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 wantddnot to touch the defective blocks themselves? What do you want to achieve? One sane idea is to backup the files and letddtry to overwrite especially the bad sectors so the disk reallocates them to spare sectors. – Kamil Maciorowski Jun 17 '23 at 17:59Achieve 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=progressthen disk Partitioned GPT and Formatted Ext4 badblocks should be zero after above dd command. Meaning:time sudo e2fsck -c -c -k -C 0 /dev/sda1ortime sudo e2fsck -fccky /dev/sd_1ortime sudo badblocks -wsv -b 4096 -c 65536 -t 0xff "/dev/sd_"– joseph22 Jun 17 '23 at 18:43e2fsckcommand kinda suggests the former; your (future)ddcommands definitely suggest the latter. – Kamil Maciorowski Jun 17 '23 at 18:51An 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:40If it can be achieved -- no errors found on disk -- then re-purpose disk. – joseph22 Jun 17 '23 at 19:40
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 wantdd(or whatever) to try to write to them. – Kamil Maciorowski Jun 17 '23 at 19:52ddand its alleged interaction withe2fsck), but it does not state the symptoms. Most likely the disk is dying. – Kamil Maciorowski Jun 17 '23 at 20:02Computer slows down or Computer hangs. Disk makes clicking sound.was happening before running commandtime sudo e2fsck -c -c -k -C 0 /dev/sda1since running above command for 33 hours the drive is quiet, no clicking sound, hence the question about relationship betweene2fsckanddd. Suggestions? What command to do? – joseph22 Jun 17 '23 at 20:40