My host machine is ArchLinux and I'm running Apache in a CentOS guest. I have the vhost configuration and all the site code in a shared folder. To be able to put the vhost configuration in a shared folder I mounted the shared folder as apache:apache.
shared /mnt/shared vboxsf defaults,uid=48,gid=48 0 0
When I'm editing files in the host, Apache will consistently start sending old versions of the file with trailing characters. In vim, they show up as ^@, so I guess they're null characters. The number of null characters is related to the number of changes I make even if I edit the first line, null characters show up at the end. If I were to speculate, it looks like a bad diff.
If I stop httpd
, umount
, remount, and start httpd
the file looks fine. Just restarting httpd doesn't help.
How would I go about debugging the mount? Nothing jumped out at me in /var/log
.
I was wrong; it was happening elsewhere but I noticed that it was only with .css and .js files. A search led me to this post which talks about a problem with vboxsf and small files.
The solution is to set, in Apache
EnableSendfile off
On lighttpd
the solution is to add the below line to lighttpd.conf
server.network-backend = "writev"
See: Lighttpd broken when serving from Virtualbox shared folder
To answer the specific question "how do I go about debugging the mount":
(the below is paraphrasing, based on an investigation I just did into a problem caused by the same bug in Virtualbox, but with a different web server)
After diagnosing the problem is happening somewhere in how Apache reads files inside the virtual host, I would use "strace -p" inside the virtual host to log system calls by Apache.
While stracing, request just the one truncated/corrupted file.
Careful diagnosis will reveal that it is correctly stat'ing the file to get its length. And then it is serving it using the sendfile syscall. Basically confirming sendfile is misbehaving, meaning it must be a bug in the virtual machine.
Searching for "sendfile virtualbox" takes you to these bugs.
https://www.virtualbox.org/ticket/9069
https://www.virtualbox.org/ticket/12597