I'm running a LAEMP reverse proxy server on Arch in the cloud.
I have my nextcloud/data
folder mounted to an attached storage drive at /mnt/hdd/nextcloud/data
, linked to /srv/www/nextcloud/data
.
If I don't do this, but keep nextcloud/data
on the same disk as /
, then I don't have this problem at all.
At reboot
, the system starts; PHP pages get an error, but neither httpd
nor nginx
show any errors with systemctl status
. The error is in php-fpm
.
Output of systemctl status php-fpm
:
× php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; preset: disabled)
Drop-In: /etc/systemd/system/php-fpm.service.d
└─override.conf
Active: failed (Result: exit-code) since Tue 2023-05-30 16:47:30 PDT; 14s ago
Process: 316 ExecStart=/usr/bin/php-fpm --nodaemonize --fpm-config /etc/php/php-fpm.conf (code=exited, status=226/NAMESPACE)
Main PID: 316 (code=exited, status=226/NAMESPACE)
CPU: 8ms
May 30 16:47:29 MY_HOST systemd[1]: Starting The PHP FastCGI Process Manager...
May 30 16:47:29 MY_HOST (php-fpm)[316]: php-fpm.service: Failed to set up mount namespacing: /run/systemd/unit-root/mnt/hdd/nextcloud/data: No such file or directory
May 30 16:47:29 MY_HOST (php-fpm)[316]: php-fpm.service: Failed at step NAMESPACE spawning /usr/bin/php-fpm: No such file or directory
May 30 16:47:30 MY_HOST systemd[1]: php-fpm.service: Main process exited, code=exited, status=226/NAMESPACE
May 30 16:47:30 MY_HOST systemd[1]: php-fpm.service: Failed with result 'exit-code'.
May 30 16:47:30 MY_HOST systemd[1]: Failed to start The PHP FastCGI Process Manager.
Nextcloud is getting this from systemd
drop-in /etc/systemd/system/php-fpm.service.d/override.conf
:
[Service]
...
ReadWritePaths=/srv/www/nextcloud/data
When I run systemctl restart php-fpm
, the error goes away forever until the next reboot.
I presume that the php-fpm
service can't find the nextcloud
folder because hdd/
isn't mounted when php-fpm
starts and wants to look in its web folders. I would think that I should somehow adjust the run levels for php-fpm
and/or (preferrably) when /etc/fstab
loads the attached storage drive to /mnt/hdd
.
/etc/fstab
mounts the drive /mnt/hdd
with this statement:
/dev/vdc1 /mnt/hdd ext4 defaults,noatime,nofail 0 0
Nothing I search for on the Internet tells me how to solve this problem. Everything in the search results shows unrelated matters about php-fpm
or /etc/fstab
. Even then, at best I would get some script kiddy answer.
I want to know the proper way to have vdc1
mount much earlier at runtime, or at least have php-fpm
wait until the directory is available before throwing a fit.
You can configure the systemd unit to be started only after the mounts by adding the following configuration options either to the existing drop in file, or by adding another one if you don't want to modify it:
Another option would be to add the following option to the mount definition in fstab: