Mount an external volume in the /srv directory
We have started using Suse Enterprise Server in our company, and everything is going smoothly. The thing is that now we have a problem. We have a load balancer, and three Front Servers. We use Apache. We have the application on an external disk, and that disk is mounted on the three servers. We have the application in the external disk because in that way we can update the app in one step, and the three servers drink from that updated code. Also, in this way the application does not write to the database (which is on another server) the same thing over and over again. So we have tried the following without much success
Mount the external disk in /mnt and put a link in /srv. It works with a .html file, but not with a complete directory with many subdirectories.
Mount the disk directly in /srv. It gives an error.
The reason why we need Apache to read from /srv, is that this way we have the same code for all the servers. The ones from the development team, the test ones, the ones from operations, etc...
How can I solve this problem?
Thanks in advance,
Comments
@nanoak Hi and welcome to the Forum
When you say mount an external drive, is this a shared drive over samba, NFS etc?
Note: Are you using btrfs on
/
? Might need to ensure the subvolume/@/srv
is removed before the following.There is nothing stopping you removing the /srv directory and creating your new mount point with the external source as the mount point /srv but on reboot you might need to ensure the services that are required to use /srv are run after the external disk is mounted, else they may fail to start eg apache.
Sorry for my delay, I became a daddy recently, and my days are crazy.
No, it's an AWS volume. Mounted on the system as a disk.
I'm using xfs. What do you mean with removing the subvolume?
I have mounted the volume in /srv, and now the path is /srv/srv/.... I guess you mean this, right? How do I fix it?
By the way, this is my entry in fstab:
/dev/nvme1n1 /srv ext4 defaults,nofail 0 0
This is exactly what's happening to me right now
How can I fix that?
Thank you in advance.
@nanoak Hi, so what is under /srv without the device mounted?
I see
/srv/spm
and/srv/www
I would ensure and directories aside from www are duplicated on the nvme device (ownership and permissions), then unmount the nvme device, remove your mount point in/etc/fstab
, delete the/srv
directory. Then fire up YaST Partitioner and go through adding the partition (no format) and select the mount point as/srv
and save, should at that point appear in your/etc/fstab
. I doubt you will need the nofail, just stick with the defaults and should be good to go.I've got it all figured out!
Although there are a couple of things I don't like about my configuration.
Since I have the
/srv/....
path on the external hard drive, when I mount the external drive on/srv
, the final path I configure in apache is/srv/srv/....
I wish there was only one
/srv
. Is there a way to solve this? It is not very important, but it scratches my eyes.The owner of all the directories and files inside
/srv
isroot
. I leave it like this because that's how the SUSE documentation recommends it. Is that correct?For the apache unit to load, I have had to modify
/etc/apache2/default-server.conf
and I have modified the paths of/srv/....
to/srv/srv/....
But the SUSE documentation says not to modify this file because it could cause errors in an update. Should I look for another way?Thank you for your help
@nanoak Hi, make your own server.conf and use that instead with your modifications, looks like you might be stuck with then extra directory....
If I put my
server.conf
file in/conf.d
apache still not working:The owner of all directories and files should be
root
? It is safer to useapache
user?@nanoak Hi, normally group is
root
user iswww
or bothwww
for the apache files. Is the apache configuration looking in/srv/srv/...
and is apache using your config file and not the default one?So, my
/srv
, all of the subdirectories, and all of the files in the subdirectories, belongs toroot
.I'm following the text of the administration guide:
https://documentation.suse.com/sles/15-SP2/html/SLES-all/cha-apache2.html#sec-apache2-security
I don't know if I'm misunderstanding something, but for security reasons they shouldn't belong to
www
user and group?My vhost custom config file is looking in
/srv/srv
./etc/apache2/default-server.conf
is looking in/srv
(default config).If I modify
/etc/apache2/default-server.conf
, and replace/srv
with/srv/srv
, everything works fine. But, by doing so, I'm modifying the default config file, and that can cause problems in a future Apache update right?If I manually create
/srv/www/htdocs
directory, without modifying/etc/apache2/default-server.conf
, everything works fine.What do you recommend?
@nanoak Hi, then leave permissions as is
So are you using just /srv/www/htdocs? On your external drive, why not just move
/srv/www and other directories up a level to remove the extra
/srv, then can mount under
/srv`?Can you show the output from
lsblk
command when everything mounted.This is my
fstab
And this is the output of
lsblk
I have the disk mounted in two different directories. But it is a shared disk between three front servers. When we make a new deploy of the app, we do it in
/schoolyard
, and this way the three front ones are updated at the same time. Besides, we have it shared so that the app does not save the same data three times in the database (and other technical reasons with the sessions inside the app).The reason for having the path in
/srv/...
and for not being able to move/srv
and its subdirectories one level, is that we use the/srv/....
path in other test servers. When we update the app, we first test it on a development server, whose path is the standard one (/srv/....
), we also have the rest of the team testing the updated app on a different server called PRE (again,/srv
path), and after making the necessary changes we make the final deployment on the FRONT servers. The point is that there are hardcoded paths in the app source code. And of course, we would have to modify the app code only for the FRONT servers (and their sharedschoolyard
hard drive) if we were to up the path one level.This is part of the standard
/etc/apache2/defaulkt-server.conf
(Only the first, and the last part of the file)And this is my
/srv
directoryHere's
/srv/www
contentsI created manually
/srv/www/htdocs
in order to get apache working.sudo mkdir -p /srv/www/htdocs
But here's the problem, the operating system doesn't work on reboot if I create manually this directory
@nanoak Hi, honestly, I would go with your original working setup (even though sub-optimal) after an update run
rpmconfigcheck
to ensure none of you configs have changed and should be fine.Yup. I had the same feeling yesterday. Thank you!