Subject: Re: bug#17149: shred - tape data

From: Pádraig Brady <[email-masked]>
Date: Mon, 31 Mar 2014 18:32:32 +0100

On 03/31/2014 12:00 PM, Rupert Russell wrote:
> Hi,
> 
> shred -v /dev/st0    # where /dev/st0 is the drive in a multi tape carousel.
> 
> This starts well with.
> Pass 1/4 (random) 15MiB
> Pass 1/4 (random) 41MiB
> Pass 1/4 (random) 70MiB
> Pass 1/4 (random).....etc
> 
> But when the end of a 200GiB tape is reached in pass 1, 'shred' doesn't appear to trigger a rewind or maybe wait for the tape to be rewound before attempting to overwrite the data.
> 
> 
> The final messages before and around the error are:-
> 
> Pass 1/4 (random) 190GiB/190GiB  100%
> 
> Pass 2/4 (random)
> 
> Error writing at offset 1288. No space left on device.
> 
> (The next line in my script then runs and unloads the tape.)
> 
> Is this not rewinding the tape a bug or my mis-use of the 'shred' command?

shred(1) doesn't rewind the tape.

It could issue an MTREW ioctl or something,
though I suspect there are all sorts of ioctls to consider depending on plaftorm.

I also see the `mt erase` command/ioctl which might suffice?

If not then explicitly handling the tape like this might suffice?

for i in $(seq 3); do
  mt -f /dev/st0 rewind
  shred -n1 /dev/st0
done

thanks,
Pádraig.