Desativar partição swap no Centos 7

Categories Linux, TutoriaisPosted on

Our services are no longer on bare metal, instead, new services are on VPS. Recently we have a problem on CE7 when reboot and it waiting for swap partition, which we have removed completely to free-up space.

Since hypervisors will manage disk IO and memory of VPS, default i/o scheduler & memory paging will double the I/O. Hypervisor allow overcommit on memory, and it will try to take free memory from other idled VPS, before it start paging to disk. Therefore, best practice are I/O scheduler set to noop and disable memory paging by turn it off & remove swap.

CE7 auto tuned i/o schedule to noop when detect itself are running under hypervisor, but it won’t turn off swap and allocate plenty amount of disk space for swap partition.

Turn off swap is simple.

$ sudo swapoff -a

and remove it to free-up space.

$ sudo lvremove -Ay /dev/centos/swap

of course reassign it to /dev/centos/root

$ sudo lvextend -l +100%FREE centos/root

But one point we are missing, grub2.cfg need to be regenerate, but modification needed before regenerate.

$ sudo vi /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
##GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap crashkernel=auto rhgb quiet"
GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root crashkernel=auto rhgb quiet"
GRUB_DISABLE_RECOVERY="true"

$ sudo cp /etc/grub2.cfg /etc/grub2.cfg.bak
$ sudo grub2-mkconfig >/etc/grub2.cfg

Viola! No more swap partition waiting for next reboot!

Fonte: https://www.refmanual.com/2016/01/08/completely-remove-swap-on-ce7/#.XAtO3nUvw8p

Deixe uma resposta

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *