Re: [SOLVED] Re: UUID permanent at removable device?
Am Sonntag, 12. November 2023, 19:43:13 CET schrieben Sie: Hi folks, although I already marked my problem as solved, I just want to tell, that I found the best solution for me. Thanks to Andi's hint I am now using /dev/disk/by-id/my_serial for the usb stick. As I am using always the same usb-stick for this purpose, the disk-id will be not changing, of course and can such be used within my little script. Someone told, it is not a good idea, to use partitions within an ISO-file. However, this is not changeable in my case. What I am especially doing, is converting a fully installed kali system into a livesystem (I know, kali is available as live syswtem, but mine has lots of chnages. For exampl,e it is in German, has more installed packages, packages added fron third parties, installed GVM-Plugins, my own configurations and many things more.) My Kali is about 40GB big, and so it would not fit on DVD. The compressed image is about 20GB and fits on a 32 GB stick. Doing so, I habe my fully installed kali available in my pocket. Very happy with this! Beside notes: On my server, all partitions are encrypted, but on the usb-stick after installing thisis no more. Yes, I know, this would be possible on the stick, too, but not necassary as there are no original credentials on it. Thanks to your help, I now can easily create an upgraded system nightly. Everything is exactly as I imagined. And: most important(!) I learned a lot. So, thank you all for your feedback. Best regards Hans
Re: UUID permanent at removable device?
Hi, Hans wrote: > I want to automatically create a bootable USB-stick using dd from an > ISO-file. The landscape of ISO files is wide and varied. An URL for getting the ISO would help to make more specific statements. > However, after generating the stick the UUID of the first partition > (/dev/sdc1) is changing, so next time, the script will not work again, > of course. > But does the UUID also change of the device itself? Does the UUID of > /dev/sdc change, too? The UUID as of program lsblk is a property of the data which is stored on the device, not of the device itself. For example after dd'ing debian-12.0.0-amd64-netinst.iso : $ lsblk -o NAME,UUID /dev/sdc NAME UUID sdc2023-06-10-10-25-55-00 ├─sdc1 2023-06-10-10-25-55-00 └─sdc2 DEB0-0001 Because there is no valid GUID Partition Table in this ISO, the UUIDs are fabricated and don't deserve the attribute "Universially Unique". sdc and sdc1 get the creation date of the ISO 9660 filesystem as Id. sdc2 gets the Volume Serial Number of the FAT filesystem (just 4 bytes) as UUID. It does not look better with PARTUUID instead of UUID: $ lsblk -o NAME,PARTUUID /dev/sdc1 NAME PARTUUID sdc1 23261683-01 The shown id "23261683" is the hex representation of the MBR Disc Signature which has 4 bytes. > I want to dd it automatically like > dd if=/path/to/my/image.iso of=UUID=34567890-afde-.-1234 Consider refering to hardware properties, e.g. by using the symbolic links in /dev/disk/by-id . dd if=/path/to/my/image.iso \ of=/dev/disk/by-id/usb-INTENSO_USB_AA0401287699-0:0 Device link name found by knowing that this time the USB stick is sdc: $ ls -l /dev/disk/by-id ... lrwxrwxrwx 1 root root 9 Nov 12 19:14 usb-INTENSO_USB_AA0401287699-0:0 -> ../../sdc ... Have a nice day :) Thomas
Re: [SOLVED] Re: UUID permanent at removable device?
Hi, On Sun, Nov 12, 2023 at 07:43:13PM +0100, Hans wrote: > Am Sonntag, 12. November 2023, 19:27:20 CET schrieb Andy Smith: > Yes, this is looking promising. Looks like thisis what I exactly need. I am still intrigued by the idea of an iso file having a UUID when it's written directly to a USB disk though. I didn't think that happened. I don't have a USB stick to hand right now and my searches as to whether ISO images have UUIDs have not proven conclusive as of yet. I must admit it's been ages since I looked into the details of iso images so perhaps I was mistaken in saying they would not have a UUID. If they can/do have a UUID then perhaps they can also have a label, which may help if the device id method doesn't suit you. Ultimately though, you are probably constrained by the info that appears in /dev/disk/by-* as that is what Linux tools will be using for mounting. So that's the place to look to see what your options are. Thanks, Andy -- https://bitfolk.com/ -- No-nonsense VPS hosting
Re: UUID permanent at removable device?
On Sun 12 Nov 2023 at 18:27:20 (+), Andy Smith wrote: > On Sun, Nov 12, 2023 at 07:03:41PM +0100, Hans wrote: > > I want to dd it automatically like > > > > dd if=/path/to/my/image.iso of=UUID=34567890-afde-.-1234 > > If your use case is writing an ISO file directly to a USB device (no > partitioning) then I'd think you could use the ID of the USB stick > to mount it in future. You can find these in /dev/disk/by-id and it > will remain the same for the life of that stick. I would agree with that, though there is one thing you should check first, and that is that you're not using one of a set of identical USB sticks that have the same ID (or, if you are, that you have some physical means of distinguishing between them). Cheers, David.
[SOLVED] Re: UUID permanent at removable device?
Am Sonntag, 12. November 2023, 19:27:20 CET schrieb Andy Smith: Yes, this is looking promising. Looks like thisis what I exactly need. I will try it. Thanks for the fast response! Best Hans > Hello, > > On Sun, Nov 12, 2023 at 07:03:41PM +0100, Hans wrote: > > I want to dd it automatically like > > > > dd if=/path/to/my/image.iso of=UUID=34567890-afde-.-1234 > > If your use case is writing an ISO file directly to a USB device (no > partitioning) then I'd think you could use the ID of the USB stick > to mount it in future. You can find these in /dev/disk/by-id and it > will remain the same for the life of that stick. > > Thanks, > Andy
Re: UUID permanent at removable device?
Hi Andy, to make things more clear. This is what I want to do: I am using bootcdwrite, which writes its cdimage.iso to a mounted (because of to few disk space) to a mounted external harddrive. This one got a UUID, which never changes, so I can mount it automatically. All this is working perfectly. After the image is created, I want automatically install this image to an USB- stick using dd. Manually this is working well with this shell script, if in this shell script the device is correctly defined. The line is just: dd if=/var/spool/bootcd/cdimage.iso of=/dev/sdc Nothing special! But if I maybe put in two USB-sticks then the wrong one might be /dev/sdc and the script would overwrite the wrong device. Thus my idea, just use UUID for identification, define the correct UUID in the script and the script will always write to the correct USB-stick, regardless, how many or in which order I put them in. As any overwrites changes the UUID of the partition of the partitions, I was asking myself, if it would overwrite the device UUID. blkid /dev/sdb1 or /dev/sdb is showing me a PTUUID, a PARTUUID and a UUID, whic is the same for /dev/sdb and /dev/sdb1, and I am asking myself, if I could use this in my script or if these would change everytime I am using dd. I dunno if my thoughts are working at all, if this, what I intend to do, is not possible at all, then I will find another solution. Or doing just manually as before. Hope, this helps. Best regards Hans
Re: UUID permanent at removable device?
Hello, On Sun, Nov 12, 2023 at 07:03:41PM +0100, Hans wrote: > I want to dd it automatically like > > dd if=/path/to/my/image.iso of=UUID=34567890-afde-.-1234 If your use case is writing an ISO file directly to a USB device (no partitioning) then I'd think you could use the ID of the USB stick to mount it in future. You can find these in /dev/disk/by-id and it will remain the same for the life of that stick. Thanks, Andy -- https://bitfolk.com/ -- No-nonsense VPS hosting
Re: UUID permanent at removable device?
Hello, TL;DR: Use filesystem labels. This is the sort of thing they're for. On Sun, Nov 12, 2023 at 06:55:33PM +0100, Hans wrote: > However, after generating the stick the UUID of the first partition > (/dev/sdc1) > is changing, so next time, the script will not work again, of course. Do you literally mean a GPT PARTUUID? Or do you mean a filesystem UUID? GPT partitions can also have a user-specified name. This is rarely used. MBR labels have a disk identifier which is incremented for each partition, so disk with MBR partitions can also have PARTUUIDs. This is really rarely used. > But does the UUID also change of the device itself? Does the UUID of /dev/sdc > change, too? Devices don't have a UUID (except that disk identifier for MBR as mentioned). GPT partitions do have a PARTUUID. And the filesystem on them does also have a UUID. So sdc being a disk not a partitions, won't have a PARTUUID but could have a filesystem UUID if you put a filesystem on it. > I would like to work with UUID, as I never know, if the USB-stick I put in is > /dev/sdb or /dev/sdc. Thus UUID would be my favourite solution, but this > would > of course only work, if the device UUID after dd will not change. UUIDs are meant to be unique, thus on filesystem creation they will be random, and anything that copies the filesystem will copy around the UUID as well because it's a property of the filesystem. For your use case you will be wanting to use the relevant filesystem-specific tool to write an fs label that you choose. Often this can be done at mkfs time, but there should also be a tool to query/change thre fs label afterwards as well. For ext* filesystems, that tool is "e2label". You can mount by label and also add an fstab entry by label. Here is a fairly exhaustive discussion of your options: https://wiki.archlinux.org/title/fstab If you meant GPT PARTUUIDs and absolutely insist on setting a PARTUUID to a known value instead of just accepting the random one that is picked at the time the GPT label is created, you can do it. e.g. with gdisk: https://askubuntu.com/a/1250232/19809 Thanks, Andy -- https://bitfolk.com/ -- No-nonsense VPS hosting
Re: UUID permanent at removable device?
Correct myself: NOT: > As I want to always the same USB-stick, I would like to mount it using a shell script. > I want to dd it automatically like dd if=/path/to/my/image.iso of=UUID=34567890-afde-.-1234 or similar. Sorry for making things unclear. Hans
UUID permanent at removable device?
Hi folks, just a question. I want to automatically create a bootable USB-stick using dd from an ISO-file. As I want to always the same USB-stick, I would like to mount it using a shell script. However, after generating the stick the UUID of the first partition (/dev/sdc1) is changing, so next time, the script will not work again, of course. But does the UUID also change of the device itself? Does the UUID of /dev/sdc change, too? I would like to work with UUID, as I never know, if the USB-stick I put in is /dev/sdb or /dev/sdc. Thus UUID would be my favourite solution, but this would of course only work, if the device UUID after dd will not change. Happy for any answers. Best Hans