Using GParted to increase my space in Ubuntu without a Live USB

Boot Ubuntu Live without a USB

  • Use Windows Disk Manaement to shrink your Windows partition.

  • Place the Ubuntu ISO on your /home partition or change swap to ext4 for a while and place it there.

  • Add the following menuentry to /etc/grub.d/40_custom.

Menuentry

menuentry "isoname ISO" {
    rmmod tpm
    set root=(hdX,Y)
    set isofile="/[path]/[name].iso"
        loopback loop $isofile
        linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile toram fsck.mode=skip --
        initrd (loop)/casper/initrd
}
  • Where hdX is the disk and Y is the partition number of the ISO location.

  • [path] is the path to the ISO file, [name] is the name of the ISO file.

  • Run sudo update-grub to add the menuentry to grub.cfg.

  • Shutdown and reboot.

  • Select "isoname ISO" from the GRUB menu. (you may need to boot toram if your ISO is located on a partition you are changing).

  • If needed you can use sudo umount -lrf /isodevice to unmount the isodevice.

You will have access to GParted the same as if you were booted from a Live USB.


I was very interested in the answer by C.S. Cameron and was keen to try it on some of my machines. The code in that answer did not work for me. The rmmod tpm line generated a non fatal error so I removed it. There is no /casper directory in the GParted iso that I downloaded. However there is a /live directory and I found changing the "casper" entries to "live" was necessary. /live contains vmlinuz and initrd.img. This got me most of the way to success and various searches threw up "toram=filesystem.squashfs" to boot other iso in this manner. Then I found this GParted website link with the following code with a couple of modifications:

menuentry "GParted ISO" {
set root=(hd0,msdos1)
set isofile="/path/gparted.iso"
    loopback loop $isofile
    linux (loop)/live/vmlinuz boot=live union=overlay username=user components noswap ip=net.ifnames=0 toram=filesystem.squashfs findiso=$isofile
    initrd (loop)/live/initrd.img

}

This works for me on legacy Ubuntu 20.04 and Arch. I haven't tried it on a UEFI/GPT machine which I expect will be different. I found I had to remove "vga=788" from the code because its deprecated. On both machines I placed the iso in my home directory and renamed it to "gparted.iso". The Ubuntu machine has a single partition so the path was /home/user/gparted.iso. The Arch machine has separate / and /home partitions so the path was shorter /user/gparted.iso

One other thing that was vital was to find the correct parameters for root=(hdX,Y). You can find these from the grub menu, just press c for command mode and ls to list the partitions and ls (hdX,Y)/ to list the contents of the top level of that partition which helps with identification. Y will be a number or something like msdos1.