Linux Set the Block Size for a SCSI Tape Device

by on January 9, 2008 · 3 comments· LAST UPDATED January 9, 2008

in , ,

Q. I've Debian Linux 4.0 Install on HP Server. This server has SCSI tape device. According to my tape documentation size should be 64k. How can I set the block size for a HP SCSI tape device?

A. You need to use standard tar or cpio command to set the block size for a SCSI tape device. There is no special setting exists to set the block for a tape.

tar command set block size

The -b option use to set block size. The record size of Nx512 bytes (default is N=20). The following example, set a tape to 256k block to backup /data file system:
# tar -b 512 -cvf /dev/st0 /data
To extract simply use:
# tar -b 512 -xvf /dev/st0
Where,

  • -b 512 Use a blocksize of 512 i.e 512x512bytes
  • c : Create archive
  • v : Verbose (display progress)
  • f : Tape device name /dev/st0
  • x : Extract archive

So to set data transfer block size to 64k (64x64bytes), enter:
# tar -b 128 -cvf /dev/st0 /path/to/backup/directory

See more about mt and tar command for making backups under Linux.

cpio command

Pass the --block-size BLOCK option to cpio command, enter:
# find /home | cpio --block-size 128 -o -H tar -F /dev/nst0
To Restore backup, enter the following command
# cpio --block-size 128 -i -F /dev/nst0

How do I find out tape block size?

Refer to tape manufactures documentation or product web site. However, with the help of dd command (little trial and error) you can find actual blocksize of tape. All you have to do is provide ibs=BLOCKSIZE:
# dd if=/dev/st0 of=/tmp/test.file ibs=64k count=1
Output:

dd: reading `/dev/st0': Cannot allocate memory
0+0 records in
0+0 records out 

If you get an error message, 'Cannot allocate memory', try next blocksize as selected blocksize (64k) is too small:
# dd if=/dev/st0 of=testfile ibs=256k count=1
Output:

1+0 records in
512+0 records out

So 256k is correct block size for this scsi tape device.

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 3 comments… read them below or add one }

1 flash April 12, 2008 at 11:39 pm

However, with the help of dd command (little trial and error) you can find actual blocksize of tape. All you have to do is provide ibs=BLOCKSIZE:
# dd if=/dev/st0 of=/tmp/test.file ibs=256k count=1
1+0 records in
512+0 records out

So 256k is correct block size for this scsi tape device.
===============================
No! 256k is only correct for the tape that was inserted on the drive. The tape device might accept larger block size (2Mb for IBM3592 for example).

Reply

2 c.velu August 17, 2009 at 12:59 pm

what is equal tar command for dd if=/device ibs=28800 of=file obs=28800

Reply

3 MarcusJabber October 16, 2009 at 6:25 pm

I use to command status to see default block size

#mt -f /dev/st0 status

Tape block size 512 bytes …

Reply

Leave a Comment

Tagged as: , , , , , , , , , , , , , , , , , , , , ,

Previous Faq:

Next Faq: