How point a directory in a Headless CentOS guest (on VirtualBox) to a directory on the host machine?

2

I have the following setup:

HOST MACHINE: openSUSE LEAP (KDE) Linux GUEST MACHINE: CentOS 7 (no GUI, command line only) VM: VirtualBox 5.1.4

I have a directory on my host machine called ~/development/webfiles and on my CentOS VirtualBox server, I have /webapps/apps/webtest/public_html.

I want the files for /webapps/apps/webtest/public_html to actually be from my host machine's ~/development/webfiles directory.

How would I do this?

EDIT: After installing guest additions, I now have a folder:

/media/sf_webfiles

How do I:

  1. Point my public_html directory at that
  2. Make it so it happens on startup

Don Rhummy

Posted 2017-03-05T19:18:40.553

Reputation: 552

Answers

2

I solved by doing the following:

  1. Install guest additions in the CentOS server
  2. Find the actual name of the shared folder: ls -l /media
  3. Remove the existing "public_html" directory: rm /webapps/apps/webtest/public_html (You may need to be root)
  4. Create a symlink to that directory: ln -s /media/sf_webfiles /webapps/apps/webtest/public_html

EDIT: This does not work for apache!

A symlinked folder did not work - apache wouldn't read it no matter what permissions I gave the directory. Instead I had to mount it like this:

sharedfoldername /webapps/apps/destfolder    vboxsf  rw,uid=48,gid=48    0   0

I put that in /etc/rc.d/rc.local

Don Rhummy

Posted 2017-03-05T19:18:40.553

Reputation: 552