Disk partitions are linear chunks of your disk. You can't have a partition that starts at the top, has a hole in it, and continues somewhere else.
Usual warning: messing with your partition layout is one of the faster ways to lose all your data. Make sure you have a backup of anything important, and take your time - don't rush past warnings or errors the tools report.
Since sda2
is a swap device, it doesn't contain any useful information when the OS is not running; so you can just delete it.
Once that is done, you should be able to extend sda1
to however much you want, and re-create a swap partition.
You should also consider using lvm
. It is quite handy and will allow you to control your disk usage more finely. See Setting Up LVM- Without A Clean Install for example.
Just to share, this is what I have done:
There is no need to perform grub-install
since all the files are already there. What needs to be done subsequently is to create a new boot option at the partition sda1 using the EFI boot manager and pointing to the shim.efi
bootloader:
# efibootmgr -c -L Fedora -l \\EFI\\fedora\\shim.efi
Then check its boot position (refer to PARTUUID using blkid
if not sure):
# efibootmgr -v
BootCurrent: 0004
Timeout: 1 seconds
BootOrder: 0004,0000,0002,0001
Boot0000* Fedora HD(1,800,64000,<PARTUUID>)File(\EFI\fedora\shim.efi) <= NEW
...
and make sure that it is the first boot loader in the sequence:
# efibootmgr -o 0000,0002,0001,0004
For grub, what needs to be done is to change all instances of /boot
location to point to the new partition:
# vi /boot/efi/EFI/fedora/grub.cfg
....
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt6
--hint-efi=hd0,gpt6 --hint-baremetal=ahci0,gpt6
....
Search and replace "gpt6" with "gpt2" (if /boot is moved from sda6 to sda2)
To prevent the OS from mounting the old /boot
and /boot/efi
partitions due to duplicate UUIDs, edit fstab:
# vi /etc/fstab
Replace the duplicate references of UUIDs with PARTUUID (if you are using GPT) or device node (e.g. /dev/sda1).
Reboot and you are done.
Best Answer
Here is the problem in your understanding:
GRUB is not "mounted" on boot. GRUB is installed to
/boot
, and is loaded from code in the Master Boot Record. Here is a simplified overview of the modern boot process, assuming a GNU/Linux distribution with an MBR/BIOS (not GPT/UEFI):/boot
partition (which I believe is determined when you install GRUB to the Master Boot Record), and parses the filesystem information. It then loads Stage 2 GRUB. (This is where the simplification comes in.)/
under/new_root
(possibly cryptographically unlocking it), starts udev, starts resume-from-swap, etc.pivot_root
utility to set/new_root
as the real/
.init
starts. Partitions get mounted, daemons get started, and the system boots.Notice how the kernel is only loaded at step 7. Because of this, there is no concept of mounting until step 7. This is why
/boot
has to be mounted again in step 9, even though GRUB has already used it.It may also be of use to look at the GRUB 2 section of the Wikipedia page on GRUB.