I need to use the remaining drive space!

Asked by sgfhoisgj sdroigdsjfoihjsg

I've made a custom ISO using Cubic, and I burned it onto a USB stick, but I want to use the remaining space on the stick to store the ISO file itself, so that it has everything it needs to clone itself (by using the ISO to burn onto another stick, put the ISO on it so that the process can be repeated, and so on).

But I'm getting VERY weird results. First of all, right after I burn the drive, it shows up on the list but isn't mountable and isn't even ejectable! I don't remember the exact error but something about a "D-Bus" not being available I think (I'm a bit new to Linux, so bear with me, but I'm a programmer so you don't have to dumb anything down).

But if I restart the computer (or maybe even if I unplug the stick and plug it back in) then the partition appears with the files from the ISO burned onto it. However, the partition is only the exact size of the files and has 0 free bytes, as though Cubic limits it to EXACTLY how much it needs.

That's fine, but it doesn't show the other partitions, so I checked GParted and it says there's only 1 partition which is about 14.5 GB (it's a 16 GB stick but evidently they're never really a full 16 GB), which seems to conflict with the evidence that the partition is only 2 GB (the exact size of all the files). So that's very strange.

If I look at it in the Disks tool (in Accessories) then it shows the first partition as 2 GB, the second as something very small like 4 MB (probably just for booting) and the rest as free space. But the free space says its over 14 GB, the same size as the whole "partition" according to GParted (which is really the whole drive), and if I try to create a partition in the free space it says there's not enough space available, even if I limit to only like 5 GB, and I KNOW there's enough for that! It always complains about it overlapping with the other partitions.

Then to make matters weirder, even though it causes an error and supposedly doesn't actually modify anything, the drive seems to be corrupted after I do that, so that if I view it again in the Disks tool, the partitions are out of order and what had been the first partition (2 GB with all the files from inside of the ISO on it), it says it's free space, and nothing appears in the list of mounted/mountable drives in any folder anymore. I can burn it again to fix it, but I don't see why it's getting corrupted.

I want to just make an Ext4 partition for the remaining space (or even at least enough to fit the ISO) and just put the ISO on it so that it can perpetually be cloned. What am I doing wrong?

I'm making my ISO of Mint 20 Cinnamon (or maybe possibly Mate if necessary) live mode, but I don't know if that matters.

Question information

Language:
English Edit question
Status:
Solved
For:
Cubic Edit question
Assignee:
No assignee Edit question
Solved by:
sgfhoisgj sdroigdsjfoihjsg
Solved:
Last query:
Last reply:
Revision history for this message
Cubic PPA (cubic-wizard) said :
#1

You need to make a "Persistent Live System" USB.

A really good tool that I use is MKUSB.

Here are instructions to install and use:

    https://help.ubuntu.com/community/mkusb

    $ sudo add-apt-repository universe # only for standard Ubuntu live
    $ sudo add-apt-repository ppa:mkusb/ppa # and press Enter
    $ sudo apt update
    $ sudo apt install mkusb usb-pack-efi

The tool has a command line version and a GUI version.
You can launch the GUI version from Ubuntu's Dick by selecting the "guidus" app.

1. Launch guidus from launcher
2. Select i Install (make a boot device)
3. Select p 'Persistent live' - only Debian and Ubuntu
4. Select sdb (or whatever is your USB disk)

   No need to make selections; you can just leave these unchecked...
   []select msdos GPT
   [] select usb-pack-efi (default grub from ISO file)
   [] d-n-i

5. Move the slider to select free space you want (80% is good for a 4-8GB USB stick)
6. Select Go

Revision history for this message
Cubic PPA (cubic-wizard) said :
#2

* Apologies for the typo, that was supposed to be...

"You can launch the GUI version from Ubuntu's DOCK by selecting the "guidus" app."

Revision history for this message
sgfhoisgj sdroigdsjfoihjsg (bodfjoix35cd46gbd7sohdg) said :
#3

Actually, I have gone to a lot of trouble to avoid using persistence (you are referring to saving data into a file on the USB drive to keep the live system updated, right?). Otherwise I could have just stuck with a method that I was trying earlier with Ventoy, in which I could customize the settings how I want, but the problem was that it wouldn't STOP being persistent (unless I turned it off and then it reverted back to just the default ISO).

The problem is, I need something that I can configure how I want but then it stays that way permenantly, and also, I really need to avoid wear and tear on the drive, because it's going to be used often and I want it to last.

In any case, can't I somehow get the extra free space on the USB stick and just format that into a partition? I don't understand:

- Why GParted recognizes the whole thing as one partition even though Cubic set it up to be two partitions totalling only about 2 GB, and the rest is free space.

- Why when I try use Disks to create a new partition with even only a small part of the free space it fails to do so, and somehow corrupts the drive, even though it implies that it didn't change anything.

- Why I can't just store whatever I want on the extra space, because it shouldn't interfere with the part that's already being used, right?

Revision history for this message
sgfhoisgj sdroigdsjfoihjsg (bodfjoix35cd46gbd7sohdg) said :
#4

And sorry I hadn't specified before that it must not be persistent, but it hadn't occurred to me that it would be relevant.

Revision history for this message
Cubic PPA (cubic-wizard) said :
#5

I know the older versions of the startup disk creator app used to allow you to specify free space on the USB. I'll see if I can suggest something else...

Revision history for this message
sgfhoisgj sdroigdsjfoihjsg (bodfjoix35cd46gbd7sohdg) said :
#6

Well I can try that then, but I had just been using the built-in USB Image Writer, because I figured if it was only using part of the space for the partitions for Cubic then I should be able to do just set the rest for another partition. In any case I'll try it when I get the chance, but I'm working on my other problem right now (in the other post), which has an even higher priority.

Revision history for this message
Cubic PPA (cubic-wizard) said :
#7

MKUSB has an option in it's grub menu called "Live only to ram".

Therefore, you would be able to create the persistent USB, but not use the "overlay" file system that writes to the USB.

There is a way to make this the default.
In this way, you would get the "extra" partition to save files, but not have your "live" system altered in any way.

I'll see if I can give you some info on this.

Revision history for this message
sgfhoisgj sdroigdsjfoihjsg (bodfjoix35cd46gbd7sohdg) said :
#8

Actually, I already use the "toram" parameter and I've been putting it into the boot options for Cubic, so I'll save you the trouble because I was already planning to do that.

Also, I noticed something odd: as I said, the extra space is not a partition, but sometimes it automatically becomes an Ext4 partition called "writeable"! I have no idea how it happens but it does. It seems to not always happen right away, and I suspect that it happens the first time the OS is booted on the USB stick, so that subsequent examinations of the USB stick will show the "writeable" partition as soon as it's plugged in!

Revision history for this message
Cubic PPA (cubic-wizard) said :
#9

(1)
Generate the Persistent USB using MKUSB, as described above.
For a 8GB USB,I selected the default 50% space, which gave me enough space to install Linux and 3gb "extra" space.
(Be patient with MKUSB because it takes a long time!).

(2)
Open the USB in the Disks application (apt install gnome-disks).

(3)
Select the USB in the left pane of the Disks application.

Click on the File system named usbboot.
It is the 2nd partition on the USB and is 256 MB FAT.

Click on the little triangle to mount this partition.
Disks will show you a link where the partition got mounted.
Click on this link to open the partition in a file browser.

(4)
In the file browser, go to the boot/grub directory.

(5)
Click on grub.cfg to edit it.

There are 10 menu entries listed.
(Note,I used "Xubuntu-20.10-desktop-amd64.iso for this example).
The first six menu entries are...
1. menuentry "Xubuntu-20.10-desktop-amd64.iso - persistent live"
2. menuentry "Xubuntu-20.10-desktop-amd64.iso - set language for persistent live"
3. menuentry "Xubuntu-20.10-desktop-amd64.iso - persistent live to RAM"
4. menuentry "Xubuntu-20.10-desktop-amd64.iso - live-only to RAM"
5. menuentry "Xubuntu-20.10-desktop-amd64.iso - live"
6. menuentry "Xubuntu-20.10-desktop-amd64.iso - recovery mode"

Remove menu entries numbers 2 through 5, so you are left with...
1. menuentry "Xubuntu-20.10-desktop-amd64.iso - persistent live"
6. menuentry "Xubuntu-20.10-desktop-amd64.iso - recovery mode"

Edit the first menu entry from...

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    menuentry "Xubuntu-20.10-desktop-amd64.iso - persistent live" {
     search --set=root --fs-uuid 2020-10-22-14-31-35-00
     linux ($root)/casper/vmlinuz boot=casper quiet splash fsck.mode=skip persistent --
     initrd ($root)/casper/initrd
    }
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

..to...

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    menuentry "Xubuntu-20.10-desktop-amd64.iso - My Live with Storage" {
     search --set=root --fs-uuid 2020-10-22-14-31-35-00
     linux ($root)/casper/vmlinuz boot=casper quiet splash fsck.mode=skip --
     initrd ($root)/casper/initrd
    }
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

...by removing both occurrences of the word "persistent" [IMPORTANT!!!!]

Obviously, you can use a different name other than "Xubuntu-20.10-desktop-amd64.iso - My Live with Storage".

By removing the keyword "persistent" from the "linux..." line you are telling Grub to NOT use a persistent overlay file system, so your live USB will not be overwritten / updated / modified as you use it!

Save the file.

(6)
In the the Disks application, click the little square icon for this partition to unmount it.

(7)
Open your file browser and eject the various partitions for the USB stick.
(Once you eject one of the partitions, the others will unmount also.

(7)
You can boot into the Live IOS.
Your new menu option will be available, "My Live with Storage"
Select this option and log in.
Open a file browser, and notice you have a mounted file system named "usbdata".
This is your "extra" storage space, and you can save your files here.

(By the way, i noticed that usbdata is an NTFS file system. You might be able to reformat it to EXT4 using gnome-disks. But try that later, after you've got steps 1 though 7 working).

Revision history for this message
sgfhoisgj sdroigdsjfoihjsg (bodfjoix35cd46gbd7sohdg) said :
#10

Wow, thanks. I'll try that, but I should mention that I was planning to give copies of this to people who are laymen and not programmers or computer experts, and probably have never used Linux before, and they need to be able to clone the drives for backup (so that I don't have to keep doing it for them forever), though I guess I could supply detailed instructions like this for them. But I'm going to see if I can get my "writeable" partition to do it. Still, this looks like a really neet trick and I'll look into it, and I think it could probably help a lot of people too, so thanks!

Revision history for this message
sgfhoisgj sdroigdsjfoihjsg (bodfjoix35cd46gbd7sohdg) said :
#11

In case anyone is interested, I've figured out that the "writeable" partition is created during the first time that the new ISO is booted (it says something during the process like "Partition 3 was detected with Ext4 format", or something like that), but the new partition doesn't actually appear yet (even if booted with toram), and won't appear until the next time you boot (you may have to boot into a different installation and then plug in the drive with the custom ISO written to it). I've tested putting files on it and they persist! However, I haven't tried formatting the partition, and since it's Ext4 by default, I can't guarantee it's compatible with other file systems, or that formatting the partition won't corrupt the data on the drive, because it's very finicky and somehow seems to get confused about which partition is where, but as long as you're alright with an Ext4 partition taking all remaining space then it should work fine!