there might be a way to go, but it is combined with a little work. So what will we be doing? first we copy the system to its new location. Then we have to make some adjustments to the copied fstab to represent the new location of the root partition and we will chroot into the copied system to adjust the boot files.
Prerequisites:
- create a ext4 partition in the unallocated space on /dev/sda
- mount the newly created partition to /mnt via
sudo mount /dev/sda6 /mnt
- it might have a different number at the end but gparted will tell you
- get the uuid of the new partition
ls -la /dev/disk/by-uuid/
and write it down
Copy files
copy the content of your current /
to the new partition with:
sudo rsync -aAXv / --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} /mnt
Make necessary corrections
- adjust the fstab on the new location via
sudo nano /mnt/etc/fstab
and exchange the uuid in the entry for /
; afterwards it should look like UUID={UUID-of-the-new-partition} / ext4 errors=remount-ro 0 1
- mount necessary directories to /mnt for chroot
for dir in /dev /dev/pts /proc /sys /run; do sudo mount --bind $dir /mnt$dir; done
- lets not forget the boot/efi
sudo umount /dev/sda1 && sudo mount /dev/sda1 /mnt/boot/efi
- chroot into the copied system
sudo chroot /mnt /bin/bash
- update the bootloader
sudo update-grub
- enter
exit
to leave the chroot
- reboot
Finishing up
You now might have two entries for ubuntu in your grub, so you might have to try them to see which one is representing the system in the new location. If it booted fine and you have checked that everything works as intended you can delete the old ubuntu partition in gparted and run sudo update-grub
again so there is only one ubuntu left.
hope this helped
something else
to tell the installer precisely where to install Ubuntu). However, you can backup the list of installed programs and restore them. https://askubuntu.com/q/9135/124466 – Archisman Panigrahi May 20 '21 at 13:56