1

I use dd on Linux to extract data from a tape (yeah it's really oldschool!) and I had a problem. Sometimes, when I extract a file (from different files on one tape), after a really long time and a really big size of the file extract, the extraction is still not finished. So it's a problem because I know that the size of the file is about 10MB and not 1GB or more. I know the number of blocks in the file (4092 for example) so I would like to stop the extraction at this number of blocks. Do you know if it's possible to stop the extraction at 4092 blocks for example?

I have searched for a long time on the Internet and I haven't found a command about this.

I use this command to extract files from a tape:

sudo mt -f /dev/nst0 of=file.out bs=512 conv=noerror,sync
  • use count= parameter - count x bs = total size, see man page – gengisdave Jul 7 '15 at 13:42
1

You can use the "count" option to dd to specify the number of blocks to copy; combined with the blocksize option, "bs", this allows you to control the amount of data being extracted. Note that a smaller blocksize may also result in a longer transfer time, depending on the kind of device.

First position the tape as required, e.g. to block 2048:

mt -f /dev/nst0 setblk 2048

Then use the dd command to read from the relevant device (note: there may be several similar tape devices, check the driver details to find the no-rewind device if you want to subsequently read other files):

sudo dd if=/dev/nst0 of=file.out bs=1024 count=37 conv=noerror,sync

This will read 37 Kilobytes from the starting position of block 2048 in blocks (i.e. buffers) of 1024 bytes each.

  • Thank's a lot ! I will try that ! I didn't think that option could solve my problem... thank's again :) – Lionel Jul 7 '15 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy