4 ms·
The author neglects to mention any of the use cases where "dd" really is the best alternative. Such as when you need to copy a bootloader from an existing image
by colonwqbang 4y ago
The author neglects to mention any of the use cases where "dd" really is the best alternative. Such as when you need to copy a bootloader from an existing image without damaging your partition table:
# My partition table is in sector 0 and my Linux partition starts at sector 62500
dd if=random-linux-image.img of=/dev/mmcblk0 bs=512 count=62499 seek=1 skip=1
How do you make "cat" seek 512 bytes into its stdout before writing? You can't. And even if you used a temporary file, I think the above is better than a pipeline of "head" and "tail" with uses of $(()) to convert from sector to byte units.
Once you have learned to use the tool in such situations a few times, you mentally start to associate it with "disk operations". So you start to use it also in simpler situations where simpler tools would be sufficient. You start teaching its use to others. I don't think it's that strange, or bad in any way.
- fbn79 4y agoYou can use head as stated in the article: sudo dd if=/dev/sda of=/tmp/boot.1 bs=512 count=1 sudo head -c 512 /dev/sda > /tmp/boot.2 md5sum /tmp/boot.1 06d6f2aa3e7c33ad06282f70aa4e133b /tmp/boot.1 md5sum /tmp/boot.2 06d6f2aa3e7c33ad06282f70aa4e133b /tmp/boot.2
- merlincorey 4y agoYou missed a nuance in the GP's problem set: > dd if=random-linux-image.img of=/dev/mmcblk0 bs=512 count=62499 seek=1 skip=1 is not the same as: > sudo dd if=/dev/sda of=/tmp/boot.1 bs=512 count=1 You are missing the "seek" and "skip" arguments which the GP challenges you to make `head` do.
- fbn79 4y agoYou right. To skip you can pipe tail. sudo head -c 1024 /dev/sda | tail -zc 512 > /tmp/boot.2 Read 1024, keep last 512
- jstimpfle 4y agoWhat if the position is not at 512 but at 512G?
- knorker 4y agoThat "sudo head" only works for reading, not writing though. I use dd when redirect doesn't have permission.
- guenthert 4y agoI've seen tee used for that, but I myself stick to dd (out of habbit or because I belong to said cult).
- asib 4y agoA generous interpretation of the title might be that the author is only writing about those for whom dd is so ingrained in their style that they use it where another command would be more natural, hence they're "cultish".
- deleted 4y ago[deleted]