Swap using in proxmox 6.2

plastilin

Renowned Member
Oct 9, 2012
99
5
73
Ukraine
Hello. As far as is known, rc.local does not work in Debian 10, but even when it is created, and then adding the launch of your code through systemd, an error is generated. Perhaps you have a swap blocking solution in Proxmox 6.2?

At first i create /etc/rc.local file with content:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# fix for proxmox kernel swappiness problem, yes, it must be executed twice
for i in `/usr/bin/find /sys /var/lib 2>/dev/null | /bin/grep slice | /bin/grep swappiness` ; do /bin/echo 0 >"${i}" ; done
for i in `/usr/bin/find /sys /var/lib 2>/dev/null | /bin/grep slice | /bin/grep swappiness` ; do /bin/echo 0 >"${i}" ; done

exit 0

do this file executable

chmod +x /etc/rc.local

I try to start rc.local with systemd by create file /etc/systemd/system/rc-local.service

[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99

[Install]
WantedBy=multi-user.target

systemctl enable rc-local
systemctl start rc-local.service

if i start manually, all ok but after reboot i have some errors:

Jul 14 09:33:17 prxmx systemd[1]: Starting /etc/rc.local Compatibility...
Jul 14 09:33:17 prxmx rc.local[702]: /etc/rc.local: 14: /etc/rc.local: cannot create /sys/fs/cgroup/memory/system.slice/lxc.service/memory.swappiness: Directory nonexistent
jul 14 09:33:17 prxmx systemd[1]: rc-local.service: Control process exited, code=exited, status=2/INVALIDARGUMENT
jul 14 09:33:17 prxmx systemd[1]: rc-local.service: Failed with result 'exit-code'.
Jul 14 09:33:17 prxmx systemd[1]: Failed to start /etc/rc.local Compatibility.

help me for fix use swap by proxmox. In previos version all works perfectly with content in rc.local
 
Resolved

Content in /etc/rc.local

Code:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
for i in $(/usr/bin/find /sys /var/lib 2>/dev/null | /bin/grep slice | grep swappiness) ; do [ -f ${i} ] && /bin/echo 0 > ${i} ; done
exit 0

Content in etc/systemd/system/rc-local.service

Code:
[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local
After=pve-cluster.service

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
 
Last edited:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!