Timeline for When is dd suitable for copying data? (or, when are read() and write() partial)
Current License: CC BY-SA 3.0
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jul 25, 2011 at 23:49 | comment | added | psusi | @Gilles my mistake. I was thinking O_DIRECT, which does require block size and alignment. At any rate, dd is safe to use between two block devices without the fullblock flag ;) | |
| Jul 25, 2011 at 17:22 | comment | added | Gilles 'SO- stop being evil' |
No, there is no “appropriate block size”. cat picks a buffer size for performance; it doesn't get any device-related information from the kernel. Apart from tapes, you can read() and write() to a block device with any size. On Linux at least, st_blksize depends only on the filesystem where the block device inode is located, not on the underlying device.
|
|
| Jul 25, 2011 at 15:51 | comment | added | psusi | @Gilles that is because cat uses the appropriate block size, as OrbWeaver noted in his answer. | |
| Jul 25, 2011 at 15:00 | comment | added | Gilles 'SO- stop being evil' |
Apart from tapes, the block size of a device is purely for the kernel to care about, or not. cat </dev/sda >/dev/sdb works just fine to clone a disk.
|
|
| Jul 25, 2011 at 14:57 | comment | added | psusi | @Gilles that sounds like a different issue entirely. You always have to use a multiple of the proper block size with block devices. I am pretty sure it is true of all unicies, and it is also true for Windows. | |
| Jul 25, 2011 at 14:47 | comment | added | Gilles 'SO- stop being evil' |
Is that true of all modern unices? (I know it wasn't true of Linux at some point, possibly up to 2.0.x or 2.2.x. I rembember mke2fs failing silently because it called write() with some non-power-of-2 size (3kB IIRC) and the kernel rounded down to a power of 2.)
|
|
| Jul 25, 2011 at 14:29 | history | answered | psusi | CC BY-SA 3.0 |