Disclaimer

This blog is kind of my own personal work Notebook, and the processes below are only guaranteed to work for my specific configurations. So, use this info at your own risk, and please understand I won't be able to provide any help if you break something

Monday, July 12, 2021

Add multiple Swap partitions

The Problem: 

When trying to increase the size of my swap partition in my Linux server I got the following:

root@server:~# sudo fallocate -l 1G /swapfile

fallocate: fallocate failed: Text file busy

Trying to turn off the swap partition returns: 

root@pilot888:~# sudo swapoff -a

swapoff: /swapfile: swapoff failed: Cannot allocate memory


The Solution: 

Leave that swap partition alone and create multiple partitions instead: 

root@server:~# sudo fallocate -l 1G /swapfile2

root@server:~# ls -lh /swapfile2
-rw-r--r-- 1 root root 1.0G Jul 12 09:55 /swapfile2

root@server:~# sudo mkswap /swapfile2
Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes)
no label, UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

root@server:~# sudo swapon /swapfile2

root@server:~# sudo swapon --show
NAME       TYPE  SIZE   USED PRIO
/swapfile  file  512M   512M   -1
/swapfile2 file 1024M 193.6M   -2

root@server:~# free -h
              total        used        free      shared  buff/cache   available
Mem:           992M        784M         69M         60M        138M         25M
Swap:          1.5G        1.4G        124M

No comments:

Post a Comment