How to mount windows directory in VirtualBox Ubuntuzalam
In this article, we’ll configure Apache on the VirtualBox in order to use this shared folder to run website from windows folder.
Prerequisite for this article is ‘Setup of ubuntu server or ubuntu desktop on VirtualBox‘
You need to share the directory in VirtualBox. To access the shared folder properties, simply click on ‘Settings’ go to ‘Shared Folder’ give folder name, path, check ‘auto mount’. For this example i have sharing by windows ‘e_drive’.
Install VirtualBox package for mounting drives.
sudo apt-get install virtualbox-guest-dkms
Create a directory in apache root folder
Apache expects the files to render to belong to the group www-data. By default, however, the shared folder in VirtualBox belongs to the vboxsf user. We will add this user to the www-data group. To do so, edit the group properties on the guest:
Edit the line that says vboxsf:x:1001: and replace it with the following:
You can also add linux users to the above to give access to other users.
We’ll now mount the shared folder and assign it to the www-data user and group. To check out the user and group id, you can have a look at the /etc/passwd file on the guest machine (cat /etc/passwd | grep ‘www-data’). On Debian based OS, both ids are usually set to the value 33. So, simply issue the following command
cat /etc/passwd | grep 'www-data'
Now mount the shared folder into apache directory.
sudo mount -t vboxsf -o rw,uid=33,gid=33 e_drive /var/www/e_drive/
You can also place this command into startup script on ubuntu start.
sudo nano /etc/rc.local
Add the following line before ‘exit 0’
Sometimes network is not started, so add 5 second sleep before mounting takes place.
mount -t vboxsf -o rw,uid=33,gid=33 e_drive /var/www/e_drive/
Now is a good time to restart the server and see the changes and directories and website would be available under http://localhost/e_drive/