4

After I do this on my Debian Stretch:

sudo apt install cgroup-bin cgroup-tools cgroupfs-mount libcgroup1

I can issue this:

sudo systemctl set-property user-1000.slice CPUQuota=40% 

I have 4 vCPU host, each CPU takes 10% hit with "stress -cpu 4", but after reboot, I can no longer get the "CPUQuota" to work, again.

I have already have "GRUB_CMDLINE_LINUX_DEFAULT="cgroup_enable=memory swapaccount=1"

So how do I get systemd resource management to work after each reboot without having to reissue:

sudo apt --reinstall install cgroup-bin cgroup-tools cgroupfs-mount libcgroup1 
Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250

1 Answers1

2

This is how I fixed the problem. (For some reason, after cgroupfs-mount is installed, the file /lib/systemd/system/cgroupfs-mount.service is linked to /dev/null.)

sudo apt --reinstall instll cgroupfs-mount
sudo rm /lib/systemd/system/cgroupfs-mount.service
sudo systemctl daemon-reload

Now created systemd service file:

sudo nano /lib/systemd/system/cgroupfs-mount.service

[Unit]
Description=CGroups FS Mount

[Service]
Type=oneshot
ExecStart=/etc/init.d/cgroupfs-mount start
ExecStop=/etc/init.d/cgroupfs-mount stop
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Once the file is created, issue:

sudo systemctl daemon-reload

Check on the status and enable startup during boot:

sudo systemctl status cgroupfs-mount
sudo systemctl enable cgroupfs-mount

Now test:

sudo systemctl set-property user-1000.slice CPUQuota=40%
sudo systemctl daemon-reload
GAD3R
  • 63,407
  • 31
  • 131
  • 192
GaoZu
  • 21
  • 1