5

I am trying to read from the disk and wanted to dd command to issue every request random and check for the latency of the disk for the read operation I have used seek and skip both will that work ?

dd if=/dev/rdsk/c2t5000CCA0284F36A4d0 skip=10  of=/dev/null bs=4k count=1024000
1024000+0 records in
1024000+0 records out
4194304000 bytes (4.2 GB) copied, 51.0287 s, 82.2 MB/s


dd if=/dev/rdsk/c2t5000CCA0284F36A4d0  seek=10  of=/dev/null bs=4k count=1024000
1024000+0 records in
1024000+0 records out
4194304000 bytes (4.2 GB) copied, 51.364 s, 81.7 MB/s

can anybody suggest me with any new way to read from the disk ?

15

skip (also known as iseek in some dd implementations) moves current pointer of the input stream while seek moves current pointer in the output stream.

Thus, by using skip you could ignore some data at the beginning of the input stream.

The seek is usually used (but not always) in conjunction with conv=notrunc to preserve some data existing at the beginning of the output stream.

5

From the man page of dd

seek=BLOCKS
skip BLOCKS obs-sized blocks at start of output
skip=BLOCKS
skip BLOCKS ibs-sized blocks at start of input

That can be rephrased as,

seek skips n blocks from the beginning of the output file.

skip skips n blocks from the beginning of the input file.

0

The following example first prepares an input file and an output file, then copies a portion of the input into a portion of the output file.

echo     "IGNORE:My Dear Friend:IGNORE"      > infile
echo "Keep this, OVERWRITE THIS, keep this." > outfile
cat infile
cat outfile
echo
dd status=none \
   bs=1 \
   if=infile \
   skip=7 \
   count=14 \
   of=outfile \
   conv=notrunc \
   seek=11

cat outfile

The arguments to dd are:

status=none  Don't output final statistics as dd usually does - would disturb the demo
bs=1         All the following numbers are counts of bytes -- i.e., 1-byte blocks.
if=infile    The input file
skip=7       Ignore the first 7 bytes of input (skip "IGNORE:")
count=14     Transfer 14 bytes from input to output
of=outfile   What file to write into
conv=notrunc Don't delete old contents of the output file before writing.
seek=11      Don't overwrite the first 11 bytes of the output file
             i.e., leave them in place and start writing after them

The result of running the script is:

IGNORE:My Dear Friend:IGNORE
Keep this, OVERWRITE THIS, keep this.

Keep this, My Dear Friend, keep this.

What would happen if you exchanged the values of 'skip' and 'seek'? dd would copy the wrong part of the input and overwrite the wrong part of the output file:

Keep thear Friend:IGNTHIS, keep this.

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.