Craig Thompson
2012-Feb-15 20:30 UTC
[CentOS] question on unused directories in /usr/lib and /usr/lib64
I was working on archiving an old virtual server today and was reminded of how much space is wasted by some of the default installations on CentOS. I think this was a 5.x box. Anyway, in /usr/lib/64 (and probably /usr/lib on non-64 systems), there were a lot of directories which have no bearing on a basic server. I saw firefox, openoffice and many, many other directories -- replete with enough files to seriously affect backup space over time. Does anyone have an available script or list of commands for removing most or all of these "generally unused" directories, packages or whatever they are? I found something a while back for shutting off unused services, but this seems to be a gaping hole in available archives. Thanks. CT
Alexander Dalloz
2012-Feb-15 20:51 UTC
[CentOS] question on unused directories in /usr/lib and /usr/lib64
Am 15.02.2012 21:30, schrieb Craig Thompson:> I was working on archiving an old virtual server today and was reminded of how much space is wasted by some of the default installations on CentOS. I think this was a 5.x box. > > Anyway, in /usr/lib/64 (and probably /usr/lib on non-64 systems), there were a lot of directories which have no bearing on a basic server. I saw firefox, openoffice and many, many other directories -- replete with enough files to seriously affect backup space over time. > > Does anyone have an available script or list of commands for removing most or all of these "generally unused" directories, packages or whatever they are? > > I found something a while back for shutting off unused services, but this seems to be a gaping hole in available archives. > > Thanks. > > CTYou are kidding, are you? Uninstall unused / unnecessary software cleanly using using yum (or rpm). *Don't* randomly delete filesystem structures you think they are pointless or wasting harddrive space. Alexander
Lamar Owen
2012-Feb-15 21:30 UTC
[CentOS] question on unused directories in /usr/lib and /usr/lib64
On Wednesday, February 15, 2012 03:30:56 PM Craig Thompson wrote:> Does anyone have an available script or list of commands for removing most or all of these "generally unused" directories, packages or whatever they are?Ok, here's a two-step process you can try: 1.) rpm -qf /usr/lib/name/of/file/in/one/of/those/directories 2.) yum remove result-from-step-1-without-version-or-release-but-with-arch. Be sure to check the dependencies yum will want to remove, and think it through at least twice before confirming by pressing 'y.' This is a diesel piledriver of a solution, but..... do be careful you aren't trying to remove something really important. As an arbitrary and simple example: [root at localhost ~]# cd /usr/lib64 [root at localhost lib64]# cd firefox-3.6 [root at localhost firefox-3.6]# ls application.ini chrome extensions langpacks README.txt blocklist.xml components firefox LICENSE run-mozilla.sh browserconfig.properties defaults icons modules searchplugins [root at localhost firefox-3.6]# pwd /usr/lib64/firefox-3.6 [root at localhost firefox-3.6]# rpm -qf application.ini firefox-3.6.26-1.el6.centos.x86_64 [root at localhost firefox-3.6]# cd .. [root at localhost lib64]# yum remove firefox.x86_64 Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Remove Process Resolving Dependencies --> Running transaction check ---> Package firefox.x86_64 0:3.6.26-1.el6.centos will be erased --> Finished Dependency Resolution Dependencies Resolved =============================================================================== Package Arch Version Repository Size ===============================================================================Removing: firefox x86_64 3.6.26-1.el6.centos @updates 17 M Transaction Summary ===============================================================================Remove 1 Package(s) Installed size: 17 M Is this ok [y/N]: n Exiting on user Command [root at localhost firefox-3.6]# Here's a more concrete (if extreme) example, since the python-2.6 directory in a default CentOS system isn't small (do note that I've snipped out several hundred lines of output with points of ellipsis (...) but left in lines that show real dealbreaker issues.....): [root at localhost lib64]# du . --max-depth=1|sort -g 4 ./audit 4 ./games 4 ./libxslt-plugins .. 19112 ./firefox-3.6 29568 ./xulrunner-1.9.2 39092 ./dri 46536 ./perl5 77424 ./python2.6 141624 ./valgrind 691124 . [root at localhost lib64]# cd python2.6 [root at localhost python2.6]# ls _abcoll.py HTMLParser.py sched.pyc ... htmlentitydefs.pyo runpy.py zipfile.pyc htmllib.py runpy.pyc zipfile.pyo htmllib.pyc runpy.pyo htmllib.pyo sched.py [root at localhost python2.6]# rpm -qf runpy.py python-2.6.6-29.el6.x86_64 [root at localhost python2.6]# yum remove python.x86_64 Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Remove Process Resolving Dependencies --> Running transaction check ---> Package python.x86_64 0:2.6.6-29.el6 will be erased --> Processing Dependency: python(abi) = 2.6 for package: python-babel-0.9.4-5.1.el6.noarch --> Processing Dependency: python(abi) = 2.6 for package: authconfig-6.1.12-5.el6.x86_64 ... ---> Package yum.noarch 0:3.2.29-22.el6.centos will be erased --> Processing Dependency: yum >= 3.2.18 for package: yum-plugin-security-1.1.30-10.el6.noarch --> Processing Dependency: yum >= 3.0 for package: yum-plugin-fastestmirror-1.1.30-10.el6.noarch ---> Package yum-metadata-parser.x86_64 0:1.1.2-16.el6 will be erased ---> Package yum-utils.noarch 0:1.1.30-10.el6 will be erased --> Running transaction check ... ---> Package cman.x86_64 0:3.0.12.1-23.el6 will be erased ... --> Processing Dependency: gettext = 0.17-16.el6 for package: gettext-devel-0.17-16.el6.x86_64 --> Processing Dependency: gettext for package: libvirt-client-0.9.4-23.el6_2.4.x86_64 ---> Package grub.x86_64 1:0.97-75.el6 will be erased --> Processing Dependency: grub for package: 1:libguestfs-1.7.17-26.el6.x86_64 ... --> Processing Dependency: /sbin/mount.nfs for package: resource-agents-3.9.2-7.el6.x86_64 --> Restarting Dependency Resolution with new changes. --> Running transaction check ---> Package resource-agents.x86_64 0:3.9.2-7.el6 will be erased --> Finished Dependency Resolution Error: Trying to remove "yum", which is protected You could try using --skip-broken to work around the problem You could try running: rpm -Va --nofiles --nodigest [root at localhost python2.6]# In other words, you can't remove /usr/lib64/python2.6 safely..... unless you want the basic 'yum' command to break....and want to remove the bootloader.... and want the cluster manager (cman) to quit working..... But python2.6 accounts for over 11% of the space in the /usr/lib64 tree.....
Lamar Owen
2012-Feb-15 22:05 UTC
[CentOS] question on unused directories in /usr/lib and /usr/lib64
On Wednesday, February 15, 2012 04:00:45 PM Craig Thompson wrote:> Hardly kidding. But then again, this is early April isn't it? Oh, wait... > > To "cleanly uninstall unused software," one would need a list of what software is ON the system which is unused.And one would need to define 'unused.' The Windows Add/Remove Control Panel widget has an indicator of 'last usage' and it might be possible to emulate that to a degree by looking at the last accessed time for a library... hmmm, something like: find /usr/lib64 ! -used +1 -exec rpm -qf \{\} \; |sort|uniq might do *part* of what you want, at least for /usr/lib64. I say *part* simply because this finds all files that have not been used more than 1 day after their status last changed and lists the package containing that file, sorts the output, and strips out all nonunique lines, but it is very possible that a package could have many, but not all, of its files 'used' and wind up on this list because of even just one unused file.... and what you want is to find each package where *none* of its files have been used since their status last changed (that is, since that package was last installed/modified). But you'd want to actually *use* all of the programs you expect to be used before acting on that list.... and you'd want to take the packages on that list and feed them to 'rpm -ql' for each package, and see if *any* file in that package had been 'used' (in the 'find' sense of the word). Sounds like a 'yum remove-unused' plugin or 'yum-cleanup-unused' utility or an enhancement to 'package-cleanup' from the yum-utils package, really, since the yum API has all the hooks necessary to do this from python. Python is guaranteed to be available on any EL system with a functional yum, and is much more powerful than shell for this sort of thing, so it would be a good fit, IMO.
Lamar Owen
2012-Feb-15 22:12 UTC
[CentOS] question on unused directories in /usr/lib and /usr/lib64
On Wednesday, February 15, 2012 04:13:23 PM m.roth at 5-cent.us wrote:> There are indeed some packages that have a ridiculous set of dependencies. > I can't remember what it was - it's been months, but I wanted to install > some command line tool, and it wanted gnome installed.This is one area 'build it yourself' distributions have done better than more general-purpose distributions. With gentoo, as an example, you can build the system with options telling it how to build each package. There are packages that require some things installed in the general case due to build-time options, and in order to eliminate the dependency you have to rebuild from source; to then go and say you want that feature back you have to rebuild from source. Some seemingly 'ridiculous' dependencies are there for that reason, and the packager is building for the general case, not for the minimalist case. And, no, I can't think of one right of the top of my head, either.