Adding Swap After Debian Installation

You installed a Debian based system but you have forgotten creating swap. Do not panic! You can do it later.

Another way, you can need extent main partition area, so you must delete swap and add again.

free -h


swapon -s

You can see if the swap partition is available and what size by these commands.

“swapon -s” command shows which partition is swap.

If you have not a swap partition, you need a blank partition. To set swap to any partition:

mkswap /dev/sdX (Replace X with partition number)

To get UUID number of any partition: (Partition number is 3)

blkid /dev/sda3

Output: 735b3be3–779c-4d21-a944-b033225f3ab4

You probably see an output as above. Then you should write the UUID number to “/etc/fstab” file.

UUID=735b3be3-779c-4d21-a944-b033225f3ab4 none swap sw 0 0

Finally, you can restart your operating system. The swap will be active after restarting. Actually restarting is not mandatory. You can run swapon -UUUID command as following to activate swap, but I recommend restarting OS.

swapon -U 735b3be3-779c-4d21-a944-b033225f3ab4

Now, command of swapon -s shows your swap area.

DevOps & Software & Architect & Linux Geek —

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store