admin:linux:hdd

Hard Disk Drives under Linux

turn off disk (sleep mode) hdparm -Y /dev/sdX or udisksctl power-off -b /dev/sdX
remove disk from system[(this means that it's not detected anymore and you need to turn it off and on again for it to appear in the Kernel's list of block devices)] echo 1 | sudo tee /sys/block/sdc/device/delete
check power status (might wake up the disk) smartctl -i -n standby or hdparm -C[(hdparm -C is reported to be more likely to wake up the disk)]

Since badblocks was originally written to verify floppy disks, its design isn’t construed for modern HDD drives. With sizes such as 18 TB drives, even the regular tip to use -b 4096 won’t help anymore. This is an alternative: Span a crypto layer above the device:[(https://wiki.archlinux.org/title/Badblocks)]

# cryptsetup open /dev/device name --type plain --cipher aes-xts-plain64

Fill the now opened decrypted layer with zeroes, which get written as encrypted data:

# shred -v -n 0 -z /dev/mapper/name

Compare fresh zeroes with the decrypted layer:

# cmp -b /dev/zero /dev/mapper/name

If it just stops with a message about end of file, the drive is fine. This method is also way faster than badblocks even with a single pass.[(https://wiki.archlinux.org/title/Badblocks)]

  • Last modified: 2023-08-26 18:23