====== Hard Disk Drives under Linux ======
===== useful oneliners =====
^ 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)] |
===== check for bad sectors =====
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 [[https://www.reddit.com/r/DataHoarder/comments/fbst8m/alternative_to_badblocks/|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)]