5

I am using VPS with 512MB RAM. Trying yum -y update and this is what i get:

[root@cs09-prod ~]# yum -y update
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.sesp.northwestern.edu
 * epel: mirror.steadfast.net
 * extras: linux.cc.lehigh.edu
 * updates: mirror.team-cymru.org
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-9 will be updated
---> Package epel-release.noarch 0:7-11 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                Arch             Version           Repository      Size
================================================================================
Updating:
 epel-release           noarch           7-11              epel            15 k

Transaction Summary
================================================================================
Upgrade  1 Package

Total download size: 15 k
Downloading packages:
Failed to download prestodelta for repository epel: [Errno 5] [Errno 12] Cannot allocate memory


Error downloading packages:
  epel-release-7-11.noarch: [Errno 5] [Errno 12] Cannot allocate memory

[root@cs09-prod ~]#

Is there anyway to fix this except getting a VPS with more memory?

1
  • That would do absolutely nothing. There is a lack of memory, not disk space. Commented Feb 18, 2018 at 20:57

2 Answers 2

2

Your VPS doesn't have enough memory available. You can see how much there is by running:

free -gh

The g shows how much memory is available in gigabytes and h puts in it human-readable format. You can use mh if you want to see it in megabytes.

In order for yum to work, you'll need to stop services to free up memory. You can see which processes are using what amount of memory by using the ps command.

4

Problem

Yum Cannot allocate memory

Answer:

Make a swap file to use as memory.

I know this is an old thread but the accepted answer didn't answer the real question of what to do about it and when you only have 0.5G of memory, you can't actually end enough processes to handle a yum update on a cheaply provisioned system.

You need to allocate disk space to be used as memory with a swap file. In Centos it can be done following the tutorial here.

This will create 4G of memory, which may be excessive. Just change count=4096 from 4096 to however many MB you want to use. Also note, that the performance won't be good, but it will get you through trouble where a process expects to use more than your available RAM up to the amount you provision from disk space.

sudo dd if=/dev/zero of=/swapfile count=4096 bs=1MiB
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo sh -c 'echo "/swapfile none swap sw 0 0" >> /etc/fstab'
3
  • Thanks a lot for this solution. The first file name should be /swapfile, not /myswap. Great that you proposed dd (not buggy in this case fallocate). Unfortunately my OpenVZ VPS doesn't allow swap, so it didn't help. Commented Nov 26, 2020 at 12:53
  • @YaroslavNikitenko It's a VPS. What does the brand have to do with it? You either have root access to a set of resources or you don't. If you don't then it's not a virtual private server. It would be a shared server. Commented Aug 9, 2022 at 17:57
  • It is a private server, but it is virtual. I have root access, but it has many limitations. Commented Aug 10, 2022 at 19:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .