[SOLVED] increasing the size of a legacy /boot partition

udotirol

Well-Known Member
Mar 9, 2018
72
21
48
53
One of my PVE nodes has been installed some years ago and even though it has always upgraded it to the newest PVE version (currently 8.4.3), one thing has been bothering me for a while.

When the node was installed, it was done by using ext4 & mdstat, ending in a partition layout like this:

Code:
$ gdisk -l /dev/sda
GPT fdisk (gdisk) version 1.0.9

[...]

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          391167   190.0 MiB   FD00  Linux RAID
   2          391168        16015359   7.5 GiB     8200  Linux swap
   3        16015360       113672191   46.6 GiB    FD00  Linux RAID
   5       113674240      1953525167   877.3 GiB   FD00  Linux RAID

sda1 and sdb1 are part of md0, which is mounted at /boot. As you can see, it has only got 190MiB reserved for that partition.

Whenever a new kernel arrives, it is impossible to just apt-get update it, because the old and the new kernel don't fit into those 190MiB at the same time. The update ends with "no space left on the device". What I need to do is to manually delete (rm ...) any non running kernel including initrd etc. from /boot and also even remove the running kernels initrd.img. Only then can I install a new kernel.

So, long story short: how can I increase the size of the /boot partition? If that is too cumbersome, I am also inclined to just move the VMs to another node and simply reinstall that node, but if there is a somewhat easy way, I'd like to resize the partition.

Any ideas appreciated ... thanks in advance!
 
Last edited:
Shrink the second (swap) partition (and shift it towards the end) to make space for growing the first partition? This would be simple with booting the system with a GParted Live USB-stick except for the (unsupported by Proxmox) RAID configuration, with which I have no experience.
 
thanks @leesteken, the idea of shrinking the swap partition and using the additional space for the /boot partition got me on the right track :) I didn't use GParted but did it on the running node.

In case anyone stumbles on this as well, here's what I did as root (assuming that md0 is mounted as your /boot partition and sda1 and sda2 are part of that md0 array).

Beware: changing partition layout on a live system can easily lead to data corruption in case you don't really know what you are doing - YMMV!

Code:
$ swapoff -a
$ mdadm /dev/md0 --fail /dev/sda1 --remove /dev/sda1
mdadm: set /dev/sda1 faulty in /dev/md0
mdadm: hot removed /dev/sda1 from /dev/md0
$ fdisk /dev/sda

[... changed partition layout so that it looks like shown below ...]

$ mdadm -a /dev/md0 /dev/sda1
mdadm: added /dev/sda1
$ cat /proc/mdstat
[...]
md0 : active raid1 sda1[2] sdb1[1]
      194368 blocks super 1.2 [2/2] [UU]

The partition layout after changing it - sda1 now has 1G instead of 190MB and sda2 (my swap partition) has been shrinked 6.6GB:

Code:
$ fdisk -l /dev/sda
[...]
Device     Boot     Start        End    Sectors   Size Id Type
/dev/sda1  *         2048    2099199    2097152     1G fd Linux raid autodetect
/dev/sda2         2099200   16015359   13916160   6.6G 82 Linux swap / Solaris
/dev/sda3        16015360  113672191   97656832  46.6G fd Linux raid autodetect
/dev/sda4       113672192 1953525167 1839852976 877.3G  5 Extended
/dev/sda5       113674240 1953525167 1839850928 877.3G fd Linux raid autodetect

I repeated the same for sdb:
Code:
$ mdadm /dev/md0 --fail /dev/sdb1 --remove /dev/sdb1
mdadm: set /dev/sdb1 faulty in /dev/md0
mdadm: hot removed /dev/sdb1 from /dev/md0
$ fdisk /dev/sdb

[... changed partition layout so that it looks like shown below ...]

$ mdadm -a /dev/md0 /dev/sdb1
mdadm: added /dev/sdb1
$ cat /proc/mdstat
[...]
md0 : active raid1 sda1[2] sdb1[1]
      194368 blocks super 1.2 [2/2] [UU]

sdb looks the same as sda:

Code:
$ fdisk -l /dev/sdb
[...]
Device     Boot     Start        End    Sectors   Size Id Type
/dev/sdb1  *         2048    2099199    2097152     1G fd Linux raid autodetect
/dev/sdb2         2099200   16015359   13916160   6.6G 82 Linux swap / Solaris
/dev/sdb3        16015360  113672191   97656832  46.6G fd Linux raid autodetect
/dev/sdb4       113672192 1953525167 1839852976 877.3G  5 Extended
/dev/sdb5       113674240 1953525167 1839850928 877.3G fd Linux raid autodetect

After this, I resized the md0 array and the contained filesystem:
Code:
$ mdadm -D /dev/md0 | grep -e "Array Size" -e "Dev Size"
        Array Size : 194368 (189.81 MiB 199.03 MB)
     Used Dev Size : 194368 (189.81 MiB 199.03 MB)
$
$ mdadm --grow /dev/md0 -z max
mdadm: component size of /dev/md0 has been set to 1048432K
$
$ mdadm -D /dev/md0 | grep -e "Array Size" -e "Dev Size"
        Array Size : 1048432 (1023.86 MiB 1073.59 MB)
     Used Dev Size : 1048432 (1023.86 MiB 1073.59 MB)
$
$ resize2fs /dev/md0
resize2fs 1.47.0 (5-Feb-2023)
Filesystem at /dev/md0 is mounted on /boot; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 4
The filesystem on /dev/md0 is now 1048432 (1k) blocks long.

Just to be sure, I also reinstalled grub on sda and sdb:

Code:
$ grub-install /dev/sda
Installing for i386-pc platform.
Installation finished. No error reported.
$ grub-install /dev/sdb
Installing for i386-pc platform.
Installation finished. No error reported.

And finally, I reinitialized the two swap partitions sda2 and sdb2 again:
Code:
$ mkswap /dev/sda2
Setting up swapspace version 1, size = 6.6 GiB (7125069824 bytes)
no label, UUID=someUUID4sda2
$ mkswap /dev/sdb2
Setting up swapspace version 1, size = 6.6 GiB (7125069824 bytes)
no label, UUID=someUUID4sdb2

The UUIDs you get here need to replace the ones in /etc/fstab for the swap partitions (use your favorite editor), so that it looks like this:
Code:
UUID=someUUID4sda2 none            swap    sw              0       0
UUID=someUUID4sdb2 none            swap    sw              0       0

To reenable swap, just issue a swapon -a