I have a systemd-nspawn container in which I am trying to change the kernel parameter for msgmnb. When I try to change the kernel parameter by directly writing to the /proc filesystem or using sysctl inside the systemd-nspawn container, I get an error that the /proc file system is read only.
From the arch wiki I see this relevant documentation
systemd-nspawn limits access to various kernel interfaces in the container to read-only, such as /sys, /proc/sys or /sys/fs/selinux. Network interfaces and the system clock may not be changed from within the container. Device nodes may not be created. The host system cannot be rebooted and kernel modules may not be loaded from within the container.
I thought the container would inherit some properties of /proc from the host, including the kernel parameter value for msgmnb, but this does not appear to be the case as the host and container have different values for msgmnb.
The kernel parameter value in the container:
cat /proc/sys/kernel/msgmnb 16384
Writing to the proc filesystem inside the container
$ bash -c 'echo 2621440 > /proc/sys/kernel/msgmnb' bash: /proc/sys/kernel/msgmnb: Read-only file system
For completeness, I also tried sysctl in the container:
# sysctl -w kernel.msgmnb=2621440 sysctl: setting key "kernel.msgmnb": Read-only file system
I thought this value would be inherited from the host system. I set the value on the host, rebooted and re-created my container. The container (even new ones) maintains the value of 16384.
# On the host $ cat /proc/sys/kernel/msgmnb 2621440
I've also tried using unprivileged the -U flag when booting the systemd-nspawn container but I get the same results.
I've also tried to editted /etc/sysctl.conf in the container tree to include this line before booting the container:
kernel.msgmnb=2621440
I also looked into https://man7.org/linux/man-pages/man7/capabilities.7.html and noticed CAP_SYS_RESOURCE which has a line that reads:
CAP_SYS_RESOURCE ... raise msg_qbytes limit for a System V message queue above the limit in /proc/sys/kernel/msgmnb (see msgop(2) and msgctl(2));
When I use msgctl with IPC_SET and pass msqid_ds->msg_qbytes with a value that is higher than what is in /proc/sys/kernel/msgmnb, the syscall returns an error code.
Nothing I've tried here has changed the value for msgmnb in the container. I can't seem to find documentation on how to achieve my goal.
I'd appreciate any help - thank you!