Wednesday, April 24, 2013

On Cleaning Ubuntu's boot partition


I got two Ubuntu servers which have been shutdown for months. Upon powering them up, I did the usual "apt-get update; apt-get upgrade" on both but received the following error:

gzip: stdout: No space left on device

Did a "df -kh" and noticed the /boot partition is almost full. 

root@web-host:/boot# df -kh
Filesystem                  Size  Used Avail Use% Mounted on
/dev/mapper/web--host-root   70G  9.8G   56G  15% /
... ... 
/dev/sda1                   228M  224M     0 100% /boot

Note: Ubuntu's default /boot partition size is 228MB, and the /boot directory stores previous (unused) versions of linux in case if they are needed. 

To clean up the /boot directory:

1. Use "apt-get autoremove" and problem solved.

2. In case if this doesn't work, I found a web post with a script to remove all unused linux images.

#dpkg --get-selections|grep 'linux-image*'|awk '{print $1}'|egrep -v "linux-image-$(uname -r)|linux-image-generic" |while read n;do apt-get -y remove $n;done

While the following error still occurs occassionally, the /boot usage is reduced to 26%.
update-initramfs: Generating /boot/initrd.img-3.2.0-33-generic
gzip: stdout: No space left on device

Subsequent "apt-get update; apt-get upgrade" are successful and returns no error. 


P.S. There's this program called GParted which comes with Ubuntu Live CD (ubuntu desktop 13.0.4 ships with Gparted v.0.12.1). It allows for resizing of /boot partition. 

However, if the Ubuntu servers have Logical Volume Manager (LVM) on its sda5 partition (sitting on top of sda2), then use Gparted's own live CD (v.0.14) which supports resizing LVM.


2 comments:

  1. If you're trying to lose weight then you certainly have to jump on this totally brand new personalized keto plan.

    To create this service, certified nutritionists, fitness couches, and top chefs united to produce keto meal plans that are efficient, suitable, money-efficient, and delightful.

    Since their launch in 2019, thousands of people have already completely transformed their body and well-being with the benefits a proper keto plan can give.

    Speaking of benefits; in this link, you'll discover eight scientifically-tested ones provided by the keto plan.

    ReplyDelete