4 ms·
In Linux, raw disk devices like /dev/sda1 are cached by kernel (unless opened with O_DIRECT flag). In FreeBSD (and presumably other UNIX implementations) they
by mkup 4y ago
In Linux, raw disk devices like /dev/sda1 are cached by kernel (unless opened with O_DIRECT flag).
In FreeBSD (and presumably other UNIX implementations) they aren't: https://docs.freebsd.org/en/books/arch-handbook/driverbasics/#driverbasics-block https://docs.freebsd.org/en/books/arch-handbook/driverbasics...
So, in FreeBSD "dd if=/dev/ada0p1 of=/dev/null bs=1 count=1" will fail: disk driver will return EINVAL from read(2) because I/O size (1) is not divisible by physical sector size (usually 512). "cat" with buffer size X (which depends on the implementation) will either work or not depending on divisibility of X by physical sector size, and other random factors, like short file I/O caused by delivery of a signal.
Summary: dd(1) still has its place and author of original article is getting it wrong.