Topic: [SOLVED] Rearranging partitions, including boot partition
I have a 500GB NVMe drive on my Ubuntu machine. A year ago I upgraded from 18.04 to 22.04 by creating a new partition and installing 22.04 to it, so that I could retain the old Ubuntu for file retrieval. (Booting uses Grub 2.06.)
Now I want to get rid of the old partition and merge it with the new. Problem 1: the boot partition is in the middle of my drive. (Don't ask me how it got this way; likely user error.)
So, I want to delete the old data partition (nvme0n1p1 below), move the boot partition (nvme0n1p2 below) to the beginning of the drive, and resize the new data partition (nvme0n1p5 below) to fill the drive. Problem 2: if I try to move the boot partition, GParted (quite reasonably) warns me that moving it will break Grub if I do so.
So, how can I move the boot partition without breaking my booting? Just move it, and then go through the "Fix Grub Boot problem" mentioned in the manual?
P.S. Here's the format of my drive (from GParted and command line tools):
griscom@nob:~$ sudo lsblk -o name,maj:min,rm,size,ro,type,fstype,label,mountpoint /dev/nvme0n1
NAME MAJ:MIN RM SIZE RO TYPE FSTYPE LABEL MOUNTPOINT
nvme0n1 259:0 0 465.8G 0 disk
|-nvme0n1p1 259:1 0 240.3G 0 part ext4 /mnt/oldroot
|-nvme0n1p2 259:2 0 513M 0 part vfat /boot/efi
|-nvme0n1p3 259:3 0 1K 0 part
`-nvme0n1p5 259:4 0 224.9G 0 part ext4 /
griscom@nob:~$ sudo fdisk -l /dev/nvme0n1
Disk /dev/nvme0n1: 465.76 GiB, 500107862016 bytes, 976773168 sectors
Disk model: Samsung SSD 970 EVO 500GB
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xc743bd49
Device Boot Start End Sectors Size Id Type
/dev/nvme0n1p1 2048 503910399 503908352 240.3G 83 Linux
/dev/nvme0n1p2 * 504016896 505067519 1050624 513M ef EFI (FAT-12/16/32)
/dev/nvme0n1p3 505069566 976771071 471701506 224.9G 5 Extended
/dev/nvme0n1p5 505069568 976771071 471701504 224.9G 83 Linux
griscom@nob:~$