cp file.iso /dev/sda cp file.iso /dev/sda cat foo.img > /dev/sda
works and should be portable. No control over the buffer size, though.Whatever behaviour you’re describing is not how POSIX mandates cp to work. In fact you can do this with busybox too.
cp will open("/dev/sda", O_WRONLY | O_TRUNC) and simply start writing to that file descriptor.
&& sync
not sure why it's necessary only sometimes!If you want to be more targeted:
blockdev --flushbufs /dev/sda