0% found this document useful (0 votes)
14 views1 page

Add Swap Ubuntu

The document describes how to add additional swap space to a Linux system using a swap file. It involves creating a large empty file, securing it and making it swap space, turning it on, and adding it to fstab to activate it automatically on boot. Specifically, it shows commands to 1) create a 1GB empty file, 2) change ownership and permissions, 3) format it as swap, 4) enable it, and 5) configure fstab for permanent use.

Uploaded by

loveyoubikash
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views1 page

Add Swap Ubuntu

The document describes how to add additional swap space to a Linux system using a swap file. It involves creating a large empty file, securing it and making it swap space, turning it on, and adding it to fstab to activate it automatically on boot. Specifically, it shows commands to 1) create a 1GB empty file, 2) change ownership and permissions, 3) format it as swap, 4) enable it, and 5) configure fstab for permanent use.

Uploaded by

loveyoubikash
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Adding Swap Space

Code:

$ top

top - 11:20:22 up 8:58, 2 users, load average: 0.36, 0.39, 0.37


Tasks: 93 total, 2 running, 91 sleeping, 0 stopped, 0 zombie
Cpu(s): 50.0% us, 50.0% sy, 0.0% ni, 0.0% id, 0.0% wa, 0.0% hi, 0.0% si
Mem: 451660k total, 445580k used, 6080k free, 8880k buffers
Swap: 1052216k total, 165704k used, 886512k free, 171052k cached

In short, no. You will have to assign more space on the HD.
Actually, yes. You can supplement your swap partition with a swap file. It goes something l
ike this:

1. First, create a large empty file:


Code:

sudo dd if=/dev/zero of=/swap_file bs=1M count=1000

Replace 1000 with the size of the swap file desired, in MB. You can also put the swap_file in
a different location if desired. (i.e. !GB of swap space created).

2. Next, we'll secure the swapspace, so ordinary users cannot read the contents (potential
security breach):
Code:

sudo chown root:root /swap_file


sudo chmod 600 /swap_file

3. Then, turn it into swap space:

Code:

sudo mkswap /swap_file

4. Next, turn it on:


Code:

sudo swapon /swap_file

5. To make it turn on at every bootup, open up /etc/fstab:


Code:

sudo gedit /etc/fstab

6. Add this line to the end of the file:


Code:

/swap_file none swap sw 0 0

You might also like