Skip to content

Instantly share code, notes, and snippets.

@mortenbra
Last active October 29, 2021 14:51
Show Gist options
  • Save mortenbra/31b23ea03841325041aa to your computer and use it in GitHub Desktop.
Save mortenbra/31b23ea03841325041aa to your computer and use it in GitHub Desktop.
Creating a swapfile suitable for Oracle XE on CentOS
# Oracle XE requires a swap file of at least twice the size of physical memory
# see https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-centos-6
# check current swap file
swapon -s
# check available space
df
# setup 2GB swap file
dd if=/dev/zero of=/swapfile bs=1024 count=2048k
mkswap /swapfile
swapon /swapfile
# check swap file again
swapon -s
# make the swap file permanent
# see http://blog.allanglesit.com/2012/05/bash-programmatically-add-entries-in-fstab/
echo "/swapfile swap swap defaults 0 0" >> /etc/fstab
# prevent file from being world-readable
chown root:root /swapfile
chmod 0600 /swapfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment