Re: [question] What happens when dd writes data to a missing device?
From: Douglas Gilbert
Date: Sun Oct 11 2020 - 22:06:23 EST
On 2020-10-11 3:46 p.m., Mikhail Gavrilov wrote:
Hi folks!
I have a question.
What happens when dd writes data to a missing device?
For example:
# dd if=/home/mikhail/Downloads/Fedora-Workstation-Live-x86_64-Rawhide-20201010.n.0.iso
of=/dev/adb
Today I and wrongly entered /dev/adb instead of /dev/sdb,
and what my surprise was when the data began to be written to the
/dev/adb device without errors.
But my surprise was even greater when cat /dev/adb started to display
the written data.
I have a question:
Where the data was written and could it damage the stored data in
memory or on disk?
Others have answered your direct question.
You may find 'oflag=nocreat' helpful if you (or others) do _not_ want
a regular file created in /dev ; for example: if you have misspelt a
device name.
That flag may also be helpful in unstable systems (e.g. where device
nodes are disappearing and re-appearing) as it can be a real pain
if you manage to create a regular file with a name like /dev/sdc when
the disk usually occupying that node is temporarily offline. When
that disk comes back online then regular file '/dev/sdc' will stop
device node '/dev/sdc' from being created.
The solution is to remove the regular file /dev/sdc and you probably
need to power cycle that disk. If this becomes a regular event then
'oflag=nocreat' is your friend [see 'man dd' for a little more
information, it really should be expanded].
Doug Gilbert