Sunday, December 12, 2021

Re: Is it true that `dd` is almost not needed?

"The era of magnetic tapes" has not ended.

It is just that some people mysteriously believe their data is safer "in
the cloud" where they cannot monitor it,
than on a tape in a fire safe under their own supervision. I have read back
tapes I wrote myself 30 years earlier.
Have you tried getting your data back from a deceased "cloud provider"?

That is why we get all these stories of ransomware attacks.

Also, for many of us that have spent half a century learning Unix, we do
not want our well proven tools snatched from our hands.
There is room for more than one knife in a virtual tool box.

On Sat, 11 Dec 2021 at 23:58, Stuart Longland <stuartl@longlandclan.id.au>
wrote:

> On Sat, 11 Dec 2021 18:06:43 +0200
> <uxer@mailo.com> wrote:
>
> > The Cult of DD
> > Mar 17, 2017
> > You'll often see instructions for creating and using disk images on Unix
> > systems making use of the dd command. This is a strange program of
> > [obscure provenance](https://en.wikipedia.org/wiki/Dd_(Unix)) that
> > somehow, still manages to survive in the 21st century.
> >
> > Actually, using dd is almost never necessary, and due to its highly
> > nonstandard syntax is usually just an easy way to mess things up. For
> > instance, you'll see instructions like this asking you to run commands
> > like:
> >
> > […snip…]
> >
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > End of article and my questions:
> >
> > Is the author right in general?
> > Is the author right for Linux environment?
> > Is the author right for OpenBSD environment?
>
> Can `cat`/`tail` et all, create a "sparse" file?
> > vk4msl-gap$ dd if=/dev/zero bs=1M count=1 seek=9 of=sparsefile
> > 1+0 records in
> > 1+0 records out
> > 1048576 bytes transferred in 0.009 secs (108639200 bytes/sec)
> > vk4msl-gap$ ls -lh sparsefile
> > -rw-r--r-- 1 stuartl stuartl 10.0M Dec 12 08:42 sparsefile
> > vk4msl-gap$ du -hs sparsefile
> > 1.0M sparsefile
>
> Very useful for "thin provisioning" of raw disk images with virtual
> machines.
>
> Can `cat`/`tail` et all read bytes from the middle of a file?
> > vk4msl-gap$ echo -n '000102030405060708090a0b0c0d0e0f' > test
> > vk4msl-gap$ dd if=test of=test.part bs=2 skip=4 count=4
> > 4+0 records in
> > 4+0 records out
> > 8 bytes transferred in 0.000 secs (66541 bytes/sec)
> > vk4msl-gap$ cat test.part
> > 04050607
>
> Can `cat`/`tail` et all overwrite specific bytes in the middle of a file?
> > vk4msl-gap$ echo -n 'aaabacad' | dd of=test bs=2 count=4 seek=8
> conv=notrunc
> > 4+0 records in
> > 4+0 records out
> > 8 bytes transferred in 0.000 secs (98985 bytes/sec)
> > vk4msl-gap$ cat test
> > 0001020304050607aaabacad0c0d0e0f
>
> I think you'll find `dd` was written in the era of magnetic tapes as a
> storage medium, and so the ability to seek to a specific part of a tape
> then perform a read or write, was seen as a critical feature of the day.
>
> That same feature is handy when doing various low-level disk operations
> as well (e.g. backing-up/restoring the boot sector/partition table).
> --
> Stuart Longland (aka Redhatter, VK4MSL)
>
> I haven't lost my mind...
> ...it's backed up on a tape somewhere.
>
>

No comments:

Post a Comment