Sunday, 30 September 2012

How to free up more space in /boot?

1. When I look at /boot I see that it is indeed very low on space, and has old-kernel files in it:
host3@host3-desktop:~/Desktop$ df -h /boot
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda7        93M   54M   34M  62% /boot


2. host3@host3-desktop:~/Desktop$ la /boot
initrd.img-3.2.0-23-generic-pae  vmlinuz-3.2.0-23-generic-pae
initrd.img-3.2.0-22-generic-pae  vmlinuz-3.2.0-22-generic-pae

initrd.img-3.2.0-21-generic-pae  vmlinuz-3.2.0-21-generic-pae
initrd.img-3.2.0-20-generic-pae  vmlinuz-3.2.0-20-generic-pae



3. Here is  lot of unused kernels. Remove all but the last kernels with:
initrd.img-3.2.0-27-generic-pae  vmlinuz-3.2.0-26-generic-pae  this is the last kernel image file, so keep it as usual. delete the others 

Use this sudo apt-get purge linux-image-{3.0.0-12,2.6.3{1-21,2-25,8-{1[012],8}}} 
or This is shorthand for:
sudo apt-get purge linux-image-3.2.0-23 linux-image-2.6.31-21 
linux-image-2.6.32-25 linux-image-2.6.38-10 
linux-image-2.6.38-11 linux-image-2.6.38-12 linux-image-2.6.38-8
 
It will remove the linux-image-x.x.x-x package will also remove  
linux-image-x.x.x-x-generic-pae
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:
dpkg -l linux-image-\* | grep ^ii
One command to show all kernels and headers that can be removed, excluding the  
current running kernel:
kernelver=$(uname -r | sed -r 's/-[a-z]+//')
dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve $kernelver
 
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 therecommendation 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:
sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" 
| awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')") 


Another way you can change the /boot partition and merge with root partion

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 ):
sudo -s
umount /boot
mount /dev/sda2 /mnt
cp -a /mnt/* /boot/
umount /mnt
gedit /etc/fstab
grub-install /dev/sda
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.
More 
http://askubuntu.com/questions/89710/how-do-i-free-up-more-space-in-boot
 


No comments:

Post a Comment

Source base installation of php, mysql and apache in ubuntu/ linux

Compile and Install a LAMP(Linux/Apache/MySQL/PHP) Server from Source In the last post, I described the method to install a LAMP ser...