Tag Archives: kernel

How to Solve Ubuntu Server /boot full Issue Tips, Tricks and Tutorials 19 FEB 2016

If you manage an older Ubuntu server and do a lot of updates/upgrades, inevitably you’ll hit the annoying /boot full issue, which is essentially what happens when the ridiculously tiny /boot folder gets filled up with older kernel version as a result of all your upgrading.

To spot if this is in fact what currently plagues you, simply run the following command to get a quick snapshot of disk space usage:

sudo df -h

If your /boot directory is indeed full or close to 100%, you can run the following command that automatically locates and removes older kernels and headers from the system:

sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')")

With those gone, you can now clean up a bit further by removing packages that aren’t necessarily needed any more (because they were automatically installed to satisfy dependencies for the newly removed packages):

sudo apt-get autoremove
sudo apt-get --purge remove && sudo apt-get autoclean

This should solve your issue.

cat using laptop

Note: If you can’t use apt-get at all because of this problem, you can try to manually delete the kernels yourself. Run the following to get an idea of what can be removed:

dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')"

With that list now in your possession, craft a remove operation using those version numbers listed above, followed by an attempt to solve the new dependency issue with apt-get e.g.

sudo rm -rf /boot/*-3.2.0-{101,102,103}-*
sudo apt-get -f install

(As always though, tread with care though when it comes to messing with this part of your server install…)

Ubuntu Server fstab Failed Tips, Tricks and Tutorials 19 JUN 2014

Oh dear. On return from a lovely long weekend away at Piekenierskloof Mountain Resort, we discovered that our XBMC media server had inexplicably died – essentially the primary hard drive just would’t load the XBMCbuntu operating system any more. With a very dejected Jessica (no My Little Pony: Friendship is Magic for her), I set about re-installing XBMC 13.0 “Gotham”, and of course, I became just a little too clever for my own boots.

There are two old hard drives in the old machine, one larger than the other. So naturally I installed XBMCbuntu on the smaller of the two, formatted the larger drive to ext4 and then symbolic linked the Movies and TV Shows folders on the primary drive so that they point to the second drive (essentially I want to store all video content on the larger drive, but without going through all the hassles of maintaining multiple sources in XBMC).

Knowing that I need to auto-mount the second drive in order for this to work, I added the UUID mount command in the /etc/fstab file as per norm, and it was at this time that I spotted some great tips on optimizing drive speed by adding parameters like noatime and data=writeback. Without doing any proper research, I added in the options to all my hard drive mounts in fstab, and of course, on reboot the system fell over.

So how do your recover from a mount fail because of a bad or corrupt fstab file?

Essentially you need to be able to boot into the system with write access and a mounted / path so that you can alter the fstab file and try and get it back into a stable state. To do this, you need to access the GRUB menu and alter the kernel parameters of your Ubuntu load string.

First, if your box doesn’t come up with the GRUB menu automatically before continuing, you can force this by rebooting your computer and holding down SHIFT. Once the GRUB menu is up, select the Linux entry you want to load and press ‘e’ to edit it.

In the edit view, locate the kernel entry – it should look something similar to this:

linux   /boot/vmlinuz-3.5.0-23-generic root=UUID=862e9bd8-8641-478a-96a3-d5ad9a53b104 ro find_preseed=/preseed.cfg noprompt  quiet

Add the following at the end of the kernel entry:

rw init=/bin/bash

Save your changes and launch the edited entry – your machine will boot and you should end up in a bash prompt environment. The / path is mounted in read/write mode, meaning you can now go ahead and edit (read: fix) /etc/fstab, save your changes, and reboot!

ubuntu black and orange logo

Clear Up Some Space on your Ubuntu Server Install Tips, Tricks and Tutorials 25 NOV 2013

ubuntu orange logoI ran into an issue the other day installing VMWare Tools on a virtual server whereby the installer was moaning about not having enough space in the /boot directory in order to continue with the installation.

(Now of course, unless you’re a seasoned Linux pro, you don’t really want to be messing about with your /boot folder, even if you’re confident that after running uname -r you’re kind of 100% sure which kernel files you can safely remove! In other words, tread carefully and always have backups on hand.)

Thankfully there are some pretty useful commands that you can run in order to help you free up some much needed space, commands that remove unused kernels, left over dependencies, and just plain old cached .deb files!

To remove old kernels, inspect your /boot folder. If you run uname -r you’ll see your currently used kernel version. This is the one you want to keep, so make a note. (Oh, and it’s also usually a good idea to hang on one older one for just in case.)

The Ubuntu Forums offered up this particularly handy little command to list all the kernels and headers that can be removed, excluding the current running kernel:

dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')"

Now you can remove unneeded kernels one by one using the apt-get purge command (e.g. sudo apt-get purge linux-image-x.x.x-x), or you can make use of the above snippet to blast everything away at once:

sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')")

(Risky, I know, but it is a time saver if you have a lot of unused kernels lying around)

Next up in terms of clearing up some space on your Ubuntu install is making use of the sudo apt-get commands ‘autoclean’, ‘clean’ and ‘autoremove’.

From the apt-get MAN pages:

clean: clean clears out the local repository of retrieved package files. It removes everything but the lock file from /var/cache/apt/archives/ and /var/cache/apt/archives/partial/.

autoclean: Like clean, autoclean clears out the local repository of retrieved package files. The difference is that it only removes package files that can no longer be downloaded, and are largely useless. This allows a cache to be maintained over a long period without it growing out of control.

autoremove: is used to remove packages that were automatically installed to satisfy dependencies for some package and that are no longer needed.

First, run the autoclean package command that essentially removes partial package from the system, followed by the clean command that removes .deb packages that apt caches when you install, update, or upgrade:

sudo apt-get autoclean
sudo apt-get clean

Now run the autoremove command to remove any packages that should technically no longer be needed:

sudo apt-get autoremove

There, that should have freed up some space for you!

(Reminder to myself: I tend to Google this to get here: ubuntu server /dev/sda1 full)