[GTALUG] growing an EFI System Partition (ESP)
D. Hugh Redelmeier
hugh at mimosa.com
Tue Nov 7 12:20:24 EST 2023
(This is a recipe. If you find errors or think of improvements, please
let me know.)
== context ==
The ESP is the partition to hold anything the UEFI firmware can
run. Mostly bootloaders but also diagnostics and firmware updates.
It is a FAT filesystem in a partition with a special type.
In a running Linux, it is usually mounted on /boot/efi.
This stuff is a little bit tricky and not well-documented. I tried to be
very detailed to make sure you don't get lost.
== motivation ==
The ESP doesn't have to be very big, but sometimes it isn't big enough.
I often buy computers pre-loaded with Windows -- typically cheaper than
computers without Windows. Sometimes the ESP is 100MB. This has pinched.
So I want to increase the size. I have a feeling that 200MB would be a
good size, but I will probably settle on 400MB.
== naive method and a failure ==
Tools:
- a live USB Linux system. [You don't want to be doing partition surgery
on the disk from which you are running.]
- some place to temporarily hold the contents of the ESP.
It could be on another partition of the same disk or on a USB devicee.
- gparted for partition manipulation. You could substitute with something
like parted(8).
- gnome "disks" (gnome-disk-utility). I find it convenient for mounting,
unmounting, and looking at the properties of disks and partition. You
can choose to do these things with other tools.
1. boot the live Linux stick.
2. if your live system doesn't include gparted, install it.
Fedora: "sudo dnf install gparted"
debian or Ubuntu: "sudo apt install gparted"
3. run gparted and point it at the disk with the too-small ESP.
Make sure that none of that disk's partitions is mounted.
3. shift and shrink partitions to make sufficient unallocated space
adjacent to the ESP.
If you are going to install Linux on the disk, this would be a good
time to make space for it too.
Make sure to tell gparted to "apply" these changes.
4. If you changed the size of any NTFS partitions, gparted might have
damaged some redundant metadata. Fix it now.
- boot into Windows
- ask it to scan and repair the volume(s)
- reboot into your live Linux system and get back into gparted
5. ask gparted to resize the ESP. It should succeed in resizing the
partition but may fail in resizing the FAT filesystem. The
failure message will be rather obscure:
No Implementation: GNU Parted cannot resize this partition to this size. We're working on it!
What it means is that libparted-fs-resize doesn't have code to deal
with some common forms of FAT. The message is wrong: the partition has
been resized but the filesystem it contains has not. Oh, and nobody
has worked on this in a decade.
If you had no failure, STOP HERE, you are done.
Continuing past FAT filesystem resize failure:
1. exit gparted
2. mount the old ESP. GNOME "disks" has a button for that.
3. copy the contents of the ESP somewhere safe. It could be to a USB
device or even a non-ESP partition on the system disk.
"sudo cp -a ESP SAVED"
ESP is the ESP mount point.
SAVED is to be a new directory in the place where you have enough free
space
4. unmount the old ESP
5. Make a new, larger FAT filesystem, filling the partition:
"sudo mkfs.vfat X"
where X is the device name of the ESP partition.
On my system, it was /dev/nvme0n1p1 but yours might well be different
This will wipe the old FAT filesystem and make an empty new one that
fills the partition.
6. mount the new ESP
7. copy the old contents of the ESP into the new ESP.
"sudo cp -a SAVED/* ESP
Note: the /* bit is to avoid creating an extra directory layer in the
ESP. * isn't great but FAT filesystems don't have files starting with
".".
8. shut down Linux; unplug the live stick
FINI
More information about the talk
mailing list