Skip to content

Rage Against the Shell

Linux tips and other things…

  • Home
  • Contact
  • Privacy Policy

Month: December 2019

Disable swap in systemd

Posted on December 16, 2019 by Mr. Reboot

Tested in ubuntu 18 / debian 9

Usually you can disable the swap by this command:

~ $ swapoff -a

And then comment entry swap line in /etc/fstab file for making reboot persistent. But sometimes in systems with systemd this is not enough, steps would be these:

Get the swap service name in use:

~ $ systemctl --type swap

UNIT                                       LOAD   ACTIVE SUB    DESCRIPTION                  
dev-mapper-ubuntu\x2d\x2dvg\x2dswap_1.swap loaded active active /dev/mapper/ubuntu--vg-swap_1

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.

1 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.

Stop service, note “‘” on start and end in service name:

~ $ systemctl stop 'dev-mapper-ubuntu\x2d\x2dvg\x2dswap_1.swap'

Mask service:

~ $ systemctl mask 'dev-mapper-ubuntu\x2d\x2dvg\x2dswap_1.swap'
Created symlink /etc/systemd/system/dev-mapper-ubuntu\x2d\x2dvg\x2dswap_1.swap → /dev/null.

Finally check service:

~ $ systemctl --type swap
0 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.

If you want enable swap again:

~ $ systemctl unmask 'dev-mapper-ubuntu\x2d\x2dvg\x2dswap_1.swap'
~ $ systemctl start 'dev-mapper-ubuntu\x2d\x2dvg\x2dswap_1.swap'
Posted in File systems2 Comments

Search

Calendar

December 2019
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
3031  
« Oct   Apr »

Categories

  • Apache
  • Cisco
  • Command line
  • Distros
  • Dovecot
  • File systems
  • Gadgets
  • GlusterFS
  • MySQL
  • Nginx
  • NTP
  • Opendkim
  • Pacemaker + Corosync
  • Postfix
  • Raspberrypi
  • SSH
  • SSL
  • Varnish

RSS RSS

  • Using qrencode January 16, 2022
  • Compile varnish module vmod_vsthrottle April 22, 2020
  • SSH vpn with sshuttle April 9, 2020
  • Disable swap in systemd December 16, 2019
  • Getting the parent process pid October 12, 2018
Proudly powered by WordPress | Theme: micro, developed by DevriX.