-
-
Save mdPlusPlus/30ebddea8d6167b27ef2d07c75e5ebc9 to your computer and use it in GitHub Desktop.
| badblocks -b 4096 -p 0 -s -t 0 -v -w DEVICE [LAST_BLOCK] [FIRST_BLOCK] | |
| -b block_size (4096 only works up to 16TiB drives, consider using 8192 for up to 32TiB, or 16384 for up to 64TiB. Default is 1024) | |
| -c Number of blocks which are tested at a time (Default is 64, consider increasing to speed up the process, 64*4096B=256KiB) | |
| -p num_passes | |
| -s Show the progress of the scan | |
| -t test_pattern | |
| -v Verbose mode | |
| -w Use write-mode test |
A more modern equivalent would look like this:
badblocks -b 16384 -c 512 -p 0 -s -t 0 -v -w DEVICE [LAST_BLOCK] [FIRST_BLOCK]
It writes/reads 512 blocks of 16KiB (so 8MiB) at a time on drives with a capacity of up to 64TiB).
To keep the process running in the background or run multiple processes in parallel:
screen -dmS $NAME badblocks -b 16384 -c 512 -p 0 -s -t 0 -v -w /dev/disk/by-id/$DEVICE_ID -o $NAME.badblocks
See all running screens with screen -ls and reattach to one with screen -r $NAME.
To detach press ctrl+a and then d .
It's also a good idea to run an extended SMART test on new hard drives:
Under root: for d in /dev/disk/by-id/ata-*; do [[ $d == *-part* ]] || smartctl -t long "$d"; done
With sudo: sudo bash -c 'for d in /dev/disk/by-id/ata-*; do [[ $d == *-part* ]] || smartctl -t long "$d" ; done
To check the status: for d in /dev/disk/by-id/ata-*; do [[ $d == *-part* ]] || smartctl -c "$d" | grep -A1 'Self-test execution status'; done
Shows output similar to this:
Checking blocks 0 to 1953512447When cancelled with ctrl+c:
Interrupted at block 284489984To continue:
badblocks -b 4096 -p 0 -s -t 0 -v -w DEVICE 1953512447 284489983