Reputation: 1221
I want to use dd to write data starting from a specific location (basically skip the first 50000 bytes ) on a disk and start writing after the first 50000 bytes. I tried doing this
dd of=/dev/disk1 if=/dev/random seek=50000
I let the above line run for few mins and then when I cancel it out, I get this
0+6 records in
0+0 records out
0 bytes (0 B) copied, 79.2458 s, 0.0 kB/s
Looks to me nothing got copied. Am I doing anything wrong ?
Upvotes: 9
Views: 23305
Reputation: 97968
From dd docs:
‘seek=n’
Skip n ‘obs’-byte blocks in the output file before copying.
if ‘oflag=seek_bytes’ is specified, n is interpreted as a byte
count rather than a block count.
So it looks like you want this:
dd of=/dev/disk1 if=/dev/random obs=50000 seek=1
Or this:
dd of=/dev/disk1 if=/dev/random oflag=seek_bytes seek=50000
Another thing is that /dev/random
will block if kernel pool is empty. You can try /dev/urandom
instead, which will use other methods to generate a number without blocking when the pool is empty:
dd of=/dev/disk1 if=/dev/urandom oflag=seek_bytes seek=50000
Upvotes: 15