Fixing partition error caused by making USB live disks with Disks
A while back I stopped using optical disks for making GNU/Linux live disks. They are bulky and wasteful, especially the non-rewritable ones. Initially I used third-party tools like UNetbootin, but then I discovered I could use the built-in Disks utility, by selecting my USB, choosing 'Restore image', and choosing the .ISO file I want to make a live disk from.
This worked fine for a while, but then I started to hit weird errors where I couldn't restore an image on a USB I'd already used as a live disk, and couldn't fully remove the partitions the restore process created. I found a solution here:
https://ubuntuforums.org/showthread.php?t=2256873
"Change sdX to correct drive, sdb, sdg etc. Double and triple check you have typed the correct letter a it will erase boot & partition table of the drive you specify. Any typo then creates major issues.
Zero out MBR only, chang sdX to correct drive, erases both boot code and partition table.
dd if=/dev/zero of=/dev/sdX bs=512 count=1"
This seems to reset the partition table, allowing me to create a new partition, and restore another image. If anyone knows how to avoid triggering this problem in the first place, please share your knowledge here.
'dd if=/dev/zero of=/dev/sdX' fill up the whole /dev/sdX drive with zeros. Everything is gone after that command: the partition table and the filesystems.
Yes, that's right. It takes the USB right back to a tabula rasa, allowing me to create a new partition, and restore an .ISO to create a boot USB.
What I was doing was doing 'restore image' on a USB stick that already had a live GNU-Linux system on it. In answer to my own question, I might be able to avoid the bug that stops me deleting partitions by making sure that before I use 'restore image' to make a boot USB from an .ISO, I remove all partitions, and create a new FAT partition.