Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> commits every block individually

It uses a syscall per block write (which would slow it down if you use 512 byte blocks instead of 8M for example), but the OS does the file buffering and final writing to the device, unless you pass the fsync or fdatasync options to dd.

Edit:

here's writing to a old and slow stick and you can see that dd is fast and then the OS has to transfer the buffered data onto the stick:

  dd if=some-2GB-data status=progress of=/dev/sdX bs=8M
  1801256960 bytes (1,8 GB, 1,7 GiB) copied, 7 s, 257 MB/s

  0+61631 records in
  0+61631 records out
  2019556352 bytes (2,0 GB, 1,9 GiB) copied, 378,59 s, 5,3 MB/s
And the stick is placed in a USB 3.2. port on a fast machine ;-0


Can also do `oflag=direct` and it'll just skip as much of the caching as it can.


> Can also do `oflag=direct` and it'll just skip as much of the caching as it can.

Correct, and that's one more point for dd compared to head/tail (which are fine commands by themselves).

But wouldn't help much in my example, where I used an (very) old "high speed usb 2.0 stick" with 4 MByte/s write speed to demonstrate the difference between buffering and actual writing.


Thats when it matters, with cat it would cache the entire write. If you don't want it to cache everything and have no idea how much time is left or how fast it is writing, and then wait an hour for it to unmount instead then cat is fine.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: