1

I'm trying to write random data over a partition on my local hard disk. I'm booted into a recovery live CD (Clonezilla) and have tried the following:

$ dd if=/dev/urandom bs=1024 count=4 | base64 | \
    sudo cryptsetup plainOpen --key-file - /dev/sda5 rando
$ dd if=/dev/zero | pv -ptra | sudo dd of=/dev/mapper/rando

In laymans terms:

  1. Open /dev/sda5 as a plain encrypted disk with a random passphrase. (ie: initialize an AES cipher with a random key)
  2. Fill the virtual disk with zeroes, meaning that the underlying media is filled with random data, effectively filling the disk with random data for reasons™.

This fails at around 250GiB, and the partition is around 512GiB in size.

I've also tried the good old:

$ sudo dd if=/dev/urandom of=/dev/sda5 bs=4096

and it also fails at about 250GiB. I've tried resuming the overwriting later on with seek, but it also fails again.

I'm thinking this is a disk issue, but I have no way of validating this. Is there a tool that will confirm my suspicions and figure out which sectors are failing?

  • Why not simply dd if=/dev/urandom of=/dev/sda5? What is the error message? What is in the kernel log (dmesg | tail -n 20)? – Hauke Laging Jan 8 '16 at 7:38
  • 1
    @HaukeLaging The first way I did it results in a faster write that isn't as CPU-bound. Running things through a defined AES cipher is much faster than /dev/urandom. Both fail. blk-update_request: I/O error, dev sda, sector N and other bad things come out of dmesg. – Naftuli Kay Jan 8 '16 at 7:39
  • Can you paste your error output? Also you might want to try to run fsck to check your filesystem. – gardenhead Jan 8 '16 at 8:16
  • There is no filesystem, I'm writing to an empty partition. There are disk I/O errors. At this point I just want to zero everything out that I possibly can. – Naftuli Kay Jan 8 '16 at 8:39
0

If the disk is not completely failing and there are just a few damaged sectors then you can try to repair them with

hdparm --write-sector

using the sector numbers from dmesg. You may also use smartctl to have a look at the drive's self-test data or start self-tests.

  • Okay, so if this disk is toast, is there a way to zero out the disk, skipping bad sectors and completing no matter what? – Naftuli Kay Jan 8 '16 at 7:49
  • You can make dd ignore read errors; I am not aware of a way to make it ignore write errors. But every time dd aborts you can get the next defective sector from dmesg and skip this sector. – Hauke Laging Jan 8 '16 at 7:54
  • 1
    @NaftuliTzviKay - You can zero out the disk using hdparm's secure erase facility. Make sure it's connected to your SATA/SCSI/IDE cable and not USB though as the latter can cause issues. Note that this will zero the whole disk - not just a partition. – garethTheRed Jan 8 '16 at 8:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.