admin管理员组文章数量:1391995
While trying to implement resource limitation (Debian 12) for all users except root user i faced that user-0.slice MemoryMax does not override user.slice MemoryMax parameter.
root@:/etc/systemd/system.control# tree .
├── user-0.slice.d
│ └── 50-MemoryMax.conf
└── user.slice.d
└── 50-MemoryMax.conf
user.slice.d/50-MemoryMax.conf (5GB)
[Slice]
MemoryMax=5368709120
user-0.slice.d/50-MemoryMax.conf
[Slice]
MemoryMax=infinity
root@:/etc/systemd/system.control# systemctl status user-0.slice
● user-0.slice - User Slice of UID 0
Loaded: loaded
Drop-In: /usr/lib/systemd/system/user-.slice.d
└─10-defaults.conf
/etc/systemd/system.control/user-0.slice.d
└─50-MemoryMax.conf
Active: active since Wed 2025-03-12 15:48:51 UTC; 6min ago
Docs: man:[email protected](5)
Tasks: 13 (limit: 84525)
Memory: 27.0M (available: 4.7G)
CPU: 10.458s
CGroup: /user.slice/user-0.slice
├─session-1.scope
│ ├─672 "sshd: root@notty"
│ ├─752 fish -c /usr/lib/openssh/sftp-server
│ └─768 /usr/lib/openssh/sftp-server
├─session-7.scope
│ ├─10980 "sshd: root@pts/1"
│ ├─11338 -fish
│ ├─22233 bash
│ ├─25322 systemctl status user-0.slice
│ └─25323 pager
├─session-8.scope
│ ├─11257 "sshd: root@notty"
│ ├─11633 fish -c /usr/lib/openssh/sftp-server
│ └─11646 /usr/lib/openssh/sftp-server
└─[email protected]
└─init.scope
├─703 /lib/systemd/systemd --user
└─706 "(sd-pam)"
Mar 12 15:48:52 systemd[703]: Listening on gpg-agent-extra.socket - GnuPG cryptographic agent and passphrase cache (restricted).
Mar 12 15:48:52 systemd[703]: Listening on gpg-agent-ssh.socket - GnuPG cryptographic agent (ssh-agent emulation).
Mar 12 15:48:52 systemd[703]: Listening on gpg-agent.socket - GnuPG cryptographic agent and passphrase cache.
Mar 12 15:48:52 systemd[703]: Listening on pk-debconf-helper.socket - debconf communication socket.
Mar 12 15:48:52 systemd[703]: Listening on dbus.socket - D-Bus User Message Bus Socket.
Mar 12 15:48:52 systemd[703]: Reached target sockets.target - Sockets.
Mar 12 15:48:52 systemd[703]: Reached target basic.target - Basic System.
Mar 12 15:48:52 systemd[703]: Reached target default.target - Main User Target.
Mar 12 15:48:52 systemd[703]: Startup finished in 587ms.
Mar 12 15:48:52 sshd[672]: pam_env(sshd:session): deprecated reading of user environment enabled
I still see 4.7 GB for root available, but expect unlimited
While trying to implement resource limitation (Debian 12) for all users except root user i faced that user-0.slice MemoryMax does not override user.slice MemoryMax parameter.
root@:/etc/systemd/system.control# tree .
├── user-0.slice.d
│ └── 50-MemoryMax.conf
└── user.slice.d
└── 50-MemoryMax.conf
user.slice.d/50-MemoryMax.conf (5GB)
[Slice]
MemoryMax=5368709120
user-0.slice.d/50-MemoryMax.conf
[Slice]
MemoryMax=infinity
root@:/etc/systemd/system.control# systemctl status user-0.slice
● user-0.slice - User Slice of UID 0
Loaded: loaded
Drop-In: /usr/lib/systemd/system/user-.slice.d
└─10-defaults.conf
/etc/systemd/system.control/user-0.slice.d
└─50-MemoryMax.conf
Active: active since Wed 2025-03-12 15:48:51 UTC; 6min ago
Docs: man:[email protected](5)
Tasks: 13 (limit: 84525)
Memory: 27.0M (available: 4.7G)
CPU: 10.458s
CGroup: /user.slice/user-0.slice
├─session-1.scope
│ ├─672 "sshd: root@notty"
│ ├─752 fish -c /usr/lib/openssh/sftp-server
│ └─768 /usr/lib/openssh/sftp-server
├─session-7.scope
│ ├─10980 "sshd: root@pts/1"
│ ├─11338 -fish
│ ├─22233 bash
│ ├─25322 systemctl status user-0.slice
│ └─25323 pager
├─session-8.scope
│ ├─11257 "sshd: root@notty"
│ ├─11633 fish -c /usr/lib/openssh/sftp-server
│ └─11646 /usr/lib/openssh/sftp-server
└─[email protected]
└─init.scope
├─703 /lib/systemd/systemd --user
└─706 "(sd-pam)"
Mar 12 15:48:52 systemd[703]: Listening on gpg-agent-extra.socket - GnuPG cryptographic agent and passphrase cache (restricted).
Mar 12 15:48:52 systemd[703]: Listening on gpg-agent-ssh.socket - GnuPG cryptographic agent (ssh-agent emulation).
Mar 12 15:48:52 systemd[703]: Listening on gpg-agent.socket - GnuPG cryptographic agent and passphrase cache.
Mar 12 15:48:52 systemd[703]: Listening on pk-debconf-helper.socket - debconf communication socket.
Mar 12 15:48:52 systemd[703]: Listening on dbus.socket - D-Bus User Message Bus Socket.
Mar 12 15:48:52 systemd[703]: Reached target sockets.target - Sockets.
Mar 12 15:48:52 systemd[703]: Reached target basic.target - Basic System.
Mar 12 15:48:52 systemd[703]: Reached target default.target - Main User Target.
Mar 12 15:48:52 systemd[703]: Startup finished in 587ms.
Mar 12 15:48:52 sshd[672]: pam_env(sshd:session): deprecated reading of user environment enabled
I still see 4.7 GB for root available, but expect unlimited
Share Improve this question asked Mar 12 at 15:57 IgnatellaIgnatella 691 silver badge7 bronze badges 1- I’m voting to close this question because it belongs on Server Fault. – Ian Abbott Commented Mar 12 at 17:12
1 Answer
Reset to default 0Infinite
value is the same as empty value and results in the same value as parent.
P.S. Child cannot set limits higher than parent (I struggled to understand it)
本文标签: linuxSystemd cgroup slice user override does not workStack Overflow
版权声明:本文标题:linux - Systemd cgroup slice user override does not work - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744742378a2622684.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论