How to Free Up /boot Partition Space

How to Free Up /boot Partition Space in Ubuntu?

Ubuntu is one of the modern, stable, and popular Linux operating systems that has many fans with the valuable advantages it has created. By now, you have probably received the warning that the /boot partition is full or /boot partition has no space left. This warning in Ubuntu informs that the /boot partition space is full, which is one of the most common problems of computer systems. But what is the boot partition, and why do we get this error?

The /boot partition in Ubuntu is where the necessary files to start the Ubuntu operating system are stored, and when its space is full, various problems arise, such as system instability or the inability to boot. If you bought an Ubuntu VPS and received the “/boot partition has no space left” error, don’t worry because this article will guide you in solving your problem to free up /boot partition space in Ubuntu. In this article, we will talk about the /boot partition, the issues that arise when the /boot partition space is full, and how to free up /boot partition space in Ubuntu, so stay with us until the end of this article.

What is a /boot partition?

The boot partition is a particular partition on the hard disk that includes the necessary files for the initial startup of the operating system. The /boot partition is a vital part of the overall system setup that stores the bootloader, kernel, initial ramdisk, and other related files. Usually, Ubuntu users assign 512MB or 256MB of hard disk to the boot partition. The /boot directory usually contains the /boot partition and the versions of vmlinuz, initrd.img, System.map, abi, config etc files.

Why do we get the “/boot partition has no space left” warning?

The warning “/boot partition has no space left” in Ubuntu means that the boot partition has no space, and this problem will interfere with system performance. Possible reasons for this warning are as follows:

  • Installing the new kernel and not removing the old kernel, which will consume /boot partition space.
  • Installing rich and complex programs in the /boot partition
  • Occupying a significant space of the boot partition with the accumulation of temporary files, log files, and system updates in the /boot partition
  • Inappropriate and small partition size compared to operating system growth
  • Improper disk management and incorrect space allocation to the /boot partition
  • Incorrect management of Logs and Error Reports and occupation of /boot partition space by these files
  • Malware that creates large files or duplicates themselves on the /boot partition

What problems does /boot partition space getting full cause?

If there is no free space left in the /boot partition, you will experience many problems, including system boot problems, disruption of the overall system performance, and system instability. Some of the common issues that occur due to the /boot partition space being full will be discussed here.

System instability: When the /boot partition is full, the operating system is disturbed in performing routine tasks, and these disturbances lead to crashes, freezes, and general slowness.

Inability to Boot: The most obvious problem related to getting full the /boot partition space is that the computer cannot boot properly. On the other hand, since the /boot partition stores the necessary files to start the operating system, essential files may not be available when the boot partition space is full, and the boot will fail. Of course, this problem is nothing to worry about because there are useful solutions to fix Ubuntu boot problems.

Software problems: The performance of the software relies on the necessary files stored in the boot partition, the unavailability of these files due to the lack of enough space in the boot partition causes the software not to run properly.

Inability to install updates or new kernels: To install a new kernel or operating system patches, you need free space in the /boot partition; if the partition space is full, the updates will not be released, and the system will be vulnerable and exposed to Security risks. You will also miss the advanced features of the new kernel and updates.

Disruption in system performance: Being the /boot partition space full leads to a general slowdown in system performance.

Data loss: Unavailability of free space in the boot partition leads to crashes, errors, and unexpected behavior. Finally, important system files may fail due to a lack of /boot partition space, and you may lose important data.

Checking current usage of /boot partition

To free up boot partition space, you can first check the available /boot partition space by running the following command in Ubuntu:

df -h

In the output of the previous command, you can check the occupied and unoccupied space of the /boot partition, and if you find that there is no free space left, through the methods we will teach, free up the /boot partition space.

A useful tutorial to free up /boot partition space in Ubuntu

So far in this article, you have learned about the importance of the /boot partition and the problems that can arise from the /boot partition being full. Therefore, as a Linux system administrator, you must manage the /boot partition space efficiently and free up the space of the /boot partition so that you do not experience problems using the Ubuntu system. The fastest solutions to free up /boot partition space are as follows:

  • Deleting temporary and unnecessary files, cache, and unnecessary reports
  • Managing installed programs and moving them to another partition if possible or removing unnecessary programs
  • Changing the size of the partition
  • Checking and managing boot partition space and setting automatic remove
  • Running a malware scan
  • Upgrading the system and operating system to the latest version

Some users do not allocate space for a separate boot partition to avoid receiving the “/boot partition has no space left” error and consider only the root partition for installing the Ubuntu operating system or other purposes. The advantage of this is that there is enough space in the /root partition and not get the /boot partition being full error, but this problem is not a logical reason for not creating a separate partition for boot and is not a good solution. Better solutions with less risks to free up /boot partition space exist.

You may be asking yourself how to solve this problem through these solutions. Don’t worry, we will teach you the most useful methods to free up boot partition space in ubuntu.

Freeing up disk space from temporary files

As mentioned before, cleaning up temporary files, old kernel, and APT package repository caches in Ubuntu is one of the easiest and most useful ways to free up disk space. Don’t worry that this solution will be time-consuming or complicated, you can clear APT package repository caches in Ubuntu by running one command and get rid of old kernels, unused dependencies, and temporary files. Run the following command to remove APT caches:

sudo apt autoremove

After running the previous command, the items that will be deleted will be displayed, and after your confirmation, the disk space will be freed from the displayed items.

Therefore, by running a simple command in the Ubuntu terminal, you can clear the APT package repository caches and remove temporary files from the /boot partition. Of course, it should be noted that you must have sudo privileges to execute the previous command.

One thing to consider is that when the /boot partition space is full, the APT package manager may not work correctly and cannot successfully clear the /boot partition space. Therefore, you can replace this method with other methods, such as changing the partition size or removing unused kernels.

Removing old kernel to free up ubuntu /boot partition space

Once you update the Ubuntu Linux Kernel and the updated kernel is compatible with your system, you will no longer need the old kernels in the system. It may be that keeping an old kernel in the disk space is a useful solution for situations where the incompatibility of the new kernel with the system disrupts the operation of the operating system. Still, the existence of more than two kernels in the system has no other advantage except filling the disk space. Therefore, we recommend that when the /boot partition space is full, delete the old and unused kernels from the disk space. For this purpose, follow the steps below:

1. Check the currently active kernel version

Before removing the old kernel from the Ubuntu system, obtain information about the active kernel version to identify it through the “unnamed” command:

uname -r

Sample output:

5.4.0-7642-generic

After identifying the current kernel, you can remove kernel versions that do not match the previous command’s output. Be careful not to accidentally delete the current kernel, which will cause the system to crash.

2. List the installed kernel packages

Check the list of installed kernel images to detect the old kernel image by running the following command:

dpkg -l | grep linux-image

3. List the kernel files installed in /boot directory

List the installed kernels and files in the /boot directory and identify old kernels and those that do not match the current kernel version to remove:

ls -l /boot

4. Remove the old kernel from the /boot partition

Use thermcommand to remove old kernel files from the boot partition in Ubuntu. For example:

sudo rm /boot/vmlinuz-5.4.0-7634-generic

Substitute your desired kernel version in the example we provided.

Thermcommand allows the user to remove more than one Linux kernel; to remove several old kernels, Use the following example:

sudo rm /boot/*-5.4.0-{7634}-*

For example, to clear two Linux kernels, you can separate the last part of the version with commas, as in the following example:

sudo rm /boot/*-5.4.0-{7634,7644}-*

As a result, you have freed up the space of the /boot partition from the old kernels.

If the functionality of the APT package manager in Ubuntu has not been disturbed yet, you can remove the old kernel by APT. For this purpose, use the following example:

sudo apt remove --purge linux-image-4.15.0-20-generic

Then press y and Enter to remove the “linux-image-4.15.0-20-generic” package and run the following command to remove old kernel dependencies:

sudo apt autoremove --purge

Finally, the old kernel files and their dependencies are removed from the /boot partition.

Increasing ubuntu boot partition size to solve partition full error

If the hard disk has enough free space, you can change the size of the boot partition and allocate more space from the hard disk to the boot partition. Before resizing the boot partition, make a backup copy of your important data. The steps to change the boot partition size in Linux include changing the file system and disk partition, which are different based on the partitioning and its specific configuration, so we will explain the general steps. You can increase the boot partition size using the GParted Live graphical partitioning tool; follow the steps below for this purpose:

1. Open the Gparted editor.

2. Identify and locate the boot partition you want to resize. It may be part of the root partition.

3. If the partition is mounted, unmount it from the menu that opens by right-clicking on the partition.

4. Right-click on the boot partition and adjust the partition size to the desired size by selecting the “Resize/Move” option. (When setting the size for the boot partition, make sure there is enough space left for other partitions.)

5. If a file system is stored in the boot partition, such as ext4 and xfs, etc., you should also change the size of the file system. For this purpose, right-click on the resized partition and select one of the two options, “resize /manage the file system,” to inform the file system of the newly allocated space.

6. Exit GParted and reboot Ubuntu to return to the main Linux installation.

7. Check the boot process and make sure the boot works properly.

The Instructions we taught are general steps that differ depending on Linux distributions and partition settings. Be careful when resizing partitions, as it will result in data loss.

In addition to changing the partition size, you can create a larger partition, format it to transfer the contents of the/boot directory to the new partition and mount the new boot partition in /boot directory.

FAQ

Yes, the Stacer graphical tool is designed to remove old kernels in Linux.

The cause of this problem may be the deletion of an essential file from the hard disk. To solve this problem, booting in recovery mode, restoring missing files, or using live CD/USB to repair your system's bootloader are worth trying. Ubuntu community forums are also a good guide to solve your problem.

Conclusion

In this article, you learned efficient methods to free up /boot partition space in ubuntu to avoid possible problems related to /boot partition space getting full. The /boot partition space getting full is not a rare problem, most users have the experience of receiving the “boot partition has no space left” warning, just learn the methods to free up the boot partition space and efficiently manage the boot partition space.

Thank you for choosing this article to read. If you have any questions about freeing up /boot partition space, ask us in the comments section.

Leave a Reply

Your email address will not be published. Required fields are marked.