(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Printer Friendly Version



Best of the Newsgroups: dd block sizes tape compression


What is this stuff?

If this isn't exactly what you wanted, please try our Search (there's a LOT of techy and non-techy stuff here about Linux, Unix, Mac OS X and just computers in general!):



From: Bela Lubkin <belal@sco.com>
Subject: Re: Help with solving an error message on a cpio backup
Date: Fri, 14 May 2004 07:48:22 GMT
Message-ID: <20040514074822.GL10272@sco.com> 
References: <40a2c606@news.iconz.co.nz> <20040513073040.GK10272@sco.com> <40a44208$1@news.iconz.co.nz> 


David Font wrote:



> The user has accepted they bought a from a batch of dud tapes. I sent one of
> my tapes (same brand) and they work.
> 
> However I am experimenting with suggestions to improve throughtput
> efficiency using dd/cpio.
> 
> I currently use similar commands when doing cpio backups on UW711. For
> instance I use obs=64k piped into the dd of=/dev/rct0 command with bs=64k.

I was going to say that this probably didn't work like you thought, but
some tests show that actually it does -- on UW7.  Observe:

  UW7$ dd if=/dev/zero obs=4k count=1024 | dd bs=4k of=junk  
  1024+0 records in
  128+0 records out
  128+0 records in
  128+0 records out
  UW7$ dd if=/dev/zero obs=64k count=1024 | dd bs=64k of=junk  
  1024+0 records in
  8+0 records out
  8+0 records in
  8+0 records out
  UW7$ dd if=/dev/zero obs=128k count=1024 | dd bs=128k of=junk
  1024+0 records in
  4+0 records out
  0+8 records in
  0+8 records out
  OSR5$ dd if=/dev/zero obs=4k count=1024 | dd bs=4k of=junk
  1024+0 records in
  128+0 records out
  128+0 records in
  128+0 records out
  OSR5$ dd if=/dev/zero obs=64k count=1024 | dd bs=64k of=junk
  1024+0 records in
  8+0 records out
  0+64 records in
  0+64 records out
  OSR5$ dd if=/dev/zero obs=128k count=1024 | dd bs=128k of=junk
  1024+0 records in
  4+0 records out
  0+64 records in
  0+64 records out

Each final file was 524288 bytes long.  Notice the status report from
the 2nd `dd` in each example.  Notice that both 4K tests, and the 64K
test on UW7, show "n+0" records in and out.  The UW7 128K test and the
OSR5 64K & 128K tests show "0+n" records in and out.

What's happening is that the size of the kernel pipe buffer on UW7
appears to be 64K, and on OSR5 it is 8K (I mistakenly implied it was 5K
in my previous post).  In both 128K tests, the first `dd` writes 128K at
a time, but those writes get blocked in the middle (when the pipeline
fills).  The reader can read a maximum of one pipe buffer at a time.  On
UW7, that's 64K at a time -- an exact match for the 64K test, but only
half-size reads in the 128K test.  Because ibs and obs are the same, dd
doesn't reblock; it ends up making 8 64K writes.  Those are reported as
"8+0" in the 64K test, but "0+8" in the 128K test: 0 full-sized writes
and 8 partials.

OSR5's 8K pipe buffer is sufficient for the 4K test.  At 64K and 128K we
see "0+64" records.  Dividing the total 512K by 64, we can see that the
pipe buffer is 8K.



All of which goes to show that if you're trying to reblock for efficient
tape access, you can use `dd` this way for sizes up to 64K on UW7, but
only 8K on OSR5.  You can reblock to a larger size by deliberately using
different ibs and obs:

  OSR5$ dd if=/dev/zero count=1024 | dd obs=128k of=junk       
  1024+0 records in
  1024+0 records out
  1024+0 records in
  4+0 records out
  OSR5$ dd if=/dev/zero count=1024 | dd ibs=8k obs=128k of=junk
  1024+0 records in
  1024+0 records out
  10+149 records in
  4+0 records out

In the first example I allowed ibs to be the default 512 bytes.  In the
second example I used 8k.  Notice that the 2nd `dd` says there were 10
complete 8K records, as well as a bunch of partials.  That's due to the
vagaries of process scheduling.  If the writer process got to run
unimpeded for a while, it might have filled the entire 8K pipe buffer.
Then the reader process's 8K read would return a full 8K.  Most of the
time the processes alternate faster than that.

A flaw with this scheme is that if the input isn't an exact multiple of
the obs, the last block will be short:

  OSR5$ dd if=/dev/zero count=1023 | dd obs=128k of=junk       
  1023+0 records in
  1023+0 records out
  1023+0 records in
  3+1 records out

If you were only doing this for performance, that doesn't matter.  If
you were doing it because the tape drive insists on a specific fixed
block size (some do), it's a problem.  Which makes me think that `dd`
should have a flag like "conv=opad" or "conv=osync" that means to pad
that last partial block to the full obs.  But it doesn't.

I'm pretty sure that on OSR5, you'll get more mileage from `tape -a
setblk`.  And even more from a super-tar.

>Bela<






Click here to add your comments



Don't miss responses! Subscribe to Comments by RSS or by Email

Click here to add your comments


If you want a picture to show with your comment, go get a Gravatar



/Bofcusm/2470.html copyright 1997-2004 (various authors) All Rights Reserved

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

Jump to Comments



Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.

Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.

We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.



More:
       - OSR5
       - Bofcusm
       - Bela


Unix/Linux Consultants

Skills Tests

Guest Post Here











My Favorites

Change Congress