How to modify partitions without a live USB/CD
Fortunately there is a way to boot a live environment without a usb stick or CD drive.
The overview of this answer is that you boot an iso image stored on your hard drive by adding a custom entry to grub. However always make sure you have backups of any data you cannot afford to lose before trying to modify partitions. These are the steps:
Identify your partitions in grub command notation.
This is probably the least well known part of this procedure. I recommend using your home directory to store the iso image so you need to find where that is from the perspective of the grub command prompt.
You can do this from the grub menu while booting, just press c
for a command mode prompt and then ls
to list the partitions. You should see a list containing things like (hd0,msdos1) or (hd0,gpt1). These are partitions on your system and you are looking for the one containing your home directory. To do this type ls (hdX,Y)/
at the command mode prompt to list the contents of the top level of that partition. If you don't have a separate home partition you are looking for the partition containing home/ as below. If you do have a separate home partition you are looking for john/ or jane/ or what ever your username is.
If your system boots straight into Ubuntu you can make the grub menu visible by pressing the shift key (legacy system) or the Esc key (UEFI system) while booting.
Download the iso
Download the GParted iso from https://gparted.org/download.php . It's smaller than the Ubuntu iso but that works too. Choose where to permanently store it. In this example I chose my home directory and renamed the iso to gparted.iso rather than use the longer name that was downloaded and which specifies the gparted version. That means my iso is held at /home/user/gparted.iso
Modify grub
The next step is to modify your /etc/grub.d/40_custom file. Your file needs to look like this:
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry "GParted ISO" {
set root=(hd0,msdos1)
set isofile="/home/username/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
}
The /etc/grub.d/40_custom file should already have the first 5 lines and may have other custom entries if you have added them in the past. You can keep any previous additions untouched.
Your version of the file will be slightly different. You need to change the the correct parameters for the root=(hdX,Y)
line. You also need to get the correct path for your setup in the set isofile="/home/username/gparted.iso"
line. If you have a seporate home partition it should be set isofile="/username/gparted.iso"
.
You can edit the file however you like but one way to do it is to open a terminal in your home folder and use the following:
a) cp /etc/grub.d/40_custom 40_custom.bak
(this makes a backup of your 40_custom file in your home directory)
b) cp /etc/grub.d/40_custom 40_custom
(this makes a working copy of your 40_custom file in your home directory which you edit in your editor of choice)
c) sudo cp 40_custom /etc/grub.d/40_custom
(copies the modified file back)
d) sudo update-grub
When you reboot you should get a grub menu with a new entry for "GParted ISO" which will boot you into the GParted live enviroment where you can modify your partitions. I follow partitioning questions so if you hit any problems and cannot find an answer by searching Ask Ubuntu ask a new question and I'll help if I can.