How Do I Extend the `/boot` Partition of the Debian StarFive Provides?

Hi~ my friends, the boot partition of Debian is just allocated 100M:

$ df -mh
Filesystem      Size  Used Avail Use% Mounted on
udev            3.7G     0  3.7G   0% /dev
tmpfs           793M  2.8M  790M   1% /run
/dev/nvme0n1p4  477G   73G  404G  16% /
tmpfs           3.9G  1.1M  3.9G   1% /dev/shm
tmpfs           5.0M   12K  5.0M   1% /run/lock
/dev/nvme0n1p3  100M   29M   72M  29% /boot
tmpfs           793M  120K  793M   1% /run/user/1001
$ cat /etc/fstab 
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# systemd generates mount units based on this file, see systemd.mount(5).
# Please run 'systemctl daemon-reload' after making changes here.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
## /dev/mmcblk1p3       /boot       vfat    defaults       0 2
/dev/nvme0n1p3       /boot       vfat    defaults       0 2
## /dev/mmcblk1p4     /         ext4    errors=remount-ro       0 1
/dev/nvme0n1p4       /          ext4    errors=remount-ro       0 1

And I tried to extend it but I was failed after manymany attempts. Can someone help me? Thx.

$ sudo apt install gparted
Then from the GUI you could shrink the partition (p4) that is blocking the FAT partition (p3) from growing, and move the shrunk partition (p4) closer to the end of the disk to have free space after the vfat partition (p3), or before the ext4 partition (p4) to be able to grow the vfat partition (p3).

e.g.

|p1 |p2  |p3 |p4                  |   <<== at start
|p1 |p2  |p3 |p4                |F|   <<== shrink p4, by the amount that you want to expand p3
|p1 |p2  |p3 |F|p4                |   <<== move p4
|p1 |p2  |p3   |p4                |   <<== expand p3 into free space
|p1 |p2  |p3   |p4                |   <<== after "Edit → Apply All Operations"

F above is free unallocated space.

Online documentaion/manual for the Gnome PARTition EDitor can be found here.

I have to say that I think it is a bit odd that you need a large /boot partition.

2 Likes

@mzs Thanks, it seems the official x86 image allocates ~1G boot partition. And I remember that I tried this method you post, it doesn’t work: the df command still shows the size of boot partition is 100M.

Did you try “sudo partprobe” or a reboot. What does “sudo fdisk -l” say ?

I’ve done it and now trying to recall how. The outline is as follows. First you need to shrink root file system. You can do it using resize2fs. If I’m not mistaken it will also gives you size of file system in blocks. Then you use dd to get a raw copy of shrunk root file system by copying from first to last block. You don’t have to do the same for boot - you can just file copy it’s content somewhere. After that you adjust partition sizes as you please. And finally copy the files back to boot and dd back to root. I hope it makes sense.

One more thing. To avoid copying very large root file system (if it is large in blocks), you shrink it to size of the actual data, resize2fs can do that. After you copy it it back you can resize it back to large partition.

3 Likes

Did you resize (or just make a copy, delete, and recreate p3) the filesystem after using gparted to increase the partition size?

2 Likes

Before doing anything with partitions you want to save their content in some other storage. After you shrink filesystem in partition 4 (ext4 partition) you figure out the first and last block, not of the partition but of the shrunk file system. You make copy of this block range using dd saving it to some other storage. After you resize partition 4 you copy it back using dd as well. At that point you can extend the filesystem back to new partition size.