Page 1 of 1

How to increase swap partition

Posted: Fri Dec 15, 2017 7:45 pm
by emammadov
Hello,

I have installed VestaCP from scratch. I want to increase swap partition to 8GB, but don't know how to do it. Thank you in advance.

Here is the result of lsblk command:

[root@cpanel /]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 220G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 219.5G 0 part
├─vg_cpanel-lv_root (dm-0) 253:0 0 50G 0 lvm /
├─vg_cpanel-lv_swap (dm-1) 253:1 0 3.9G 0 lvm [SWAP]
└─vg_cpanel-lv_home (dm-2) 253:2 0 165.6G 0 lvm /home
sr0 11:0 1 1024M 0 rom

Re: How to increase swap partition

Posted: Sat Dec 16, 2017 8:00 am
by mehargags
do this as "root" :

Code: Select all

fallocate -l 8G /swapfile
ls -lh /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
Check if it is correctly done

Code: Select all

swapon -s
Edit your fstab to survive reboot

Code: Select all

nano /etc/fstab

Code: Select all

/swapfile   none    swap    sw    0   0

Code: Select all

reboot
and verify again with

Code: Select all

swapon -s

Re: How to increase swap partition

Posted: Mon Dec 18, 2017 8:13 am
by emammadov
Thanks. I have some questions:
1. When I want to add swap it says: fallocate: /swapfile: fallocate failed: Text file busy.
2. Here swap is partition or file?
3. Which method do you recommend about partitioning? I can do custom partition or let VestaCP do its partitioning? If I do custom partitioning it will be so:

HDD 220GB
sda 1 - / - 50GB
sda2 - /home - 162GB
sda3 - /swap partition - 8GB

Is it correct or do I have to add something here? Vestacp added /boot - 500mb. Is it necessary?

Re: How to increase swap partition

Posted: Mon Dec 18, 2017 8:48 pm
by mehargags
You need to switch OFF Swap first in order to release OS control over it.
No one is going to spoon feed each and every problem you face so you will learn more If you could care to search a bit https://www.google.com/search?q=falloca ... +file+busy