Is there a way I can have a VM gain access to my c

2019-08-17 02:00发布

I would like to have a VM to look at how applications appear and to develop OS-specific applications, however, I want to keep all my code on my Windows machine so if I decide to nuke a VM or anything like that, it's all still there.

If it matters, I'm using VirtualBox.

4条回答
我欲成王,谁敢阻挡
2楼-- · 2019-08-17 02:40

Aside from network shares, another tool to use for this is a version-control system.

查看更多
劫难
3楼-- · 2019-08-17 02:52

This is usually handled with network shares. Share your code folder from your host machine and access it from the VMs.

查看更多
ら.Afraid
4楼-- · 2019-08-17 02:57

You should always be able make a normal network connection between the VM and the hosting OS, as though it were another computer on the same network. Which, in some sense, it is.

查看更多
Lonely孤独者°
5楼-- · 2019-08-17 02:59

I do this all the time. I have a directory in a Windows drive that I mount in my host ubuntu 12.04. I run virtualbox ubuntu 13.04 as a guest. I want the guest to mount the Windows directory with full non-root permissions. I do almost all my work from a bash shell, so this method is natural for me.

When searching for methods to automatically mount virtualbox shared folders, reliable and correct methods are hard to distinguish from those that fail. Failures include getting and setting permissions, as well as other problems.

Methods that fail include:

  • modifying /etc/fstab
  • modifying /etc/rc.local

I am fairly certain that rc.local can be used, but no methods I have tried worked. I welcome improvements on these guidelines.

On virtualbox 4.2.14 running nautilus (bash terminal) on an ubuntu 13.04 guest, Below is a working method to mount Common (sharename) on /home/$USER/Desktop/Common (mountpoint) with full permissions. (Note the ‘\’ command continuation character in the find command.)

First time only: create your mountpoint, modify your .bashrc file, and run it. Respond with password when requested. These are the four command-lines needed:

mkdir $HOME/Desktop/Common
sudo echo “$USER ALL=(ALL) NOPASSWD:ALL” >> /etc/sudoers
find $HOME/Desktop/Common -maxdepth 0 -type d -empty -exec sudo \
mount -t vboxsf -o \
uid=`id -u $USER`,gid=`id -g $USER` Common $HOME/Desktop/Common \;
source ~/.bashrc # Needed if you want to mount Common in this bash.

All other times: simply launch a bash shell.

The find command mounts the shared directory if the mountpoint directory is empty. If the mountpoint directory is not empty, it does not run the mount command.

I hope this is error-free and sufficiently general. Please let me know of corrections and improvements.

查看更多
登录 后发表回答