1

I have setup a VirtualBox running on my MacBook Pro (OS X 10.9). This VirtualBox is running CentOS 6.5. I can successfully SSH from the Macbook to the CentOS VM by doing ssh [email protected] -p 3005

Now I want to be able to access and edit the files on the CentOS VM (under the /var/www directory) using the nice editors and tools I have installed natively on my MacBook. But I'm having trouble doing so.

I successfully followed the instructions here. Now I have a directory on the CentOS VM called /mnt/my_share_name in which I can access files on the MacBook's file system. Great. . but what I really need is the opposite. I want to be able to access files in the CentOS VM's /var/www directory from the MacBook. How Can I do that?? I tried inserting a link in /mnt/my_share_name as shown below. But it didn't work.

# From the CentOS VirtualBox
% cd /mnt/my_share_name
% sudo touch me
% ls
me
% sudo ln -s /var/www www
ln: creating symbolic link `eso': Read-only file system

Just in case anyone is interested, here is a screenshot of the VirtualBox Manager application: Screenshot of my VirtualBox Manager

1 Answer 1

2

As your provided link says:

In your Guest Linux Box, open a terminal and enter the following commands:

>sudo mkdir /mnt/share 

>sudo mount -t vboxsf shared_folder /mnt/share     [shared_folder is the name of your shared folder]

This will make /mnt/share/ your shared folder (meaning if you put files in the shared folder from the host(OS X in your case) it will be visible in /mnt/share/)

You can change this around however you wish, like:

>mkdir /home/user/shared 

>sudo mount -t vboxsf shared_folder /home/user/shared     [shared_folder is the name of your shared folder]

This would place the shared folder in user's home directory. Don't forget to place the mount options in fstab as your link suggests to mount the shared folder on boot.

I would personally suggest placing it under the /media/ folder somewhere as most file managers will automatically pick that up as if it were external media (like a usb flash drive or external HDD, these would be auto mounted in /media/ as well)

To access the folder on your host, when you create the machine folder you select a "Folder Path" that path is to where it is located on your host and where you can access it from.

Update: I do not know why that symlink creation fails, but you should investigate that. As a (fairly ugly) workaround you can do something like:

cp -r /var/www/* /mnt/my_share_name
sudo nano /etc/fstab

and change your existing shared directory from /mnt/my_share_name to /var/www after this run

rm -rf /var/www

and then reboot. This should basically move all your files from /var/www to the shared folder, and make the shared folder be /var/www.

4
  • That part is all done. But that's not me question. I made some edits to the OP showing what happens when I try to put a soft-link in there to /var/www. It doesn't work. From my MacBook, I need to access files under /var/www on the VirtualBox. How?
    – Saqib Ali
    Jun 15, 2014 at 10:48
  • @SaqibAli that completely changes your question... You should start by finding out where that 'eso' came from. If you can successfully read/write files normally to the shared directory on the VM, this is a question about why the symlink fails, not how to access the folder. One hack for you could be to move the contents of /var/www/* to /mnt/my_share_name/ and then add an fstab entry that would mount the shared folder at /var/www. I'll explain in my answer.
    – Cestarian
    Jun 15, 2014 at 23:07
  • 1
    Seems like there is a bug in the VirtualBox code to make soft links: forums.virtualbox.org/viewtopic.php?f=3&t=47014
    – Saqib Ali
    Jun 16, 2014 at 3:01
  • @SaqibAli That explains it, at least you have two workarounds for it now. That post is pretty old (2010) so I am surprised it hasn't been fixed by now.
    – Cestarian
    Jun 16, 2014 at 19:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .