While installing Oracle DB in linux machine, I face a problem like swap space is not sufficient. How can I increase the swap space?

  • 1
    Swap partition or file?
    – phk
    Jul 14, 2016 at 10:40
  • I am new to linux. I want to increase the swap partition
    – vichi
    Jul 14, 2016 at 10:40
  • There is no "Linux 7"; the stable kernel is currently at version 4.6.4, and the mainline kernel is at 4.7-rc7, but it's unlikely that you are referring to the kernel version. There any many Linux distributions which might reasonably be at or around release 7. Please edit your question to try to be more specific. If you are unsure, just include the contents of any /etc/*release file that looks relevant in your question.
    – user
    Jul 14, 2016 at 11:18
  • You'll need to reorganize your partitions (or create a swap file). If you want help on reorganizing your partitions, copy-paste the output of fdisk -l (you need to run this command as root). Tell us what distribution you're running, and if you didn't pick the defaults when installing (concerning disk partitioning), tell us what you changed. Jul 14, 2016 at 22:00

2 Answers 2


In linux there is swap space in partitions or in files. Once the disk is partitioned the easiest way to grow the swap space is creating a swap file in one of your partitions. Type df -h and check which one has free space. Say you find free GB in /home:

First create a file. In this example we add around 1GB of space. Login as root in a terminal.

# dd if=/dev/zero of=/home/swap1 bs=1024 count=1024000

Make this file owned by the root user and allow only root to read and write to it:

# chown root:root /home/swap1
# chmod 0600 /home/swap1

Turn it into a swap file

# mkswap /home/swap1

Try it right now. This activates the new swap space without rebooting:

# swapon /home/swap1

Add it to the fstab file so it works when you reboot. Be carefull with the next command, do not forget there are two >

echo "/home/swap1 none swap sw 0 0" >> /etc/fstab

Check the new space is being used typing this: # swapon --show

  • I was wondering how I could free this created swap space safely and thoroughly?
    – MewX
    Nov 20, 2017 at 1:27
  • 2
    @MewX this is an entirely different question, but in a few words first you should remove the entry from /etc/fstab. Then reboot, then remove the file. Nov 21, 2017 at 8:02

With the small amount of information you've provided I could only suggest one thing; Gparted.

Download Gparted via this link and boot from it. Then just increase the swap partition as required.

A general rule of thumb regarding swap partition size that I've used is that it should be alteast as large as your total RAM. I'm not 100% sure if that is actually required, but it has worked for me all these years.

  • I needs to be slightly larger than the amount of installed RAM if you want to use suspend to disk. Otherwise it depends a lot on the use case and it certainly can be smaller than the amount of physical RAM installed.
    – Jan Henke
    Jul 14, 2016 at 12:07

You must log in to answer this question.

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