1

I'm running nginx, PHP-FPM and MySQL on Debian Wheezy. I've set up chroot jails (with debootstrap) for each individual virtual host in /srv/. Everything is working like one would expect, but after each reboot I had to manually mount --bind /proc /srv/chrootjail/proc and mount --bind /run/mysqld /srv/chrootjail/run/mysqld.

This is why I added the following lines to /etc/fstab:

/proc       /srv/chrootjail/proc       none rw,bind 0 0
/run/mysqld /srv/chrootjail/run/mysqld none rw,bind 0 0

/srv/chrootjail/proc gets mounted properly, but /srv/chrootjail/run/mysqld does not and I can't find the reason why. /srv/chrootjail/run/mysqld just remains empty, although there are files in /run/mysqld. However, mount -a fixes the problem. For obvious reasons this is not the solution I was hoping for.

Does anyone see what I'm doing wrong here?

  • 1
    Do you mount anything on /run in the chroot? It could be something like /srv/chrootjail/run/mysqld is mounted and then something is mounted at /srv/chrootjail/run shadowing it. – Gilles Nov 9 '14 at 8:16
  • Thank you for your valuable hint, but unfortunately that's not the case for me. There's no other entry in /etc/fstab but the two I added plus the ones for /, /dev/pts, /proc and /sys. /srv/chrootjail/etc/fstab is empty. – Oliver M. Nov 9 '14 at 16:43
1

I have very limited knowledge what mount --bind even does really, but I think I might have figured out why I'm facing this problem with /run/mysqld in particular. I've just noticed /run (previously /var/run) is a tmpfs and thus it gets emptied during a reboot. So my guess is that /run/mysqld doesn't exist when /etc/fstab gets parsed. It's the init-script /etc/init.d/mysql that checks for /run/mysqld and creates it if needed with this line:

# Could be removed during boot
test -e /run/mysqld || install -m 755 -o mysql -g root -d /run/mysqld

As a workaround I simply added a mount -a after that line. I guess I could just have it create the mysqld folder anywhere(?) but inside of /run (or /var/run), too. However, if nobody can tell me a better way to do it, I'll stick to this workaround. Thanks for your time!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.