You are not logged in.

#1 2014-11-04 12:47:52

bzpnbx
Member
Registered: 2014-10-05
Posts: 35

dd: input/output error when preparing drive for dmcrypt/luks

I am following the Wiki to setup full disk encryption on an external hard drive. When I run

dd if=/dev/urandom of=/dev/sda1

I get

dd: writing to '/dev/sda1': Input/output error

Can anyone advise on a way to get the drive filled? Is it still safe to use this drive for dmcrypt/luks setup? I'm unsure how to proceed or what this means for the feasibility of using the drive for what I'm trying to accomplish.

Offline

#2 2014-11-04 12:51:39

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,611
Website

Re: dd: input/output error when preparing drive for dmcrypt/luks

Which wiki page are you following?  I can't find that command listed.  The containers are randomized in one place, but not the partition (as far as I can tell).

But in either case, is the drive partitioned and that partition unmounted?  What is the output of `lsblk`?


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2014-11-04 12:56:55

bzpnbx
Member
Registered: 2014-10-05
Posts: 35

Re: dd: input/output error when preparing drive for dmcrypt/luks

I created an unformatted partition over the entire drive.

next I am to overwrite everything. I'll see if I can find what I read. I followed the exact same procedure on a different drive a few months back and had no problems. i wrote it all out in my notes, step by step, and I am replicating it on a new drive.

Offline

#4 2014-11-04 13:02:45

bzpnbx
Member
Registered: 2014-10-05
Posts: 35

Re: dd: input/output error when preparing drive for dmcrypt/luks

https://wiki.archlinux.org/index.php/Securely_wipe_disk

Isn't the error do to problems on the hard drive itself? Anyone experienced this before when setting up dmcrypt/luks?

Last edited by bzpnbx (2014-11-04 13:09:41)

Offline

#5 2014-11-04 13:41:41

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,611
Website

Re: dd: input/output error when preparing drive for dmcrypt/luks

That command isn't on that page.  There is a similar command that writes to the device not to a partition.  What about that lsblk output??


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#6 2014-11-04 13:45:05

frostschutz
Member
Registered: 2013-11-15
Posts: 1,425

Re: dd: input/output error when preparing drive for dmcrypt/luks

what's in dmesg after that error occurs?

usually it should say no space left on device (when it finishes)

Note that overwriting a hard disk with this command will take ages. It's faster to use shred -n 1 (for pseudorandom data), or cryptsetup luksFormat, luksOpen, zero the encryption device (resulting in "random" encrypted data on the disk), luksClose and finally luksFormat again for a new encryption key so cleartext is not zero either.

also when using dd you should really use a larger blocksize, like bs=64k, or bs=1M for human-readable (x blocks = x MiB).

Last edited by frostschutz (2014-11-04 13:45:26)

Offline

#7 2014-11-04 13:45:18

bzpnbx
Member
Registered: 2014-10-05
Posts: 35

Re: dd: input/output error when preparing drive for dmcrypt/luks

Trilby wrote:

That command isn't on that page.  There is a similar command that writes to the device not to a partition.

???

Do you mean

# dd if=/dev/urandom of=/dev/sdX

I copied above from the page.

Offline

#8 2014-11-04 13:46:05

bzpnbx
Member
Registered: 2014-10-05
Posts: 35

Re: dd: input/output error when preparing drive for dmcrypt/luks

frostschutz wrote:

also when using dd you should really use a larger blocksize, like bs=64k, or bs=1M for human-readable (x blocks = x MiB).

fdisk -l shows it uses the default 512

Offline

#9 2014-11-04 13:50:13

bzpnbx
Member
Registered: 2014-10-05
Posts: 35

Re: dd: input/output error when preparing drive for dmcrypt/luks

lsblk

the external drive shows as:

NAME     MAJ:MIN     RM      TYPE
sdb                8:16          0          disk
|_sdb1          8:17          0          part

Offline

#10 2014-11-04 13:53:10

bzpnbx
Member
Registered: 2014-10-05
Posts: 35

Re: dd: input/output error when preparing drive for dmcrypt/luks

dmesg output for the external drive is full of below errors:

Buffer I/O error
lost page write due to I/O error

Offline

#11 2014-11-04 14:01:08

frostschutz
Member
Registered: 2013-11-15
Posts: 1,425

Re: dd: input/output error when preparing drive for dmcrypt/luks

bs= of dd is not about physical blocksize of a hdd...

so it's sdb and not sda?

what does ls -lh /dev/sd* show?

if you used a wrong name, you filled your devtmpfs with crap, instead of actually writing to a device

if you get errors writing to a device, you have a hardware issue

Last edited by frostschutz (2014-11-04 14:01:27)

Offline

#12 2014-11-04 14:14:34

bzpnbx
Member
Registered: 2014-10-05
Posts: 35

Re: dd: input/output error when preparing drive for dmcrypt/luks

frostschutz wrote:

if you get errors writing to a device, you have a hardware issue

Yes, it is a hardware issue. I'm sorry if I didn't make this clear enough in my original post. I'm seeking guidance on if there is a work around for this hardware issue and/or if the hardware issue creates "security problems" because parts of the disk can't be overwritten. Do you recommend scrapping the drive? Is there something I can do to correct for the hardware problems, that sort of thing.

Offline

#13 2014-11-04 14:26:30

frostschutz
Member
Registered: 2013-11-15
Posts: 1,425

Re: dd: input/output error when preparing drive for dmcrypt/luks

You could check SMART data of the device (smartctl -a /dev/sda). If it has bad sectors (reallocated/pending/uncorrectable), get a replacement. Otherwise it could also be an issue with cables / power supply / etc.

Offline

#14 2014-11-04 14:32:27

bzpnbx
Member
Registered: 2014-10-05
Posts: 35

Re: dd: input/output error when preparing drive for dmcrypt/luks

It has bad sectors. It's not a very old drive either. Just wanted to check if you guys recommended scrapping the drive or if there was still a way to use it.

Offline

#15 2014-11-04 14:50:01

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,611
Website

Re: dd: input/output error when preparing drive for dmcrypt/luks

As you've just quoted, the wiki says to use that command with /dev/sdX like /dev/sda.  This is to write to the device.  You are using /dev/sda1 trying to write to the partition.  This is not suggested in the wiki.

Also please answer *all* the questions posed to you (and learn to edit posts rather than posting 4-5 posts in series).  I asked for lsblk output.  Then I had to ask for it again.  Then you gave me only *part* of the output, and not the relevant part!  If you refuse to cooperate, no one here will be able to help you (let alone want to).


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#16 2014-11-04 15:11:39

bzpnbx
Member
Registered: 2014-10-05
Posts: 35

Re: dd: input/output error when preparing drive for dmcrypt/luks

here's the entire output of lsblk:

NAME          MAJ:MIN          RM          SIZE          RO          TYPE          MOUNTPOINT
sda                 8:0                        0              298.6G     0            disk
   sda5             8:5                       0            3.7G          0            part            [SWAP]
   sda6             8:6                       0             8.4G        0              part           /     
sdb                   8:16                    0            465.8G      0             disk
  sdb1               8:17                   0             465.8G        0          part

sdb is the external drive.

Offline

#17 2014-11-04 15:12:26

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,611
Website

Re: dd: input/output error when preparing drive for dmcrypt/luks

You're trying to write to sda1, there is no such partition.  That is likely why it fails.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#18 2014-11-04 15:34:31

bzpnbx
Member
Registered: 2014-10-05
Posts: 35

Re: dd: input/output error when preparing drive for dmcrypt/luks

Trilby wrote:

You're trying to write to sda1, there is no such partition.  That is likely why it fails.

no. it writes fine. I used sda1 earlier because the way it was connected was different. That's why I wasn't putting all that you asked so quickly. I should be using sdX because in all my examples, I'm writing to the correct device, but it's not always receiving the same letter depending on what else I have connected to the computer at the same time.

I'm doing it correctly, to correct target etc. It's the hardware that's the problem.

Offline

#19 2014-11-04 15:37:12

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,611
Website

Re: dd: input/output error when preparing drive for dmcrypt/luks

bzpnbx wrote:

I'm doing it correctly ...

Eh .. ok, then why ask here.  Good luck finding help.  I give up.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#20 2014-11-04 16:05:56

bzpnbx
Member
Registered: 2014-10-05
Posts: 35

Re: dd: input/output error when preparing drive for dmcrypt/luks

Trilby wrote:
bzpnbx wrote:

I'm doing it correctly ...

Eh .. ok, then why ask here.  Good luck finding help.  I give up.

I appreciate all the help so far. With utmost respect, I only meant to say that I was aware of the change in device names. The help I was hoping for was in how to solve or manage the hardware problems with the drive.


"It has bad sectors. It's not a very old drive either. Just wanted to check if you guys recommended scrapping the drive or if there was still a way to use it."

Offline

Board footer

Powered by FluxBB