Welcome to the web's most helpful Online Free computer tips and tricks website. This site contains all Latest and Cool Computer tricks as well as some Internet Tricks, Registry tricks, Orkut tricks, Windows customize and Optimization tricks, Computer Tweaks. Solve your computer problems by browsing the website for related Computer solution. All tips work well in both Windows XP as well as windows vista or win 7 operating systems. Need some Computer Help? Then this website suites your must need. These windows and internet Hacks Tricks are safe and free from any Spy ware. Learn All Basic and Advanced computer tips and tricks and be a computer master. All the computer tips at Hack2011 are very interesting and are mainly meant for education purpose. Visit my new Computer Tips Blog and leave your comments and suggestions there. Enjoy your stay and read all the articles posted here.


Remove Outdated Kernels and Headers to Save Space (Linux)


Open Terminal
Linux is effectively made up of two parts.  First is the kernel, the code that interacts with the computer’s hardware, and then there is the desktop environment, the software that the user interacts with (and in turn, what interacts with the kernel).
The Linux kernel is under constant development, with new releases available every few weeks.  Your Linux distribution might not make every new update available in the software repositories, but if you’ve had a particular distribution installed for half a year or so, it’s likely you’ve managed to accumulate 3 or 4 kernels, maybe more.


In Ubuntu, and other distributions, when a new kernel is installed, it becomes the default automatically.  This means that once a new kernel is in use, all the other kernels effectively become obsolete.
That’s not to say that you should get rid of old kernels the second you install an update, because sometimes something new and shiny can also break things.  However, once you’ve tested the new kernel and have declared it fit for service on your computer, you can go ahead and delete the ones not in use.  Here’s how.
In Ubuntu, at least, there are two different “parts” of the kernel.  The kernel image itself, and the kernel headers.  The kernel image is the running binary, while the kernel headers are descriptive of the kernel, so other software that needs to be compiled to run on that kernel (such as graphics card and wireless drivers), can be compiled correctly.  When you delete a kernel image, the headers become useless, so both can be deleted.

The first step in deleting out-of-date kernel images and headers is to find out what kernel is currently running.  To do this, we’ll first open a Terminal.  The Terminal can be found in the Applications menu, under Accessories.
Open Terminal
Once running, type the following:
uname -r
This should spit out a single line answer, like this:
2.6.35-28-generic
This tells us that the currently running kernel is version 2.6.35-28-generic, so when we delete our old kernels, this is the only one to be sure to keep.
Now that we know our current kernel, we can delete the old ones.  We can do this in two ways.  In the first way, we stay in the Terminal.  To delete our old kernel images, type the following (you’ll be hitting the Tab key instead of typing “<TAB>” when it appears in the next couple commands):
sudo apt-get remove linux-image-<TAB>
The Tab key will autocomplete to show us any installed item that matches “linux-image-” such as shown below:
Installed Linux Images
As you can see, there are currently two different kernels, version 2.6.35-28 being the one in use, and two older versions, 2.6.35.25 and 2.6.35.27, neither of which are in use.
We can now do the same thing, only finding headers.  To do this, type the following:
sudo apt-get remove linux-headers-<TAB>
Once again, you’ll see a list of all the header files currently installed.  There are two files for each kernel, one called something similar to “linux-headers-2.6.35-25″ and one with “-generic” added to the end.  You can see that in this image:
Installed Linux Headers
As with the linux images, we have a set of headers for kernel 2.6.35-25, one for 2.6.35-27, and one (in use), for 2.6.35-28, which we will not delete.
To delete all the unused kernel images and headers, we would simply type the following:
sudo apt-get remove linux-image-2.6.35-25-generic linux-image-2.6.35-27-generic linux-headers-2.6.35-25 linux-headers-2.6.35-25-generic linux-headers-2.6.35-27 linux-headers-2.6.35-27-generic –purge
Note: this will be different, of course, depending on which kernels you have installed.
As you can see, this results in quite a bit of hard drive space reclaimed.  In this instance (with two extra kernels and header sets), we get back nearly 400 MB of space.
Removing Kernels and Headers
Now, simply provide your password when asked, and wait for a few seconds while the old kernels and headers are removed.
And that’s it!  You can also accomplish the identical task by using your package manager, such as Synaptic or the Ubuntu Software Center (if you’re using Ubuntu), but the Terminal method is, at least for some, a lot quicker, and just as effective.

No comments:

Post a Comment