I have Linux device at my school and I increased swap size from 1983 to 3007 using swapon
. However the modifications are not saved and are lost upon rebooting. How do I save these?

- 22,691
2 Answers
I assume you mean edit the size of swap from count=1983 towards 3007.
First, swap location:
To discover your swap location, use the command swapon -s
. In my case:
Filename Type Size Used Priority
/dev/dm-1 partition 2097148 0 -1
Turn swap off:
Before we can edit our swap file, we have to turn it off. Logical, cause it is in 'use'. You can check how much swap is used by the command free -m
.
Here you can read about memory usage, link.
Command to turn swap off:
sudo swapoff -a
Edit swap size:
Now we are able to edit the size, we do that by the command dd
.
Be carefull with commands like these, I advice you to read the manual before blind copying my command.
sudo dd if=/dev/zero of=/dev/dm-1 bs=1M count=3007
Initialize swap:
mkswap sets up a Linux swap area on a device or in a file.
sudo mkswap /dev/dm-1
Final, turn swap on:
sudo swapon /dev/dm-1
Please educate yourself and don't just try to complete an assignment without understanding how it works.
First, you can do it with Gparted (right clicked the partition & selected "swapon").
If you need to install gparted first : apt-get install gparted -y
Otherwise, you have to configure the swap partition in /etc/fstab to get it mounted automatically on boot. Same as with any other partitions you'd want mounted on boot.
Check the correct UUID for the partition using sudo blkid command, and then add a line like this in fstab (with the correct UUID):
UUID=d228f3a3-585c-447e-aab4-91a3d089e193 none swap sw 0 0

- 537
- 1
- 4
- 8
swap
memory? – Mar 30 '16 at 11:53