The other day when I attempted to run some regular updates for my Linux box (running Ubuntu 14.04 LTS), I encountered the message that the update could no proceed because the boot partition was full. Here are the steps I took to clear unneeded files from the boot partition.
1. First, I found out that I am running kernel 3.19.0-65 with this command below.
me@computer:~$ uname -r 3.19.0-65-generic
2. Next, list what kernel images are present in my root partition.
me@computer:~$ dpkg --list | grep linux-image ii linux-image-3.19.0-61-generic 3.19.0-61.69~14.04.1 amd64 Linux kernel image for version 3.19.0 on 64 bit x86 SMP ii linux-image-3.19.0-65-generic 3.19.0-65.73~14.04.1 amd64 Linux kernel image for version 3.19.0 on 64 bit x86 SMP ii linux-image-extra-3.19.0-61-generic 3.19.0-61.69~14.04.1 amd64 Linux kernel extra modules for version 3.19.0 on 64 bit x86 SMP ii linux-image-extra-3.19.0-65-generic 3.19.0-65.73~14.04.1 amd64 Linux kernel extra modules for version 3.19.0 on 64 bit x86 SMP ii linux-image-generic-lts-vivid 3.19.0.65.47 amd64 Generic Linux kernel image
3. The above was actually a truncated example; the actual list was much longer. In summary, I had many older kernel images that I do not need anymore. In the example shown above, I decided that since I am running 3.19.0-65, I will not need the -61 image anymore. Below is the command I used to clear out -61; I ran similar commands for all the kernel images with even lower versions as well to clear up space.
me@computer:~$ sudo apt-get purge linux-image-3.19.0-61-generic Reading package lists... Done Building dependency tree Reading state information... Done The following packages will be REMOVED: linux-image-3.19.0-61-generic* 0 upgraded, 0 newly installed, 1 to remove and 8 not upgraded. After this operation, 47.8 MB disk space will be freed. Do you want to continue? [Y/n] Y ...
4. Finally, check out the contents of the /boot/ directory. If you see any orphaned files from older kernels, consider removing them to save space.
Bonus: Useful related commands
sudo apt-get autoremove sudo apt-get clean sudo apt-get update sudo apt-get dist-upgrade
“autoremove” gets rid of packages that were automatically installed previously, but are no longer needed.
“cleans” empties /var/cache/apt/archives/ and /var/cache/apt/archives/partial/.
“update” updates apt-get’s list of available software packages.
“dist-upgrade” is best explained via its man page entry:
dist-upgrade in addition to performing the function of upgrade, also intelligently handles changing dependencies with new versions of packages; apt-get has a “smart” conflict resolution system, and it will attempt to upgrade the most important packages at the expense of less important ones if necessary. The dist-upgrade command may therefore remove some packages.