Share disk with virtual machine

From Klaus' wiki
Jump to: navigation, search

Is it possible to share the hard disk on you laptop to the virtual machine? Luckely the answer is: Yes.

From Mads Halkjær Villadsen, E16, I have these instructions. The figures are in Danish, but the buttons and settings are placed on similar places in the English version of VirtualBox.

First shut down the (not just pause) guest operating system - typical Centos, then on your host computer open the VirtualBox software.


Click on Settings/Opsætning


Click on Shared Folders/Delte mapper


Click on Add new shared folder/Tilføj ny delt mappe


Locate the folder on the host machine that shall be share with the virtual machine and click on Automount/Tilslut automatisk and Gør permanent

Accessing the folder

In the virtual Centos, when it is started open a file manager, e.g. Dolphin or Krusader. It is here shown for Dolphin.


Your share folder is located in /media, i.e. go to the root of the file system and locate the media folder.


Your share folder is called something that starts with sf_.


In Dolphin you can add the folder to be a place you can see every time you open Dolphin.

In Krusader you can bookmark it.

Alternatively you can make a symbolic link to your home directory by issuing this command in your shell:

]$ cd 
]$ ln -s /media/sf_klaus .

and the folder now appears in your home folder.

Access rights

If you can't access the folder it is most likely that you don't have the correct permissions to the folder.

[ ✓ kko@jdoe [Debug] $] ll /media/
total 8.0K
drwxr-xr-x.  3 root root     21 Nov  5 16:38 .
dr-xr-xr-x. 18 root root   4.0K Jan  9 11:18 ..
drwxrwx---.  1 root vboxsf 4.0K Feb 14 08:27 sf_klaus
[ ✓ kko@jdoe [Debug] $]

From the above you can see that it is root that owns the directory and that it belongs to the group vboxsf. In order to get access to the folder you have to become a member of the vboxsf group.

]$ sudo vi /etc/group

Search the file for the vboxsf name, typically near the end of the file.

To the end of the line add your login name, e.g. doe if you're running using the standard user.

Here I've added my user name - kko