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. I saw "The partition table has been altered.", my data partition in new partition table. But USB stick no longer booted.