jump to navigation

Adding Swap over NFS for Koji Builders June 18, 2010

Posted by Paul Whalen in ARM, Koji.

In our efforts to set up a Koji Build farm for Fedora we have decided to use the GuruPlug Server Plus. The GuruPlug has very limited memory with only 512 MB, previously the build farm used boards that had 2 GB of ram. In order to get around this limitation we have decided to add swap space over NFS. Unfortunately the kernel doesn’t support swap over NFS, for good reason due to the unreliability of NFS. In our situation these risks don’t apply as we are already using NFS for additional space during the build process, if the share becomes unavailable the system will be impacted regardless. In order to trick our system and use swap over NFS we created an ext3 file system named swap0.ext3 on an existing NFS share.
First create the file and format using ext3:
dd if=/dev/zero of=swap0.ext3 bs=1024 count=7864320
mkfs -t ext3 swap0.ext3

This creates a file of approximately 8.1 GB, to change this amount simply edit the count value to reflect the desired amount. This is calculated by multiplying 1024*x, where x is the MB.
Mount the ext3 file system by adding it to ‘/etc/fstab’ (path should be changed, should be executed as root):
echo '/arm2/swap0.ext3 /swap0 ext3 defaults,noauto 0 0' >> /etc/fstab
mkdir /swap0
mount -o loop /swap0

Once mounted move to that directory and create the actual swap file using:
dd if=/dev/zero of=swap0 bs=1024 count=7860000
mkswap swap0
swapon swap0

As we have added the swap space to the fstab including the noauto option it will not be automatically be mounted at boot, instead we have added the mount to ‘/etc/rc.d/rc.local’. This was done to ensure if the share was unavailable during the boot, the system wouldn’t stall waiting for the share.
mount -o loop /swap0
swapon /swap0/swap0

By giving the builders a swap file the createrepo task being run by Koji was completed successfully. With no swap the task would fail. The actual amount of swap space being used was limited to approximately 500 MB so its possible a smaller swap file would suffice, however moving forward other tasks may require the additional resources. This solution is far from ideal, and is quite messy but produced the desired outcome.



No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: