Discussion:
Will te UUID or blkid of a device change?
(too old to reply)
Hans
2024-05-22 19:30:01 UTC
Permalink
Hi folks,

just aquestion.

I am booting a lie system from USB-stick. In this live system I am creating an
ISO-file, which I then want to dd onto another USB-stick.

As I am doing this with a script, I want to make sure, that the correct USB-
stick is used.

Thus I can do by using the UUID of the target stick like

dd if=/path/to/myfile.iso of=UUID="123456-abcd-............"

This is working. Now my question:

Whenever I dd to the target stick, does the UUID change? I know, the UUID of
the partitions are changing, but what is with the device itself?

Or is there a better way? Maybe by using a label? I read also about blkid, but
does this change, too when dd to the device?

At all, is my idea possible at all or are ALL UUIDs changing, whenever I do a
dd? If yes, then how can this be prohibited, if any.

Thanks for any help.

Best

Hans
Marco Moock
2024-05-22 19:40:01 UTC
Permalink
Post by Hans
Whenever I dd to the target stick, does the UUID change? I know, the
UUID of the partitions are changing, but what is with the device
itself?
No. The UUID is part of the file system and will just be copied.
Mounting based on the UUID will be ambiguous in that case, so you
should generate a new UUID for each file system that supports that.
Be aware that in a GPT the disk itself has a GUID and each partition a
PART-UUID that you maybe also want to change.
--
Gruß
Marco

Send unsolicited bulk mail to ***@cartoonies.org
David Wright
2024-05-24 03:40:01 UTC
Permalink
Post by Hans
I am booting a lie system from USB-stick. In this live system I am creating an
ISO-file, which I then want to dd onto another USB-stick.
Do you want to copy the ISO to a file, a partition, or
the whole device?
Post by Hans
As I am doing this with a script, I want to make sure, that the correct USB-
stick is used.
Thus I can do by using the UUID of the target stick like
I don't know what you mean by the UUID of a USB stick. Could you
paste a command that you suppose prints it, and its output.
Post by Hans
dd if=/path/to/myfile.iso of=UUID="123456-abcd-............"
This is working.
I've never seen a dd command line like that. Can you paste that
command, from the prompt before it to the one after it.
Post by Hans
Whenever I dd to the target stick, does the UUID change? I know, the UUID of
the partitions are changing, but what is with the device itself?
If you copy a filesystem to a partition, the partition's old
filesystem and its UUID will be destroyed, being replaced by the new
filesystem and its UUID. Note that the target partition's UUID
(PARTUUID) and LABEL (PARTLABEL) are not changed, because they are
properties of the partition as a container, not its contents.

If you copy to a device, the old partition structure, its PARTUUIDs,
filesystems, and filesystem UUIDs will all be destroyed, being
overwritten by whatever was copied.¹
Post by Hans
Or is there a better way? Maybe by using a label? I read also about blkid, but
does this change, too when dd to the device?
To identify a device, you could naturally use its id. That is,
unless it's one of those very cheap ones where they all have the
same id: for example, ID_MODEL=UDisk ID_MODEL_ID=1234
ID_SERIAL=General_UDisk-0:0 . I have two like this, and obviously
the computer is unable to distinguish between them except by what
/I/ write onto them.

A device id command line could look something like:

# dd of=/dev/disk/by-id/JetFlash_Transcend_4GB_JKNB2FYG-0:0 … …
Post by Hans
At all, is my idea possible at all or are ALL UUIDs changing, whenever I do a
dd? If yes, then how can this be prohibited, if any.
In view of all the above, your question is vague and ambiguous.
When you "do a dd", what you are doing is copying. What gets changed
depends on what you copy and where to.

I don't know what you mean by prohibitions, beyond what normal unix
permissions allow and disallow.

¹ I'm ignoring any problems caused by old data remnants on the target device.

Cheers,
David.
Thomas Schmitt
2024-05-24 06:50:01 UTC
Permalink
Hi,
Post by David Wright
I want to make sure, that the correct USB-stick is used.
Thus I can do by using the UUID of the target stick like
dd if=/path/to/myfile.iso of=UUID="123456-abcd-............"
# dd of=/dev/disk/by-id/JetFlash_Transcend_4GB_JKNB2FYG-0:0 … …
This is indeed a good solution if the device ID is known and systemd does
not change its way of composing the "by-id" name.
But if you first have to find out the right "by-id" name, then there is
again the risk of user error, especially when in a hurry.


There is a different, interactive approach which depends on the fact that
the Linux kernel creates a new device file when a USB stick is plugged in:

https://packages.debian.org/stable/xorriso-dd-target
https://wiki.debian.org/XorrisoDdTarget

The man page of xorriso-dd-target demonstrates more use cases, like:
- List all devices with reasoning
- Evaluate particular given devices


Have a nice day :)

Thomas

Loading...