How much is 5*1kB?
128Byte as of dd.
% strace -e read,open dd if=/dev/random of=foo bs=1k count=5
open("/dev/random", O_RDONLY|O_LARGEFILE) = 0
read(0, "\347P\203\355\206O;\362f\263v{s\327\206\354\302{\21\5\203"..., 1024) = 96
read(0, "U\16ee\330\304\264@", 1024) = 8
read(0, "\316\26\363\\\26j\377\10", 1024) = 8
read(0, "K\331.\273,\200\4\234", 1024) = 8
read(0, "\2312\323/\304\376\n\261", 1024) = 8
0+5 records in
0+5 records out
128 bytes (128 B) copied, 2.85809 seconds, 0.0 kB/s
Seems 128bytes are quite less than the requested 5kB.
% man 2 read
RETURN VALUE
On success, the number of bytes read is returned (zero indicates end of
file), and the file position is advanced by this number. It is not an
error if this number is smaller than the number of bytes requested; ...
dd_rescue to the rescue
% dd_rescue -m 1k /dev/random foo
Summary for /dev/random -> foo:
dd_rescue: (info): ipos: 1.0k, opos: 1.0k, xferd: 1.0k
errs: 0, errxfer: 0.0k, succxfer: 1.0k
+curr.rate: 0kB/s, avg.rate: 0kB/s, avg.load: 0.0%
% ls -la foo
-rw-r----- 1 einstein einstein 1024 2008-06-15 18:35 foo
At lest dd_rescue is able to count correct.