TurnKey Linux Virtual Appliance Library

/lib/modules occupied disk space

I notice the folder /lib/modules has occupied my hard disk space:

root@ldap /lib/modules# pwd
/lib/modules

root@ldap /lib/modules# ls -al
total 48
drwxr-xr-x 10 root root  4096 Sep 18 07:00 .
drwxr-xr-x 18 root root 12288 Aug 10 07:11 ..
drwxr-xr-x  4 root root  4096 Dec  3  2011 2.6.32-36-generic
drwxr-xr-x  4 root root  4096 Dec 20  2011 2.6.32-37-generic
drwxr-xr-x  4 root root  4096 Jan 27  2012 2.6.32-38-generic
drwxr-xr-x  4 root root  4096 Mar  6  2012 2.6.32-39-generic
drwxr-xr-x  4 root root  4096 Mar 27 08:02 2.6.32-40-generic
drwxr-xr-x  4 root root  4096 Jun 29 06:34 2.6.32-41-generic
drwxr-xr-x  4 root root  4096 Sep  5 07:20 2.6.32-42-generic
drwxr-xr-x  4 root root  4096 Sep 18 07:00 2.6.32-43-generic

root@ldap /lib/modules# du -h --max-depth=1
89M     ./2.6.32-42-generic
89M     ./2.6.32-36-generic
89M     ./2.6.32-39-generic
89M     ./2.6.32-41-generic
89M     ./2.6.32-38-generic
89M     ./2.6.32-43-generic
89M     ./2.6.32-40-generic
89M     ./2.6.32-37-generic
707M    .

How may I identify unuse folders and clean it up?  Also, how may I stop the system to keep download new updates to my system?

The /boot folder also similar situations:

root@ldap /boot# pwd
/boot
root@ldap /boot# ls -al
total 194184
drwxr-xr-x  3 root root     4096 Sep 18 07:01 .
drwxr-xr-x 22 root root     4096 Sep 18 07:01 ..
-rw-r--r--  1 root root  1690205 Nov 24  2010 System.map-2.6.32-26-generic
-rw-r--r--  1 root root  1690625 Jul  8  2011 System.map-2.6.32-33-generic
-rw-r--r--  1 root root  1691092 Sep 14  2011 System.map-2.6.32-34-generic
-rw-r--r--  1 root root  1691417 Oct 11  2011 System.map-2.6.32-35-generic
-rw-r--r--  1 root root  1691417 Nov  9  2011 System.map-2.6.32-36-generic
-rw-r--r--  1 root root  1691509 Dec  3  2011 System.map-2.6.32-37-generic
-rw-r--r--  1 root root  1692624 Jan  4  2012 System.map-2.6.32-38-generic
-rw-r--r--  1 root root  1693223 Feb 14  2012 System.map-2.6.32-39-generic
-rw-r--r--  1 root root  1693462 Mar  6  2012 System.map-2.6.32-40-generic
-rw-r--r--  1 root root  1694221 Jun 13 12:41 System.map-2.6.32-41-generic
-rw-r--r--  1 root root  1694274 Aug 15 19:53 System.map-2.6.32-42-generic
-rw-r--r--  1 root root  1694274 Sep  5 17:43 System.map-2.6.32-43-generic
-rw-r--r--  1 root root   651949 Nov 24  2010 abi-2.6.32-26-generic
-rw-r--r--  1 root root   652139 Jul  8  2011 abi-2.6.32-33-generic
-rw-r--r--  1 root root   652395 Sep 14  2011 abi-2.6.32-34-generic
-rw-r--r--  1 root root   652505 Oct 11  2011 abi-2.6.32-35-generic
-rw-r--r--  1 root root   652505 Nov  9  2011 abi-2.6.32-36-generic
-rw-r--r--  1 root root   652505 Dec  3  2011 abi-2.6.32-37-generic
-rw-r--r--  1 root root   652611 Jan  4  2012 abi-2.6.32-38-generic
-rw-r--r--  1 root root   652718 Feb 14  2012 abi-2.6.32-39-generic
-rw-r--r--  1 root root   652770 Mar  6  2012 abi-2.6.32-40-generic
-rw-r--r--  1 root root   652956 Jun 13 12:41 abi-2.6.32-41-generic
-rw-r--r--  1 root root   652956 Aug 15 19:53 abi-2.6.32-42-generic
-rw-r--r--  1 root root   652956 Sep  5 17:43 abi-2.6.32-43-generic
-rw-r--r--  1 root root   116048 Nov 24  2010 config-2.6.32-26-generic
-rw-r--r--  1 root root   116025 Jul  8  2011 config-2.6.32-33-generic
-rw-r--r--  1 root root   116025 Sep 14  2011 config-2.6.32-34-generic
-rw-r--r--  1 root root   116025 Oct 11  2011 config-2.6.32-35-generic
-rw-r--r--  1 root root   116025 Nov  9  2011 config-2.6.32-36-generic
-rw-r--r--  1 root root   116025 Dec  3  2011 config-2.6.32-37-generic
-rw-r--r--  1 root root   116014 Jan  4  2012 config-2.6.32-38-generic
-rw-r--r--  1 root root   116014 Feb 14  2012 config-2.6.32-39-generic
-rw-r--r--  1 root root   116014 Mar  6  2012 config-2.6.32-40-generic
-rw-r--r--  1 root root   116014 Jun 13 12:41 config-2.6.32-41-generic
-rw-r--r--  1 root root   116014 Aug 15 19:53 config-2.6.32-42-generic
-rw-r--r--  1 root root   116014 Sep  5 17:43 config-2.6.32-43-generic
drwxr-xr-x  3 root root     4096 Sep 18 07:01 grub
-rw-r--r--  1 root root 10009030 Dec 19  2010 initrd.img-2.6.32-26-generic
-rw-r--r--  1 root root 10046359 Jul 22  2011 initrd.img-2.6.32-33-generic
-rw-r--r--  1 root root 10048286 Sep 30  2011 initrd.img-2.6.32-34-generic
-rw-r--r--  1 root root 10048033 Nov  9  2011 initrd.img-2.6.32-35-generic
-rw-r--r--  1 root root 10047412 Dec  3  2011 initrd.img-2.6.32-36-generic
-rw-r--r--  1 root root 10048356 Dec 20  2011 initrd.img-2.6.32-37-generic
-rw-r--r--  1 root root 10047966 Jan 27  2012 initrd.img-2.6.32-38-generic
-rw-r--r--  1 root root 10048417 Mar  6  2012 initrd.img-2.6.32-39-generic
-rw-r--r--  1 root root 10047734 Mar 27 08:03 initrd.img-2.6.32-40-generic
-rw-r--r--  1 root root 10047641 Jun 29 06:34 initrd.img-2.6.32-41-generic
-rw-r--r--  1 root root 10048621 Sep  5 07:21 initrd.img-2.6.32-42-generic
-rw-r--r--  1 root root 10049358 Sep 18 07:01 initrd.img-2.6.32-43-generic
-rw-r--r--  1 root root     1196 Nov 24  2010 vmcoreinfo-2.6.32-26-generic
-rw-r--r--  1 root root     1196 Jul  8  2011 vmcoreinfo-2.6.32-33-generic
-rw-r--r--  1 root root     1196 Sep 14  2011 vmcoreinfo-2.6.32-34-generic
-rw-r--r--  1 root root     1196 Oct 11  2011 vmcoreinfo-2.6.32-35-generic
-rw-r--r--  1 root root     1196 Nov  9  2011 vmcoreinfo-2.6.32-36-generic
-rw-r--r--  1 root root     1196 Dec  3  2011 vmcoreinfo-2.6.32-37-generic
-rw-r--r--  1 root root     1196 Jan  4  2012 vmcoreinfo-2.6.32-38-generic
-rw-r--r--  1 root root     1196 Feb 14  2012 vmcoreinfo-2.6.32-39-generic
-rw-r--r--  1 root root     1196 Mar  6  2012 vmcoreinfo-2.6.32-40-generic
-rw-r--r--  1 root root     1196 Jun 13 12:42 vmcoreinfo-2.6.32-41-generic
-rw-r--r--  1 root root     1196 Aug 15 19:53 vmcoreinfo-2.6.32-42-generic
-rw-r--r--  1 root root     1196 Sep  5 17:45 vmcoreinfo-2.6.32-43-generic
-rw-r--r--  1 root root  4037888 Nov 24  2010 vmlinuz-2.6.32-26-generic
-rw-r--r--  1 root root  4036896 Jul  8  2011 vmlinuz-2.6.32-33-generic
-rw-r--r--  1 root root  4040128 Sep 14  2011 vmlinuz-2.6.32-34-generic
-rw-r--r--  1 root root  4039584 Oct 11  2011 vmlinuz-2.6.32-35-generic
-rw-r--r--  1 root root  4039648 Nov  9  2011 vmlinuz-2.6.32-36-generic
-rw-r--r--  1 root root  4041088 Dec  3  2011 vmlinuz-2.6.32-37-generic
-rw-r--r--  1 root root  4048512 Jan  4  2012 vmlinuz-2.6.32-38-generic
-rw-r--r--  1 root root  4048992 Feb 14  2012 vmlinuz-2.6.32-39-generic
-rw-r--r--  1 root root  4049152 Mar  6  2012 vmlinuz-2.6.32-40-generic
-rw-r--r--  1 root root  4050752 Jun 13 12:41 vmlinuz-2.6.32-41-generic
-rw-r--r--  1 root root  4050144 Aug 15 19:53 vmlinuz-2.6.32-42-generic
-rw-r--r--  1 root root  4050048 Sep  5 17:43 vmlinuz-2.6.32-43-generic
Jeremy's picture

These are kernel modules

And it looks like you have a number of kernels installed. The best (and safest) way to go would be to remove the old kernels.

The first thing to do would be to do a full backup of your system (just in case things go pear shaped).

Then check which kernel you are using

uname -r

I'd hazard a guess that it's the most recent one: 2.6.32-43-generic. Don't uninstall that one! And if you have installed that one recently, I wouldn't uninstall the previous one either (just in case).

So it's a case of uninstalling them one-by-one. You can get the kernel version numbers from what you've listed above. Eg for kernel 2.6.32-26:

apt-get --purge remove linux-image-2.6.32-26-generic linux-headers-2.6.32-26-generic

It is possible the headers aren't installed, if so you can omit that part (ie linux-headers-2.6.32-26-generic). Then just uninstalling them one by one, until you are left with just the one you are currently running (or perhaps 2 if you want to play it safe).

Reboot to test you don't get any nasty surprises later. But only after you have backed up all your important data (if you uninstall the wrong kernel your system may not boot!!!)

Thanks. It works.  After

Thanks. It works.  After uninstall unused package, the /lib/modules left this:

root@ldap /boot# ls /lib/modules/ -al
total 20
drwxr-xr-x  3 root root  4096 Sep 22 09:28 .
drwxr-xr-x 18 root root 12288 Sep 21 06:56 ..
drwxr-xr-x  4 root root  4096 Sep 18 07:00 2.6.32-43-generic

But the /boot still has these files:

root@ldap /boot# ls /boot -al
total 80868
drwxr-xr-x  3 root root     4096 Sep 22 09:28 .
drwxr-xr-x 22 root root     4096 Sep 22 09:28 ..
-rw-r--r--  1 root root  1690205 Nov 24  2010 System.map-2.6.32-26-generic
-rw-r--r--  1 root root  1690625 Jul  8  2011 System.map-2.6.32-33-generic
-rw-r--r--  1 root root  1691092 Sep 14  2011 System.map-2.6.32-34-generic
-rw-r--r--  1 root root  1691417 Oct 11  2011 System.map-2.6.32-35-generic
-rw-r--r--  1 root root  1694274 Sep  5 17:43 System.map-2.6.32-43-generic
-rw-r--r--  1 root root   651949 Nov 24  2010 abi-2.6.32-26-generic
-rw-r--r--  1 root root   652139 Jul  8  2011 abi-2.6.32-33-generic
-rw-r--r--  1 root root   652395 Sep 14  2011 abi-2.6.32-34-generic
-rw-r--r--  1 root root   652505 Oct 11  2011 abi-2.6.32-35-generic
-rw-r--r--  1 root root   652956 Sep  5 17:43 abi-2.6.32-43-generic
-rw-r--r--  1 root root   116048 Nov 24  2010 config-2.6.32-26-generic
-rw-r--r--  1 root root   116025 Jul  8  2011 config-2.6.32-33-generic
-rw-r--r--  1 root root   116025 Sep 14  2011 config-2.6.32-34-generic
-rw-r--r--  1 root root   116025 Oct 11  2011 config-2.6.32-35-generic
-rw-r--r--  1 root root   116014 Sep  5 17:43 config-2.6.32-43-generic
drwxr-xr-x  3 root root     4096 Sep 22 09:28 grub
-rw-r--r--  1 root root 10009030 Dec 19  2010 initrd.img-2.6.32-26-generic
-rw-r--r--  1 root root 10046359 Jul 22  2011 initrd.img-2.6.32-33-generic
-rw-r--r--  1 root root 10048286 Sep 30  2011 initrd.img-2.6.32-34-generic
-rw-r--r--  1 root root 10048033 Nov  9  2011 initrd.img-2.6.32-35-generic
-rw-r--r--  1 root root 10049358 Sep 18 07:01 initrd.img-2.6.32-43-generic
-rw-r--r--  1 root root     1196 Nov 24  2010 vmcoreinfo-2.6.32-26-generic
-rw-r--r--  1 root root     1196 Jul  8  2011 vmcoreinfo-2.6.32-33-generic
-rw-r--r--  1 root root     1196 Sep 14  2011 vmcoreinfo-2.6.32-34-generic
-rw-r--r--  1 root root     1196 Oct 11  2011 vmcoreinfo-2.6.32-35-generic
-rw-r--r--  1 root root     1196 Sep  5 17:45 vmcoreinfo-2.6.32-43-generic
-rw-r--r--  1 root root  4037888 Nov 24  2010 vmlinuz-2.6.32-26-generic
-rw-r--r--  1 root root  4036896 Jul  8  2011 vmlinuz-2.6.32-33-generic
-rw-r--r--  1 root root  4040128 Sep 14  2011 vmlinuz-2.6.32-34-generic
-rw-r--r--  1 root root  4039584 Oct 11  2011 vmlinuz-2.6.32-35-generic
-rw-r--r--  1 root root  4050048 Sep  5 17:43 vmlinuz-2.6.32-43-generic

Are those old kernel still use?  How to remove them?

Also, how to stop the automatic updating service?

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <p> <span> <div> <h1> <h2> <h3> <h4> <h5> <h6> <img> <map> <area> <hr> <br> <br /> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <em> <b> <u> <i> <strong> <font> <del> <ins> <sub> <sup> <quote> <blockquote> <pre> <address> <code> <cite> <strike> <caption>

More information about formatting options

Leave this field empty. It's part of a security mechanism.
(Dear spammers: moderators are notified of all new posts. Spam is deleted immediately)