netserveng
asked on
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-serv er 2.6.32-38.83 Linux kernel image for version 2.6.32 on x86_64
rc linux-image-2.6.32-41-serv er 2.6.32-41.94 Linux kernel image for version 2.6.32 on x86_64
rc linux-image-2.6.32-42-serv er 2.6.32-42.96 Linux kernel image for version 2.6.32 on x86_64
rc linux-image-2.6.32-43-serv er 2.6.32-43.97 Linux kernel image for version 2.6.32 on x86_64
rc linux-image-2.6.32-44-serv er 2.6.32-44.98 Linux kernel image for version 2.6.32 on x86_64
rc linux-image-2.6.32-45-serv er 2.6.32-45.104 Linux kernel image for version 2.6.32 on x86_64
rc linux-image-2.6.32-46-serv er 2.6.32-46.108 Linux kernel image for version 2.6.32 on x86_64
rc linux-image-2.6.32-47-serv er 2.6.32-47.109 Linux kernel image for version 2.6.32 on x86_64
rc linux-image-2.6.32-48-serv er 2.6.32-48.110 Linux kernel image for version 2.6.32 on x86_64
rc linux-image-2.6.32-49-serv er 2.6.32-49.111 Linux kernel image for version 2.6.32 on x86_64
rc linux-image-2.6.32-50-serv er 2.6.32-50.112 Linux kernel image for version 2.6.32 on x86_64
rc linux-image-2.6.32-51-serv er 2.6.32-51.113 Linux kernel image for version 2.6.32 on x86_64
rc linux-image-2.6.32-52-serv er 2.6.32-52.114 Linux kernel image for version 2.6.32 on x86_64
rc linux-image-2.6.32-53-serv er 2.6.32-53.115 Linux kernel image for version 2.6.32 on x86_64
rc linux-image-2.6.32-54-serv er 2.6.32-54.116 Linux kernel image for version 2.6.32 on x86_64
rc linux-image-2.6.32-55-serv er 2.6.32-55.117 Linux kernel image for version 2.6.32 on x86_64
rc linux-image-2.6.32-56-serv er 2.6.32-56.118 Linux kernel image for version 2.6.32 on x86_64
rc linux-image-2.6.32-57-serv er 2.6.32-57.119 Linux kernel image for version 2.6.32 on x86_64
rc linux-image-2.6.32-58-serv er 2.6.32-58.121 Linux kernel image for version 2.6.32 on x86_64
rc linux-image-2.6.32-60-serv er 2.6.32-60.122 Linux kernel image for version 2.6.32 on x86_64
rc linux-image-2.6.32-61-serv er 2.6.32-61.124 Linux kernel image for version 2.6.32 on x86_64
rc linux-image-2.6.32-62-serv er 2.6.32-62.126 Linux kernel image for version 2.6.32 on x86_64
rc linux-image-2.6.32-64-serv er 2.6.32-64.128 Linux kernel image for version 2.6.32 on x86_64
rc linux-image-3.13.0-37-gene ric 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-gene ric 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-gene ric 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-gene ric 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-gene ric 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-gene ric 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-gene ric 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-gene ric 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-gene ric 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-gene ric 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-gener ic 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-gener ic 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-gener ic 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-gener ic 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-gener ic 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-gener ic 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-gener ic 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-gener ic 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-gener ic 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-gener ic 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-gener ic 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-gener ic 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-gener ic 3.2.0-83.120 Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii linux-image-generic-lts-tr usty 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.
When running the command "dpkg -l | grep linux-image-" the results are:
rc linux-image-2.6.32-38-serv
rc linux-image-2.6.32-41-serv
rc linux-image-2.6.32-42-serv
rc linux-image-2.6.32-43-serv
rc linux-image-2.6.32-44-serv
rc linux-image-2.6.32-45-serv
rc linux-image-2.6.32-46-serv
rc linux-image-2.6.32-47-serv
rc linux-image-2.6.32-48-serv
rc linux-image-2.6.32-49-serv
rc linux-image-2.6.32-50-serv
rc linux-image-2.6.32-51-serv
rc linux-image-2.6.32-52-serv
rc linux-image-2.6.32-53-serv
rc linux-image-2.6.32-54-serv
rc linux-image-2.6.32-55-serv
rc linux-image-2.6.32-56-serv
rc linux-image-2.6.32-57-serv
rc linux-image-2.6.32-58-serv
rc linux-image-2.6.32-60-serv
rc linux-image-2.6.32-61-serv
rc linux-image-2.6.32-62-serv
rc linux-image-2.6.32-64-serv
rc linux-image-3.13.0-37-gene
rc linux-image-3.13.0-39-gene
rc linux-image-3.13.0-40-gene
rc linux-image-3.13.0-43-gene
ii linux-image-3.13.0-44-gene
ii linux-image-3.13.0-46-gene
ii linux-image-3.13.0-48-gene
ii linux-image-3.13.0-49-gene
ii linux-image-3.13.0-51-gene
ii linux-image-3.13.0-52-gene
rc linux-image-3.2.0-67-gener
rc linux-image-3.2.0-68-gener
rc linux-image-3.2.0-69-gener
rc linux-image-3.2.0-70-gener
rc linux-image-3.2.0-72-gener
rc linux-image-3.2.0-74-gener
rc linux-image-3.2.0-75-gener
rc linux-image-3.2.0-76-gener
rc linux-image-3.2.0-77-gener
rc linux-image-3.2.0-79-gener
rc linux-image-3.2.0-80-gener
rc linux-image-3.2.0-82-gener
ii linux-image-3.2.0-83-gener
ii linux-image-generic-lts-tr
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
ASKER
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 12.04.5 LTS
Release: 12.04
Codename: precise
Distributor ID: Ubuntu
Description: Ubuntu 12.04.5 LTS
Release: 12.04
Codename: precise
Ok, thanks ...
Try removing the memtest from Grub, might already free a little space
Don't forget to do "sudo update-grub2"
Try removing the memtest from Grub, might already free a little space
sudo chmod -x /etc/grub.d/20_memtest86+
Don't forget to do "sudo update-grub2"
ASKER
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.
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
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
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
ASKER
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!
Thanks for your quick responses, by the way!
Hmmm ... Strange...
Try this command:
No problem by the way ;-)
Try this command:
sudo apt-get purge linux-image-3.13.0-37-generic | xargs sudo apt-get -y purge
No problem by the way ;-)
Hi,
The correct and safest way to clean the /boot dir is:
Check the current version using:
Get a list of installed kernels:
Remove a kernel version by the following command
Replace Version with the kernel version you want to remove.
Important! only remove version older than outputted by uname -r
Cleanup unnecessary packages
Finally update Grub
The correct and safest way to clean the /boot dir is:
Check the current version using:
uname -r
Get a list of installed kernels:
sudo dpkg --list 'linux-image*'
Remove a kernel version by the following command
sudo apt-get remove linux-image-VERSION
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
Finally update Grub
sudo update-grub
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.
ASKER
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-serv er <none> (no description available)
un linux-image-2.6.32-54-serv er <none> (no description available)
un linux-image-2.6.32-55-serv er <none> (no description available)
rc linux-image-3.13.0-37-gene ric 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?
Examples:
un linux-image-2.6.32-53-serv
un linux-image-2.6.32-54-serv
un linux-image-2.6.32-55-serv
rc linux-image-3.13.0-37-gene
Could this be why no space is freed up on the partition after purging?
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...
ASKER
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?
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
ASKER
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!
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!
Ah, I see ... That explains it then, thanks for wrapping it up, I'll keep this in mind.
ASKER
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
linux-image-2.6.32-38-serv
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-serv
Purging configuration files for linux-image-2.6.32-38-serv
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initr
update-initramfs: Deleting /boot/initrd.img-2.6.32-38
run-parts: executing /etc/kernel/postrm.d/zz-up
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-ge
Found initrd image: /boot/initrd.img-3.13.0-53
Found linux image: /boot/vmlinuz-3.13.0-52-ge
Found initrd image: /boot/initrd.img-3.13.0-52
Found linux image: /boot/vmlinuz-3.13.0-51-ge
Found initrd image: /boot/initrd.img-3.13.0-51
Found linux image: /boot/vmlinuz-3.13.0-49-ge
Found initrd image: /boot/initrd.img-3.13.0-49
Found linux image: /boot/vmlinuz-3.13.0-48-ge
Found initrd image: /boot/initrd.img-3.13.0-48
Found linux image: /boot/vmlinuz-3.13.0-46-ge
Found initrd image: /boot/initrd.img-3.13.0-46
Found linux image: /boot/vmlinuz-3.13.0-44-ge
Found initrd image: /boot/initrd.img-3.13.0-44
Found linux image: /boot/vmlinuz-3.2.0-84-gen
Found initrd image: /boot/initrd.img-3.2.0-84-
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
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
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.