Adding a share in Virtualbox

    
    

When running a guest VM in VirtualBox, it sometimes is advantageous to be able to share files between the host and VM guest instances.

This post will describe the steps necessary to accomplish sharing. Note that once we open the share, security of the sandboxed VM can be compromised under certain configurations. That is beyond the scope of this discussion. 

In this instance, the Host machine is a macbook High Sierra, and the guest VM is a Kali linux instance.

First add your share directory in the VM Box: 

Whatever you name your share here will be the name you will need to use when mounting in the vm guest OS. i.e. I named mine “kali clone shared folder” for my shared folder. You can name it whatever you want.

Next on the the guest OS make a directory to use for your mount preferably in your home directory ~/share. Once again, you can use whatever name you want.

mkdir share

Next open the terminal in the linux guest VM  and copy and paste the following or type it in. You can enable shared clipboard under Device-> Shared Clipboard-> Bidirectional

sudo mount -t vboxsf kali_clone_shared_folder ~/share/

You should now be able to copy files between OS’s using the folder “share” in your home directory. The Host OS in this case is a mac, and the companion share is located at /Users/admin/PathToYourShare/kali clone shared folder/

If you enable bi-directional sharing, you can move & copy files easily between Host & Guest. For security purposes, I usually enable Host>Guest uni-directional shares to prevent any data leaks outside the VM.

Note that once the guest VM is powered off, you will need to re-issue the mount command when restarting. If you exit the guest VM with a saved snapshot or save state, the share will persist on restart of the guest VM. You could always make it persistent in all states by modifying the way the share is created. When creating the share from the VirtualBox Manager, click on the two options for Auto-mount & Make Permanent.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.