The /boot
partition holds critical files needed during the Linux boot process, including:
- Kernel images (vmlinuz-*)
- Initial RAM disk images (initrd-*)
- Bootloader configuration files (grub.cfg)
- System.map files
# Typical /boot directory structure
/boot/
├── grub/
│ ├── grub.cfg
│ └── fonts/
├── initrd.img-5.4.0-42-generic
├── vmlinuz-5.4.0-42-generic
└── System.map-5.4.0-42-generic
Usage Scenario | Recommended Size | Rationale |
---|---|---|
Standard desktop/server (UEFI) | 500MB-1GB | Accommodates multiple kernel versions and initramfs |
Legacy BIOS systems | 200-500MB | Smaller footprint but limited to 2TB disks |
Embedded systems | 50-100MB | Minimal kernel requirements |
A dedicated /boot
partition becomes necessary when:
- Using full-disk encryption (LUKS)
- Bootloader cannot access root filesystem (e.g., ZFS, Btrfs, XFS)
- Implementing RAID/LVM configurations
Using fdisk for /boot Partition
# fdisk /dev/sda
Command (m for help): n
Partition type: p
Partition number: 1
First sector: 2048
Last sector: +500M
Command (m for help): t
Selected partition 1
Hex code: EF00 # for EFI system partition
Filesystem Formatting
# For UEFI systems
mkfs.fat -F32 /dev/sda1
# For legacy BIOS
mkfs.ext4 /dev/sda1
Regularly check partition usage with:
df -h /boot
du -sh /boot/*
ls -lh /boot/vmlinuz*
This bash script helps maintain /boot space by removing old kernels:
#!/bin/bash
CURRENT=$(uname -r)
OLD_KERNELS=$(dpkg -l | awk '/linux-image-[0-9]/{print $2}' | grep -v $CURRENT)
for kernel in $OLD_KERNELS; do
sudo apt-get purge -y $kernel
done
sudo update-grub
AWS EC2 instances typically allocate 1GB for /boot because:
- They maintain multiple kernel versions for rollback
- Cloud-init stores temporary files during provisioning
- Provides buffer for future kernel updates
Error: grub-install: error: cannot find EFI directory
Solution: Ensure /boot is mounted before GRUB installation:
mount /dev/sda1 /boot
grub-install /dev/sda
The /boot
partition stores critical files needed for system booting, including:
- Kernel images (vmlinuz-*)
- Initial RAM disk images (initrd-*)
- Bootloader configuration files (GRUB)
- System map files
For modern Linux distributions (2023+), these are the recommended sizes:
# Check current /boot usage (run as root) du -sh /boot df -h /boot
Scenario | Recommended Size |
---|---|
BIOS/MBR systems | 200-500MB |
UEFI systems (minimum) | 500MB |
Systems with multiple kernels | 1GB |
Enterprise servers | 1-2GB |
Modern Linux installations often don't require a separate /boot
partition when:
- Using UEFI with GPT partitioning
- The root filesystem is ext4/XFS (not LVM or encrypted)
- System uses GRUB2 bootloader
For automated partitioning in kickstart files:
# Example kickstart configuration part /boot --fstype=ext4 --size=512 part / --fstype=xfs --size=20480 part swap --recommended
For manual partitioning with fdisk
:
# Create 1GB /boot partition fdisk /dev/sda n (new partition) p (primary) 1 (partition number) (default first sector) +1G (size) w (write changes)
Common solutions when /boot
fills up:
# Remove old kernels (keep at least 2) sudo apt autoremove --purge # Debian/Ubuntu sudo dnf remove $(dnf repoquery --installonly --latest-limit=-2) # RHEL/Fedora # Alternative manual cleanup: ls /boot | grep vmlinuz sudo rm /boot/vmlinuz-5.4.0-42-generic sudo rm /boot/initrd.img-5.4.0-42-generic
Best practices for /boot
filesystem:
- Use ext4 (most compatible)
- Avoid advanced features like LVM or encryption
- Keep on primary storage (not network/NFS)
- For UEFI: FAT32 for ESP (EFI System Partition)
In cloud environments (AWS, Azure, GCP):
- Most cloud images don't use separate
/boot
- Kernel updates handled through cloud-init
- ESP partition still required for UEFI instances