How to clear space on a Ubuntu Linux boot partition

We have inherited an Ubuntu Linux server that continues to run out of space on the /boot partition and now the clean and autoclean commands are no longer working. We suspect that the problem has something to do with the old kernels never being removed. We aren't Linux experts, so are hesitant to run commands that may make this server unbootable. The  version is 3.13.0-53-generic when running the "uname -r" command.

When running the command "dpkg -l | grep linux-image-" the results are:

rc  linux-image-2.6.32-38-server                2.6.32-38.83                      Linux kernel image for version 2.6.32 on x86_64
 rc  linux-image-2.6.32-41-server                2.6.32-41.94                      Linux kernel image for version 2.6.32 on x86_64
 rc  linux-image-2.6.32-42-server                2.6.32-42.96                      Linux kernel image for version 2.6.32 on x86_64
 rc  linux-image-2.6.32-43-server                2.6.32-43.97                      Linux kernel image for version 2.6.32 on x86_64
 rc  linux-image-2.6.32-44-server                2.6.32-44.98                      Linux kernel image for version 2.6.32 on x86_64
 rc  linux-image-2.6.32-45-server                2.6.32-45.104                     Linux kernel image for version 2.6.32 on x86_64
 rc  linux-image-2.6.32-46-server                2.6.32-46.108                     Linux kernel image for version 2.6.32 on x86_64
 rc  linux-image-2.6.32-47-server                2.6.32-47.109                     Linux kernel image for version 2.6.32 on x86_64
 rc  linux-image-2.6.32-48-server                2.6.32-48.110                     Linux kernel image for version 2.6.32 on x86_64
 rc  linux-image-2.6.32-49-server                2.6.32-49.111                     Linux kernel image for version 2.6.32 on x86_64
 rc  linux-image-2.6.32-50-server                2.6.32-50.112                     Linux kernel image for version 2.6.32 on x86_64
 rc  linux-image-2.6.32-51-server                2.6.32-51.113                     Linux kernel image for version 2.6.32 on x86_64
 rc  linux-image-2.6.32-52-server                2.6.32-52.114                     Linux kernel image for version 2.6.32 on x86_64
 rc  linux-image-2.6.32-53-server                2.6.32-53.115                     Linux kernel image for version 2.6.32 on x86_64
 rc  linux-image-2.6.32-54-server                2.6.32-54.116                     Linux kernel image for version 2.6.32 on x86_64
 rc  linux-image-2.6.32-55-server                2.6.32-55.117                     Linux kernel image for version 2.6.32 on x86_64
 rc  linux-image-2.6.32-56-server                2.6.32-56.118                     Linux kernel image for version 2.6.32 on x86_64
 rc  linux-image-2.6.32-57-server                2.6.32-57.119                     Linux kernel image for version 2.6.32 on x86_64
 rc  linux-image-2.6.32-58-server                2.6.32-58.121                     Linux kernel image for version 2.6.32 on x86_64
 rc  linux-image-2.6.32-60-server                2.6.32-60.122                     Linux kernel image for version 2.6.32 on x86_64
 rc  linux-image-2.6.32-61-server                2.6.32-61.124                     Linux kernel image for version 2.6.32 on x86_64
 rc  linux-image-2.6.32-62-server                2.6.32-62.126                     Linux kernel image for version 2.6.32 on x86_64
 rc  linux-image-2.6.32-64-server                2.6.32-64.128                     Linux kernel image for version 2.6.32 on x86_64
 rc  linux-image-3.13.0-37-generic               3.13.0-37.64~precise1             Linux kernel image for version 3.13.0 on 64 bit x86 SMP
 rc  linux-image-3.13.0-39-generic               3.13.0-39.66~precise1             Linux kernel image for version 3.13.0 on 64 bit x86 SMP
 rc  linux-image-3.13.0-40-generic               3.13.0-40.69~precise1             Linux kernel image for version 3.13.0 on 64 bit x86 SMP
 rc  linux-image-3.13.0-43-generic               3.13.0-43.72~precise1             Linux kernel image for version 3.13.0 on 64 bit x86 SMP
 ii  linux-image-3.13.0-44-generic               3.13.0-44.73~precise1             Linux kernel image for version 3.13.0 on 64 bit x86 SMP
 ii  linux-image-3.13.0-46-generic               3.13.0-46.79~precise1             Linux kernel image for version 3.13.0 on 64 bit x86 SMP
 ii  linux-image-3.13.0-48-generic               3.13.0-48.80~precise1             Linux kernel image for version 3.13.0 on 64 bit x86 SMP
 ii  linux-image-3.13.0-49-generic               3.13.0-49.81~precise1             Linux kernel image for version 3.13.0 on 64 bit x86 SMP
 ii  linux-image-3.13.0-51-generic               3.13.0-51.84~precise1             Linux kernel image for version 3.13.0 on 64 bit x86 SMP
 ii  linux-image-3.13.0-52-generic               3.13.0-52.85~precise1             Linux kernel image for version 3.13.0 on 64 bit x86 SMP
 rc  linux-image-3.2.0-67-generic                3.2.0-67.101                      Linux kernel image for version 3.2.0 on 64 bit x86 SMP
 rc  linux-image-3.2.0-68-generic                3.2.0-68.102                      Linux kernel image for version 3.2.0 on 64 bit x86 SMP
 rc  linux-image-3.2.0-69-generic                3.2.0-69.103                      Linux kernel image for version 3.2.0 on 64 bit x86 SMP
 rc  linux-image-3.2.0-70-generic                3.2.0-70.105                      Linux kernel image for version 3.2.0 on 64 bit x86 SMP
 rc  linux-image-3.2.0-72-generic                3.2.0-72.107                      Linux kernel image for version 3.2.0 on 64 bit x86 SMP
 rc  linux-image-3.2.0-74-generic                3.2.0-74.109                      Linux kernel image for version 3.2.0 on 64 bit x86 SMP
 rc  linux-image-3.2.0-75-generic                3.2.0-75.110                      Linux kernel image for version 3.2.0 on 64 bit x86 SMP
 rc  linux-image-3.2.0-76-generic                3.2.0-76.111                      Linux kernel image for version 3.2.0 on 64 bit x86 SMP
 rc  linux-image-3.2.0-77-generic                3.2.0-77.114                      Linux kernel image for version 3.2.0 on 64 bit x86 SMP
 rc  linux-image-3.2.0-79-generic                3.2.0-79.115                      Linux kernel image for version 3.2.0 on 64 bit x86 SMP
 rc  linux-image-3.2.0-80-generic                3.2.0-80.116                      Linux kernel image for version 3.2.0 on 64 bit x86 SMP
 rc  linux-image-3.2.0-82-generic                3.2.0-82.119                      Linux kernel image for version 3.2.0 on 64 bit x86 SMP
 ii  linux-image-3.2.0-83-generic                3.2.0-83.120                      Linux kernel image for version 3.2.0 on 64 bit x86 SMP
 ii  linux-image-generic-lts-trusty              3.13.0.52.45                      Generic Linux kernel image
 ii  linux-image-server                          3.2.0.83.97                       Linux kernel image on Server Equipment.

Because there is so much here that doesn't make sense, I'm not sure how to run the command "sudo apt-get autoremove <old kernels>" with the correct syntax to assure that the current and most recent previous one are retained.

Any insight or help would be appreciated.
netservengAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Zephyr ICTCloud ArchitectCommented:
Well, you're off to a good start ... You also know which kernel not to delete/remove ...

I'd start by removing a few of the old and unused kernels with the following command:

sudo apt-get purge  linux-image-2.6.32-38-server 

Open in new window


Start with the 2.6 ones and work your way up, there are some newer 3.2 ones, you might hold on to a few of the higher ones and, like mentioned before, hold on to the one that is active under uname -r.

When you removed them run "sudo update-grub2"

We'll discuss later on doing automatic maintenance of these kernels.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
netservengAuthor Commented:
I ran that command and here are the results:

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  linux-image-2.6.32-38-server*
0 upgraded, 0 newly installed, 1 to remove and 12 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? y
(Reading database ... 325503 files and directories currently installed.)
Removing linux-image-2.6.32-38-server ...
Purging configuration files for linux-image-2.6.32-38-server ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 2.6.32-38-server /boot         /vmlinuz-2.6.32-38-server
update-initramfs: Deleting /boot/initrd.img-2.6.32-38-server
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 2.6.32-38-server /boot/         vmlinuz-2.6.32-38-server
Generating grub.cfg ...
Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is se         t is no longer supported.
Found linux image: /boot/vmlinuz-3.13.0-53-generic
Found initrd image: /boot/initrd.img-3.13.0-53-generic
Found linux image: /boot/vmlinuz-3.13.0-52-generic
Found initrd image: /boot/initrd.img-3.13.0-52-generic
Found linux image: /boot/vmlinuz-3.13.0-51-generic
Found initrd image: /boot/initrd.img-3.13.0-51-generic
Found linux image: /boot/vmlinuz-3.13.0-49-generic
Found initrd image: /boot/initrd.img-3.13.0-49-generic
Found linux image: /boot/vmlinuz-3.13.0-48-generic
Found initrd image: /boot/initrd.img-3.13.0-48-generic
Found linux image: /boot/vmlinuz-3.13.0-46-generic
Found initrd image: /boot/initrd.img-3.13.0-46-generic
Found linux image: /boot/vmlinuz-3.13.0-44-generic
Found initrd image: /boot/initrd.img-3.13.0-44-generic
Found linux image: /boot/vmlinuz-3.2.0-84-generic
Found initrd image: /boot/initrd.img-3.2.0-84-generic
Found memtest86+ image: /memtest86+.bin
done
Setting up initramfs-tools (0.99ubuntu13.5) ...
update-initramfs: deferring update (trigger activated)
Processing triggers for initramfs-tools ...
update-initramfs: Generating /boot/initrd.img-3.13.0-53-generic
cryptsetup: WARNING: failed to detect canonical device of /dev/sda5

gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-3.13.0-53-generic with 1.
dpkg: error processing initramfs-tools (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 initramfs-tools
E: Sub-process /usr/bin/dpkg returned an error code (1)

No space cleared after that and not sure what the errors mean.
0
Zephyr ICTCloud ArchitectCommented:
Can you run this command: lsb_release -a
Should show the version of Ubuntu ... Let me look into this error ... Might have to do with the fact there's not enough room to adjust things.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

netservengAuthor Commented:
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 12.04.5 LTS
Release:        12.04
Codename:       precise
0
Zephyr ICTCloud ArchitectCommented:
Ok, thanks ...

Try removing the memtest from Grub, might already free a little space

sudo chmod -x /etc/grub.d/20_memtest86+

Open in new window


Don't forget to do "sudo update-grub2"
0
netservengAuthor Commented:
Ran the commands and still no space available errors. Now when I run the command  "dpkg -l | grep linux-image-" it is showing the top two (I ran the command you provided to remove them) no longer there, but space is still not changing.
0
Zephyr ICTCloud ArchitectCommented:
So the kernels are gone but grub isn't updating?

Might have to do with this bug

There's a workaround mentioned in that link to comment out following:

GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0
#GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=5

In /etc/default/grub

Do "sudo nano /etc/default/grub" and see if you have these entries and comment them out, then try update grub again
0
netservengAuthor Commented:
Commented them out ran the command "sudo update-grub2". It doesn't give any errors, but there is still no available space.

Thanks for your quick responses, by the way!
0
Zephyr ICTCloud ArchitectCommented:
Hmmm ... Strange...

Try this command:

sudo apt-get purge linux-image-3.13.0-37-generic | xargs sudo apt-get -y purge

Open in new window


No problem by the way ;-)
0
Raymond van den BedumCommented:
Hi,

The correct and safest way to clean the /boot dir is:

Check the current version using:
uname -r

Open in new window


Get a list of installed kernels:
sudo dpkg --list 'linux-image*'

Open in new window


Remove a kernel version by the following command
sudo apt-get remove linux-image-VERSION

Open in new window


Replace Version with the kernel version you want to remove.
Important! only remove version older than outputted by uname -r

Cleanup unnecessary packages
sudo apt-get autoremove

Open in new window


Finally update Grub
sudo update-grub

Open in new window

0
Raymond van den BedumCommented:
I see your running on  3.13.0-53-generic, u reboot of your server shout boot you in to the latest kernel version. After verifying the current version uname -r. you should be able to remove the other ones.
0
netservengAuthor Commented:
I purged all linux-image-2.6.32-# images followed by "sudo update-grub2"  and I noticed that when I run the command "dpkg -l | grep linux-image-" all of the purged images are gone from the list but when I run the command "sudo dpkg --list 'linux-image*'" they show on the list with  "un" in front of the line.

Examples:

un  linux-image-2.6.32-53-server  <none>                        (no description available)
un  linux-image-2.6.32-54-server  <none>                        (no description available)
un  linux-image-2.6.32-55-server  <none>                        (no description available)
rc  linux-image-3.13.0-37-generic 3.13.0-37.64~precise1         Linux kernel image for version 3.13.0 on 64 bit x86 SMP


Could this be why no space is freed up on the partition after purging?
0
Zephyr ICTCloud ArchitectCommented:
Did you try the last command I put up here? You could try "remove" instead of purge now... If I'm not mistaking the "un" stands for unused...
0
netservengAuthor Commented:
No I didn't. I wasn't quite sure what it would do and it kind of worried me a bit. What will that command do?
0
Zephyr ICTCloud ArchitectCommented:
It purges or removes just the one kernel and with the second part making sure it gets cleaned up... So basically the same as before but adding some cleaning to it
0
netservengAuthor Commented:
Hi spravtek,

Actually your first reply was the solution. What I figured out was that the IT ex-employee who set this up and was in charge of maintaining it must not have been completely purging the old kernels. All of the version 2.6 images actually weren't there, just the pointers to them. I went to the /boot directory and checked the contents and found only 3.x images there. After purging 3 of the old ones with the commands you originally provided there is now 90MB available on the partition so we're breathing easier now.

Thanks for your help!
0
Zephyr ICTCloud ArchitectCommented:
Ah, I see ... That explains it then, thanks for wrapping it up, I'll keep this in mind.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.