Extend root partition with unallocated space on the left

5,504

Yes ... you are having the right idea. Boot from GParted Live media.
You as well can do it from Ubuntu install media (GParted included).
Important : Unmount all partitions (in case there are any mounted).

First move the sda6 partition to the left ... then move the sda7 partition to the left.
Now extend the sda7 ext4 partition - it is not necessary to move the sda9 partition.

After having completed these operations - reinstall the boot loader.
Boot from Ubuntu installation media - open a terminal and execute:

    sudo mount /dev/sda7 /mnt
    sudo mount /dev/sda1 /mnt/boot/efi
    for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
    sudo chroot /mnt
    grub-install /dev/sda
    update-grub  

After this execute :

sudo blkid  

Open another terminal and execute :

sudo gedit /mnt/etc/fstab

Replace the UUID entries with those of the output given from the blkid command.

Boot into BIOS and select Ubuntu in UEFI settings to be the default system to boot.

Note:

sda = disk | sda1 = efi partition | sda7 = system partition (taken from screenshot)

Share:
5,504

Related videos on Youtube

pikron
Author by

pikron

student

Updated on September 18, 2022

Comments

  • pikron
    pikron over 1 year

    I allowed 15Go for my root partition when I installed Ubuntu in dual boot with Windows, but it appears that it was not enough as I don't have space anymore to install new packages.

    So I shrinked 35Go of my Windows partition in order to extend my root partition with it, but that new unallocated free space is (two "steps") on the left of my root partition :

    GParted partition screenshot

    My question is how to extend the ext4 / partition (dev/sda7) with the 34.18GiB unallocated space (a part or the whole of it) ? Is it possible, AND IS IT RISKY (boot problems, etc) to do it by moving the ext4 / partition twice towards the left and then extending it using GParted in Live mode ?

    Same question for the /home (dev/sda9) partition.

  • mikewhatever
    mikewhatever over 8 years
    IMHO, when a partition is moved, its UUID changes, and GRUB won't be able to find it. The OP will need to edit /etc/fstab to fix the UUIDs, and also reinstall GRUB.
  • cl-netbox
    cl-netbox over 8 years
    @mikewhatever : Good contribution ... thank you ... I updated the answer with instructions ! :)
  • pikron
    pikron over 8 years
    thanks for the fast answer. I will create a Live Ubuntu media tonight and try that. I have read in other discussions that one should "swap off" the linux swap partition during the process, is that necessary in my case ? And do you think that moving the sda6 partition (which is Windows', recovery partition I think) might make it unusable after ?
  • cl-netbox
    cl-netbox over 8 years
    @pikron : You don't touch the swap partition - so if unmount (swapoff) is not possible, this should be no problem ... and moving the sda6 partition should not make it unusable. :)
  • pikron
    pikron over 8 years
    I have been trying unsuccessfully to boot on an Ubuntu Live USB (made by LinuxLive Creator), changing the BIOS boot priority #1 to my USB, until I tried by booting in Legacy mode, which worked. But I remember having many problems before with the Legacy mode and dual boot installation, so I wonder : is it safe to make the manipulations you gave me in Legacy mode or must I do them in UEFI mode ? If so, do you think that it is my USB key which is not suitable for booting in UEFI (then, how to recognize a "UEFI-bootable" USB key ?) or is it another problem ?
  • pikron
    pikron over 8 years
    And then, could I get the same result by using boot-repair in a Live session after the partioning instead of writing your lines of code ? (Not that I don't trust you, but just curious about boot-repair capabilities if ever I would need it in the future ;) )
  • cl-netbox
    cl-netbox over 8 years
    @pikron : 1) Create the install media properly (this seems not have been the case with the tool you used) : askubuntu.com/questions/702721/… - 2.) Do everything in UEFI mode - 3:) Do not use 3rd party tools like boot-repair ! :)
  • pikron
    pikron over 8 years
    Everything worked fine !!! Actually, the Linux version that Linux Live Creator helped me to download was a 32-bits, that's why I couldn't boot in UEFI mode, so I downloaded a 64-bits one. And I didn't need to write your lines of code, as when I rebooted right after the GParted partitioning (to check the boot behavior), everything was working as before : still have the Grub menu, Windows and Ubuntu both boot normally and seem to work well. And the space extension worked. So, thank you very much for your time and precious help !