[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Will te UUID or blkid of a device change?



On Wed 22 May 2024 at 21:19:35 (+0200), Hans wrote:
> 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?

> 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.

> 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.

> 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?

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.¹

> 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  …  …

> 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.


Reply to: