D.Dave
21 January 2024 11:45
1
Hi, I’d want to increase the size of /dev/shm (currently is of 7,8GB)
By reading here tmpfs - ArchWiki is stated that:
Mounting tmpfs at /dev/shm is handled automatically by systemd and manual configuration in fstab is not necessary.
But I can’t find the systemd units nor config files where to set the size of /dev/shm.
zbe
21 January 2024 11:56
2
Create an override file for /usr/lib/systemd/system/tmp.mount
.
Hi @D.Dave ,
According to that very article you linked to:
Tip: Temporary files in tmpfs directories can be recreated at boot by using systemd-tmpfiles .
D.Dave
21 January 2024 13:35
4
I made an override config file with the following content:
[Mount]
What=tmpfs
Where=/dev/shm
Type=tmpfs
Options=rw,nosuid,nodev,noexec,inode64,size=9G
But I get the error:
Cannot create mount unit for API file system /dev/shm. Refusing
D.Dave
21 January 2024 14:08
7
/etc/systemd/system/tmp.mount.d/override.conf
opened 07:59AM - 08 Mar 18 UTC
closed 06:02PM - 20 Mar 18 UTC
needs-reporter-feedback ❓
remount-fs
### Submission type
- Bug report
(More of "defect of the design", actua… lly)
### systemd version the issue has been seen with
>[current git](https://github.com/systemd/systemd/blob/39f305a901934dfcc064cffd4e419b92d90b02c0/src/core/mount-setup.c#L136)
### Used distribution
> openSUSE
### In case of bug report: Expected behaviour you didn't see
> All fstab and .mount directives working.
### In case of bug report: Unexpected behaviour you saw
> systemd forcing "enough for everyone" kind of mount options.
### In case of bug report: Steps to reproduce the problem
> Use it.
So, I've been trying for a while to change default option for "system" mount such as all tmpfs-based paths, including /dev/shm but had limited luck. Today I was able to force systemd to:
* Stop mounting debugfs by /dev/null symlink for /etc/systemd/system/sys-kernel-debug.mount
* Start mounting tracefs which is safer subset of debugfs by hacky /etc/systemd/system/sys-kernel-tracing.mount
* Mount /tmp as 256MB tmpfs with `huge=advise` option by another hack in /etc/systemd/system/tmp.mount
Because I've tried to migrate my system on exclusive usage of [transparent hugepages](https://www.kernel.org/doc/Documentation/vm/transhuge.txt) I tried to put proper "huge" option (such as 'within_size' and 'advise') for all shm/tmpfs mounts while also limiting their size to make sure that ALL of them + zswap don't amount to more than 50% of RAM instead of each of them having default useless 50% limit. BUT I can't do it for /dev/shm and /run because, as if it were not enough to ignore fstab entries, systemd ignores its own .mount entries because, apparently, those are forbidden "API-mounts" which are forced to have systemd's hardcoded options in [/src/core/mount-setup.c](https://github.com/systemd/systemd/blob/39f305a901934dfcc064cffd4e419b92d90b02c0/src/core/mount-setup.c#L136).
API VFS are not supported as .mount units. Currently the only way to configure mount options for them is by adding an /etc/fstab file. And I think this is unlikely to change.
You need to give more complete answers, help people to help you, otherwise you won’t get the help and you’ll get very frustrated. Anyway, that’s where, how would’ve included that. But that doesn’t answer the question. After creating it, you should’ve reloaded systemd for it to become visible and the and then reloaded the unit for the changes to take effect.
First create the drop-in:
sudo systemctl edit tmp.mount
Then you need to only change what you wish to be different:
[mount]
Options=
Options=rw,nosuid,nodev,noexec,inode64,size=9G
Save and exit.
Now you need to reload systemd:
sudo systemctl daemon-reload
You should now be able to see the override in the status output:
systemctl status tmp.mount
There should be a line similar to:
Drop-In: /etc/systemd/system/pacman-filesdb-refresh.service.d
└─override.conf
If so, you can reload the mount unit:
sudo systemctl restart tmp.mount
Hope this helps!
D.Dave:
Where=/dev/shm
it’s for tmp and no for shm (shm is an “alias”)
systemctl cat tmp.mount
for change
sudo systemctl edit tmp.mount
1 Like
D.Dave
21 January 2024 14:14
10
I just followed what already exists: the instruction on the arch wiki (and in past I already used override.conf), and there is only this way to create an override: I just avoided to be redundant.
However: check my post n°7: /dev/shm cannot be mounted by any mount unit:
/etc/systemd/system/tmp.mount.d/override.conf
API VFS are not supported as .mount units. Currently the only way to configure mount options for them is by adding an /etc/fstab file. And I think this is unlikely to change.
There is also a link on the Systemd’s Github which confirm this.
If this is the case, simply add the line to /etc/fstab
, IIRC.
I think it’s obvious to see I’ve never overrode any .mount
unit…
zbe
21 January 2024 14:50
14
Oops. I thought changing only the Options= line would work, but it only changes /tmp
size. Apparently /dev/shm
is hardcoded and adding /etc/fstab
line would be the best option. Either that or maybe creating a new .mount unit.
D.Dave
21 January 2024 14:52
15
I also tried dev-shm.mount (with the same error), but as explained in post n°7, /dev/shm cannot be mounted using a mount unit.