Hi Antonio, > > I should have also asked: is using /dev/null a special value that > > avoids the write(2) system calls, e.g. as shown by 'strace -c'? > > No. Ddrescue does not implement special values. I have not even tested > if avoiding the write calls would speed up the operation significantly > because I think this use case has not been suggested here before.
/dev/null obviously implements write(2) cheaply, but there's still the context switch associated with the system call. A very rough test here: $ f=/boot/initramfs-linux-lts-fallback.img $ stat -c %s $f 30658665 $ $ strace -c tee <$f 2>&1 >/dev/null | sed 4q % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 56.73 0.126982 33 3750 read 43.23 0.096779 25 3743 write $ $ strace -c tee /dev/null <$f 2>&1 >/dev/null | sed 4q % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 59.84 0.194545 25 7486 write 39.70 0.129078 34 3750 read $ The extra writes to /dev/null are adding 0.1 s and that's about 75% of the time taken by all the read()s. (0.126982 + 0.129078) / 2 = 0.12803 # Mean read. 0.194545 - 0.096779 = 0.097766 # Difference write. 0.097766 / 0.12803 = 0.76361790205420604545 # Difference / mean. So it might be a measurable saving to avoid the write()s when scrubbing 1 TB, say. -- Cheers, Ralph.