Active4 months ago
My
/boot
partition is nearly full and I get a warning every time I reboot my system. I already deleted old kernel packages (linux-headers...), actually I did that to install a newer kernel version that came with the automatic updates.After installing that new version, the partition is nearly full again. So what else can I delete? Are there some other files associated to the old kernel images?
Here is a list of files that are on my
/boot
partition:Currently, I'm using the
user6722user67223.0.0-14-generic
kernel.2,98533 gold badges1212 silver badges1313 bronze badges
22 Answers
How to Remove Linux (Ubuntu) From Dual Boot in Windows 10. Wait a bit for the process to complete, and then you should have only 1 volume on your Disk 0, meaning you have removed your Linux and reclaimed all the disk space back to windows. Step 2: Remove the Grub Bootloader. The small size of the /boot partition has been causing problems 'in. Room for three kernels (we're supposed to always keep two kernels,.
You've a lot unused kernels. Remove all but the last kernels with:
This is shorthand for:
Removing the
linux-image-x.x.x-x
package will also remove linux-image-x.x.x-x-generic
.The headers are installed into
/usr/src
and are used when building out-tree kernel modules (like the proprietary nvidia driver and virtualbox). Most users should remove these header packages if the matching kernel package (linux-image-*
) is not installed.To list all installed kernels, run:
One command to show all kernels and headers that can be removed, excluding the current running kernel:
It selects all packages named starting with
linux-headers-<some number>
or linux-image-<some number>
, prints the package names for installed packages and then excludes the current loaded/running kernel (not necessarily the latest kernel!). This fits in the recommendation of testing a newer kernel before removing older, known-to-work kernels.So, after upgrading kernels and rebooting to test it, you can remove all other kernels with:
LekensteynLekensteyn131k5151 gold badges274274 silver badges366366 bronze badges
Your boot partition is full. Since this is a kernel update, these files will be copied to the boot partition so you need to clean in out. Here is a blog post that will show you how to clear the old kernel images with one command. I'll give a basic synopsis of the method. Use this command to print out the current version of your kernel:
Then use this command to print out all the kernels you have installed that aren't your newest kernel:
Make sure your current kernel isn't on that list. Notice how this is the majority of the final command (down below). To uninstall and delete these old kernels you will want to pipe these arguments to:
Now we can do everything we want by combining these last two commands into this unholy mess:
And that one command will take care of everything for you. I will confirm that this does work perfectly but never trust anybody on the internet. :) For more info, the blog post gives a very good explanation of what each part of the command does so read through it so you are satisfied that it does what you want it to do.
dwarddward2,38011 gold badge88 silver badges77 bronze badges
mchid25.6k33 gold badges5959 silver badges9797 bronze badges
karankaran1,10711 gold badge77 silver badges22 bronze badges
The Synaptic Package Manager can be used to easily select and remove old kernel images.
If you don't already have Synaptic installed:
Start the application and select the options shown.
You should be able to highlight all the 'linux-' packages with the version '2.6.x' where x is between 31 to 38 according to the files in your /boot folder.
Right-click each of those linux packages and choose the option 'Mark for Complete Removal'. Finally click the apply button. This will remove all the files and any associated files. Your
mwfearnley/boot
folder should now be a bit tidier.1,13722 gold badges1111 silver badges2121 bronze badges
fossfreedom♦fossfreedom153k3939 gold badges341341 silver badges384384 bronze badges
Thank you for your detailed post of your problem, this got me going in the right direction. Although it is useful to keep previous kernel files you can remove all of them in one go, check this post:
How to Remove All Unused Linux Kernel Headers, Images and Modules
How to Remove All Unused Linux Kernel Headers, Images and Modules
Done via command line. If you are doing this via remote use something like WINSCP to open a terminal session and just paste it in, works very well.
Here it is copied from article link, I suggest you read the full article:
Mateo7,56088 gold badges5151 silver badges7373 bronze badges
OmniOmni
This is a new answer to an old question, but an easy way to clean this thing (and more) is to install Ubuntu Tweak. To install it:
then you can run Ubuntu Tweak, Going to the 'janitor' tab, and from here it's a matter of three clicks:
It is better to leave the last kernel (you never know) or a well-known working kernel for safety, though; but that's easily customizable.
You can use the same tool to clean a lot of things --- just remember that if you clean thumbnail cache or TB cache then the system will have to rebuild them if they are needed.
RmanoRmano26.4k99 gold badges8484 silver badges154154 bronze badges
I was able to fix the problem by using
dpkg
to remove the packages directly. Although the packages are still listed in dpkg -l
, the files are removed from /boot
, freeing up space.After this,
apt-get -f install
fixed my dependency problems, and all was well with the world.I'll not be accepting this answer of mine, however, as I still need to know if I should be increasing my
PhrogzPhrogz/boot
size or doing something else.81144 gold badges1313 silver badges2525 bronze badges
You can stop using a separate /boot partition, then you won't have such limited space there. To do this, unmount the partition, then mount it somewhere else and copy all of the files there to the /boot directory in your root partition, then remove the entry from /etc/fstab and reinstall grub. For example ( you will need to use the correct partition ):
You can then use gparted to delete the old /boot partition, and possibly extend the root partition to use that space. To extend the root partition you will need to boot from the livecd, and the free space needs to be immediately to the right. If the /boot partition is currently to the left of the root partition, then you will need to first move the root partition to the left, then extend it, but this can take a very, very long time, so may not be worth the trouble.
psusipsusi32.2k11 gold badge5353 silver badges9393 bronze badges
Taking the best from the answers above, my tried-and-true approach is this:
uname -a
to find the running kernel.dpkg -l linux-{headers,image}-* | grep ^ii
to list all currently installed kernel-related packages. This will include the running kernel.sudo apt-get purge linux-{image,headers}-3.16.0-{xx,yy,zz}
to remove the old kernels. Replacexx,yy,zz
with a list of the kernel builds you want to remove—these are all the builds listed by the previous command which are older than the currently running kernel. Make sure you don't remove the currently running kernel—your system will become unbootable. You may also need to change the kernel version from3.16.0
to whatever is installed on your system.- Optionally, do an additional
sudo apt-get autoremove
—this will remove any leftover dependencies of the old kernels which are no longer needed by the current one, freeing up some more space.
You may have header files without matching kernel versions installed, or vice versa—just include all of these versions in the command. APT will complain that some packages can't be removed because they are not installed, but that will do no harm.
- If the apt command fails due to a no space left on device error, use the corresponding dpkg command instead:
sudo dpkg --purge linux-{image,headers}-3.16.0-{xx,yy,zz}
. - If the dpkg command still doesn’t work because the
linux-image
packages are required by thelinux-headers
packages of the same version (which you also want to uninstall), dpkg may have failed to resolve that. Re-examine the output ofdpkg -l
and specify any package name suffixes on the command line. For example, on one of my systems the command that eventually worked wassudo dpkg --purge linux-{image,headers}-3.16.0-{xx,yy,zz}-generic-pae
. - If you get any other error, seek help—you may have a different problem than you thought.
user149408user149408
For me both
apt-get purge
and dpkg --remove
both failed. So I had to deleted a couple of older kernel images from /boot with rm -f
. orkodenorkoden
List all kernels:
Display current kernel:
List all kernels EXCEPT current one:
Make sure your current kernel isn't on that list.
Remove all kernels EXCEPT current one:
Clear other stuff:
If it still gives you boot disk space error for installing/uninstalling files then directly remove one of OLD image from /boot directory,
NOTE: Please review current kernel image again before deleting any image.
Hemant ThoratHemant Thorat
I already deleted old kernel packages (linux-headers...)
linux-headers-*
aren't kernels. Kernel packages are the ones named linux-image-*
. The ones named linux-headers-*
are development packages for compiling kernel modules: they don't live in the /boot directory and are not required for general day to day use of your system.The files you listed in /boot do include several old kernel images (
vmlinuz*
) and compiled initrd images (initrd.img*
) for those kernels, which is an indication that you still have a lot of old kernel packages installed.You should be able to list your installed kernels with
(Note that this will probably return packages that aren't kernels, too).
There is usually no need for more than two kernels to be installed - the one currently in use and the previous one to that (as a fallback). So you can start removing the older ones, one by one, like this:
Make sure you substitute '3.2.0-23-generic' with the actual kernel version you want to remove! Also, don't remove packages such as
linux-image-generic
. You have to be really careful not to remove the currently running kernel or you won't be able to boot (Ubuntu may or may not warn you about doing this).You can find your currently running kernel with:
thomasrutterthomasrutter28.4k44 gold badges7171 silver badges9292 bronze badges
I had this problem and more as I removed some
initrd-img-xxx
files manually from the /boot and I had a problem that these old versions keep generated and filling in the /boot
folder. To fix it I followed the following: - I removed the generated old kernel version manually so to free space.
- You’ll be editing a text configuration file as superuser, so paste the following into a terminal:
- Locate the line
update_initramfs=yes
and change it toupdate_initramfs=no
. Save and exit the file, then run:
That solved my problem. That was based on this blog
Hopefully, everything should be fine when you reboot, and later you can try changing the
no
back to yes
in update-initramfs.conf
.aibrahimaibrahim
I show that still in 2017 this question has new comments and answers but missing one answer that I think is very useful here:
Ubuntu as a desktop OS of simple everyday usage has no reason to be installed with separate boot partition and something like this will NOT offer something to a 'common user'... So a solution is a fresh install without boot partition and this way you will never have such a problem
PS: My answer can be deleted or added in the accepted answer... (I think it will help some people this way)
koleygrkoleygr
Super helpful utility that will clear out your boot partition
Use at your own risk, but it worked for me:
JonathanJonathan1,74833 gold badges1515 silver badges3636 bronze badges
In aptitude or synaptic there is a section 'old or manually installed packaged'. There should be the old linux packages there.
Martin UedingMartin Ueding4,2201010 gold badges4343 silver badges7777 bronze badges
There's a bash script which I wrote give below that makes the process a bit more user-friendly.
YMMV - it was made for Mint 14. Still learning BASH so it's probably a bit clunky. Use at own risk, but it works for me!
wibbynutwibbynut
[As an AskUbuntu noob I can't comment until reputation = 50 so don't down-vote because of this.]
My server was doing this, too. Literally none of the expected answers here worked since these require some working room on /boot for them to complete. If the boot partition is full, it will abruptly end without deleting any of the images.
The only thing that worked for me was to review the current image, then to manually
sudo rm filename
for the oldest image files (each had -3.16.0-30 in their names). Once that was done, then sudo apt-get autoremove
had the wiggle-room it needed to do its job. It did highlight some errors associated with that version, for example: 'depmod: FATAL: could not load /boot/System.map-3.16.0-30-generic: No such file or directory' but that is to be expected.When finished, the
df
returned a 42% in use for /boot to indicate that it's healthy again.Justin CaseJustin Case
I wrote this bash script to selective purge old kernels all at once:
All the bash code and instructions are included in the link.
WinEunuuchs2UnixWinEunuuchs2Unix58.5k1818 gold badges119119 silver badges232232 bronze badges
Save this script as
/usr/local/bin/remove_kernels.sh
(remember to give execute permissions sudo chmod 755 /usr/local/bin/remove_kernels.sh
):Then to remove all old kernels just type:
sudo remove_kernels.sh
Anthony KellyAnthony Kelly
/boot partition can be bit strange sometimes
do not directly start to delete kernal files.
Steps to follow
- Check for the currently installed kernal being used by linux system
uname -r
this should give you name of currently installed kernal image on system - Now start deleting extra files except that one specific installed on your system
apt-get remove linux-image-XXXXX
- Also remove the header file as well
apt-get remove linux-headers-XXXXX
- Also there may be a condition where
apt
has stopped working, in that case switch to /bootcd /boot
- Start removing files manually but very carefully also keep in the mind not deleting the
installed one's
kernal files from your system.rm linux-image-XXXXX
rm linux-image-extra-XXXXXX
- After removing the correct files cleanup partial installs if any
apt-get -f install
- Remove extra files sitting there as boot files cleaned manually
apt-get autoremove
- Update grub
update-grub
- Lastly update your system packages
apt-get update
user225user225
If you cannot remove more unused files and if you have other partition with/or free space on same device, you can resize of /boot partition by parted/gparted. (It is included on installation media, too.)
Warning: Resizing of partition is dangerous operation, save your important data on other media before doing it!
Rudolf DovičínRudolf Dovičín
protected by Community♦May 4 '14 at 15:22
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
Would you like to answer one of these unanswered questions instead?