USB sticks are getting larger. I'd like to store data in addition to having USB bootable. And I know how: 1. write ISO to USB stick 2. Add partition via Gnome-disks (both GUI).
Now I want to be able to replace ISO keeping that extra data intact and accessible. How to do that? Preferably w/out manual editing hex data on the disk, but this solution is better than no solution. TIA
I've tried and failed as below. I've read How to copy the partition layout of a whole disk using standard tools where using sfdisk
was advised.
Most ISO's I've encountered look as one below:
sfdisk --dump linuxmint-20.2-cinnamon-64bit.iso
label: dos
label-id:
device: linuxmint-20.2-cinnamon-64bit.iso
unit: sectors
sector-size: 512
linuxmint-20.2-cinnamon-64bit.iso1 : start= 0, size= 4222944, type=0, bootable
linuxmint-20.2-cinnamon-64bit.iso2 : start= 640, size= 7936, type=ef
That is some partition table sfdisk cannot write back (start 0 is not OK for it).
But after creating a partition via gnome-disks
:
sudo sfdisk --dump /dev/sda
label: dos
label-id:
device: /dev/sda
unit: sectors
/dev/sda1 : start= 8433664, size= 57104384, type=83
/dev/sda2 : start= 4800, size= 8496, type=ef
# (note: the ISO I've tried to change from had start=4800 for ef).
So I've saved that new line /dev/sda1
to say a.part
, wrote new ISO to USB, created partition via gnome-disks
, confirmed via sfdisk --dump
, then deleted data partition via gnome-disks
and did sfdisk --append /dev/sda < a.part
(see part of output below). I saw "The partition table has been altered.", my data partition in new partition table. But USB stick no longer booted.
/dev/sda3: Created a new partition 3 of type 'Linux' and of size 24.4 GiB.
Partition #3 contains a btrfs signature.
/dev/sda4: Done.
New situation:
Disklabel type: dos
Disk identifier:
Device Boot Start End Sectors Size Id Type
/dev/sda2 4800 13295 8496 4.2M ef EFI (FAT-12/16/32)
/dev/sda3 14368768 65538047 51169280 24.4G 83 Linux
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
Added (about Ventoy):
I'm using Ventoy already. I still want to have some USB with my favorite system so that I insert the stick, press power and the system loads unattended while I do other stuff. Also I recall Vetroy GUI glitched on some old computer, so again dedicated directly bootable stick is IMO useful.
However these issues are mitigated if Ventoy has option to load default specified file (with delay like GRUB boot menu) - could not find such googling and reading https://www.ventoy.net/en/faq.html. As seems Ventoy internally uses GRUB boot I opened config file to see if I can add default boot option.