I'm trying to dump our online backups to tape; for obvious reasons I want to encrypt the data on the tapes, so to write to the tape I need to tar everything up, pipe that to openssl to encrypt it, then write that to tape:

tar c /etc | openssl aes-128-cbc -salt -pass "pass:Test123" | dd of=/dev/nst0

However it appears the dd doesn't like this. Writing directly to the tape from tar works fine:

svr-bup1 # tar cf /dev/nst0  /etc
tar: Removing leading `/' from member names
svr-bup1 #

Adding dd into the chain and it breaks:

svr-bup1 # tar c /etc | dd of=/dev/nst0
tar: /dev/nst0: Cannot open: Device or resource busy
tar: Error is not recoverable: exiting now
0+0 records in
0+0 records out
0 bytes (0 B) copied, 9.6274e-05 s, 0.0 kB/s

The same happens with and without the openssl command; I omitted it above to simplify the testing.

mt commands work fine (with env variable TAPE set):

svr-bup1 # mt status
SCSI 2 tape drive:
File number=6, block number=0, partition=0.
Tape block size 0 bytes. Density code 0x46 (LTO-4).
Soft error count since last status=0
General status bits on (81010000):
svr-bup1 # mt rewi
svr-bup1 # 

Hardware is a HP 1720 LTO4 SAS drive using the mpt2sas driver on CentOS 6.


Your version of tar appears to be trying to write to the tape device by default, rather than standard output. It appears to be GNU tar. Autodetecting the tape drive was the default before version 1.11.5 of GNU tar and I suspect you have such an old version. Versions of tar on other UNIX systems may also attempt to write to the tape device by default.

Force tar to write to stdout by specifying the file -:

tar cf - /etc | dd of=/dev/nst0
| improve this answer | |
  • I should have thought of forcing output to stdout; Thank-you very much :) – fukawi2 Apr 1 '14 at 4:36

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.