Hi,

Andrew M.A. Cater wrote:
> > When copying a file and writing it to another medium, perhaps eg when
> > writing a DVD .iso file directly to a USB stick, it's ideal.

The Wanderer wrote:
> Is there really no functional difference between the baseline trivial
> functionalities of cat and dd?

cat and cp cannot do the following:

  # Remove possible GPT backup header from the end of the USB stick
  dd if=/dev/zero of=/dev/sdc bs=512 seek=3915775 count=1 status=none

  # Copy the ISO with its built-in partition table to the USB stick.
  # Show realistic progress messages by curbing the i/o buffering.
  ISO=debian-10.6.0-amd64-netinst.iso
  dd if="$ISO" of=/dev/'sdc' bs=1M status=progress oflag=dsync

With all copy methods one should do before unplugging the stick:

  sync


It should be noted that dd has its special pitfalls. E.g. if the input file
is not a data file or block device, then one should use
  iflag=fullblock
because with some versions of dd there is the risk to get partially read
blocks written as full output blocks.
(I cannot reproduce it right now by
   (echo hello ; sleep 1 ; echo hello) | dd of=dd_target_file obs=512
but i had undesirable results in the past.)


Whatever, the main risk with a short copy command performed by the superuser
is to pick the wrong device file name and thus to overwrite a disk with
valuable content.
I made a cautious (or paranoid) helper script for the task of copying ISOs
to USB sticks:
  https://wiki.debian.org/XorrisoDdTarget

It came too late for the freeze of Debian 11 but is planned to be
available as package in Debian 12. Up to then it can be downloaded from
upstream and verified by its corresponding .sig file:
  gpg --verify xorriso-dd-target.sig xorriso-dd-target


Have a nice day :)

Thomas

Reply via email to