adminze

May 012020
 

I ran into a nasty issue with a VPS that has only 256MB RAM and updating using yum update failed due to memory issues with some packages. I ended up in a state where some packages were updated and some where not. This means I had duplicate packages of old and new ones and broken dependencies. Coming from Debian (apt) I was not so comfortable with yum, but this is how I solved it and learned new commands:

1. Add some memory (even being swap)

Lets add some swap memory to the VPS. 1GB should be fine:

swapon –show
fallocate -l 1G /swapfile
dd if=/dev/zero of=/swapfile bs=1024 count=1048576
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo “/swapfile swap swap defaults 0 0” >> /etc/fstab
reboot # might be needed – I had to do it

2. Find the problematic packages

yum already gave me hints about the packages that have issues. In my case iptables and iptables-service. I checked which versions I have installed using

yum list installed | grep iptables

and found that I have multiple versions installed.

3. Remove the duplicates

yum update already mentioned some issues, but I figured out that the root cause was duplicates. I learned that there is a command to remove duplicates in CentOS:

package-cleanup –cleandupes

I wonder how often this happens that you need a tool for this … anyway.

If you want to remove only a specific version of a package you can do this using

yum remove iptables-services-1.4.21-33.el7.x86_64

You take the package name, append “-” and the version, append “.” and the architecture.

4. Re-run update

Finally I was able to run yum update -y and yum was able to install the new versions of all packages and all went fine.