Hello,
Recently I decided to do a full cleanup of my system, and found that I could free over 1.2GB in useless packages. That's 1200MB!
Well, let me rephrase that. No RPM package is ever useless because they all package software of some sort or another - What I should say was it was software that wasn't useful in my situation. Here's how I did it:
Code:
rpm -qa --qf '%{NAME}\n' > RPMS_complete.txt
for i in $(cat RPMS_complete.txt);do if [ "$(rpm -q --whatrequires $i | grep 'no package requires' > /dev/null;echo $?)" == "0" ]; then echo $i >> RPMS_notneeded.txt; fi; done
That should take a while, depending on how fast your system is and how many RPMs are installed. When you are finished, you will have a RPMS_notneeded.txt file that has a list of many packages. These are the packages which are not required by anything else, which are usually the ones you can drop from your system if you're not using them.
Remember: not all of these are packages you can clean out as the dependency system in RPM isn't 100% predictable by the commands I use above: eg.
libmypackage will provide the /usr/lib/libmypackage.so.0 file
in RPM thispackage. If another package has a requirement of /usr/lib/libmypackage.so.0 rather that libmypackage, it will appear in the file created above.
Now, you can go through that list and look up what an RPM does with this command:
Code:
rpm -qi package_name
If you decide you don't need what that package offers, then remove it like this:
Code:
rpm -e package_name
If "package x is required by [...]" errors turn up, don't force the remove with --nodeps.
If you're not sure if you use a package or not, then leave it to be safe. Also, It would be a good idea to keep a record of what you're removing, incase you find out later that you really do need one of the packages you removed. Using this command:
Code:
echo package_name >> record.txt
One can log package_name to the file named "record.txt"
Example: You want to remove mypackage, and are 75% sure you don't need it, that it won't affect your system's function.
Code:
echo "mypackage" >> record
EDIT:
Originally Posted by
axelseap
along this same topic u can also save space by removing the rpms that yum downloaded. yum doens't remove them and just let's them gather dust and take space. running the command
removes all the .rpm files that yum has downloaded. i usually add the command to the /etc/rc.local file so the packages are cleaned at boot.
Excellent idea. To clean packages downloaded by Yum, (Once RPMS are installed the RPM file is no longer needed; the files are on your system.) execute this command as root:
Code:
echo 'yum clean packages' >> /etc/rc.d/rc.local
Another thing you can do is to clear completely useless RPM headers archived by yum. They eventually build up and take a lot of space (A header is no longer needed once it's corresponding package has been updated. A header just contains the info about an RPM.)
Recently I found that I had duplicate RPMs on my system (from yum segfaults, etc). You can find duplicate rpms like this:
Code:
rpm -qa --qf '%{NAME}\n' | sort | uniq -d > rpm_duplicates.txt
Now the file rpm_duplicates.txt contains a list of names that have two or more packages with different versions (but same name) installed. For kernel*, kmod* and gpg-pubkey* packages this is OK, but in general everything you want to keep only one version installed. To remove the second version, take a name from the list in the file we just created and do:Look at the two outputs, and find the older one. Remove it with:
Code:
rpm -e fullname-with-version
Be sure to include the version in there otherwise it will remove both copies!
Finally, RPMs aren't always the problem. Other things can take up lots of space on your / drive, too. This command will output the total size of installed RPMs:
Code:
test=0;rpm -qa --qf '%{SIZE} - %{NAME}\n' | awk -v t=test '{printf $1"\n"}' | while read line;do let test="$test + $line";echo $test | awk '{printf "\rTotal: "int($1/1048576)"MB"}';done;echo "";
Compare that to disk usage:If the difference is very large you may want to check out /tmp and /var.
Hope it helps out,
Firewing1
(some minor changes for readability - foolish)