• Will te UUID or blkid of a device change?

    From Hans@21:1/5 to All on Wed May 22 21:30:01 2024
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Marco Moock@21:1/5 to All on Wed May 22 21:40:01 2024
    Am 22.05.2024 um 21:19:35 Uhr schrieb 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 [email protected]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David Wright@21:1/5 to Hans on Fri May 24 05:40:01 2024
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Thomas Schmitt@21:1/5 to Hans on Fri May 24 08:50:01 2024
    Hi,

    Hans wrote:
    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-............"

    David Wright wrote:
    # 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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)