coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fwd: unexpected error w/ dd


From: Eric Blake
Subject: Re: Fwd: unexpected error w/ dd
Date: Tue, 22 Nov 2016 10:59:48 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0

On 11/22/2016 10:45 AM, Billy Crook wrote:
> Pardon my html email, but the inline attached images are relevant.

Please don't do that again. The mailing list server multiplies your 890k
into many megabytes of wasted traffic to all subscribers of the list.
It is possible to capture just the text of your terminal session, rather
than a graphical screenshot, while still conveying just as much
information in a lot less space.

> 
> I am trying to use dd to zero the (first and) last 512MB of a range of
> partitions on a range of disks.  The blocksizes vary, and I put together a
> one-liner which I thought should do the trick, but it doesn't.
> 
> i specify a bs to match the partition's block size as reported by blockdev
> --getbsz.  I specify a seek= that is less than the number of blocks that
> blockdev --getsz reports.  I should think this would begin writing before
> the end of the partition and continue until the end.  But instead, I
> receive "cannot seek: invalid argument" (0b copied)
> 
> What am I doing wrong?

I'm replying only to the plain text portion of the email, and a
transcription of the smallest of the three images:

> sh-4.2# blockdev --getbsz /dev/sdt2
> 1024
> sh-4.2# blockdev --getsz /dev/sdt2
> 19531873694
> sh-4.2# dd if=/dev/zero of=/dev/sdt2 bs=1024 seek=19531361694
> dd: '/dev/sdt2': cannot seek: Invalid argument
> 0+0 records in
> 0+0 records out
> 0 bytes (0 B) copied, 0.000402845 s, 0.0 kB/s
> sh-4.2#

You are asking dd to seek to the 19531361694th block of 1024 bytes
(setting bs implies that you set both ibs and obs), but your device does
not have that many blocks.  Because you are attempting to seek 1023
times beyond the end of the file, the kernel is complaining that you did
an invalid seek, and hence dd gives up.

Try it on something smaller to see what is happening:

$ seq 5 > f
$ yes 0 | head -c 10 > g
$ # now f and g both have 10 bytes
$ dd if=f of=g bs=2 seek=4
5+0 records in
5+0 records out
10 bytes copied, 0.000108328 s, 92.3 kB/s
$ cat g
0
0
0
0
1
2
3
4
5
$

So I basically started copying f into g at a position of 4 blocks into
g, where I defined the size of g's blocks as 2 bytes each.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]