Setting Up Shared Folders

Revision as of 17:59, 24 December 2024 by Brash99 (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

It is possible to allow the guest operating system (i.e. the virtual machine or VM) to have access to the filesystem of your host machine.

Step 1: Adding Guest Additions edit

The first step to having shared folders is to allow the guest operating system to add some modules to the virtual machine kernel which are necessary for file sharing. This is accomplished by mounting/attaching a special Guest Additions .iso file that comes with VirtualBox. Fortunately, in the most recent versions of VirtualBox this is fairly straightforward. Simply choose Devices->Insert Guest Additions CD image from the VirtualBox pulldown menu (note that this is pulldown menu is part of VirtualBox, and not part of your guest operating system).

Step 2: Power Up the Linux Virtual Machine edit

After you power up the Linux VM and log in, automagically a terminal window will pop up that will compile the new kernel module that is necessary, and go through the installation procedure. When this has completed, power down the VM again.

Step 3: Select a local directory/filesystem to be shared edit

With the VM in a powered-down state, select "Settings". Under the "Shared Folders" tab, click on the folder with a "+ sign" to add a new local folder/file system. Select the local folder path and folder name. MAKE SURE TO SELECT THE AUTO-MOUNT RADIO BUTTON!!! You should now see that this folder has been added to the list of "Machine Folders", with Auto-mount=Yes and Access=Full.

Step 4: Power Up the Linux Virtual Machine edit

After you have powered up the VM and logged in, open a terminal window and execute the command 'df'. You should see something like the following:

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/VolGroup-lv_root
                      25336932   5328644  18714568  23% /
tmpfs                   251080        84    250996   1% /dev/shm
/dev/sda1               487652     54829    407223  12% /boot
/dev/sr0                 56892     56892         0 100% /media/VBOXADDITIONS_4.3.30_101610
Dropbox              975922976 184014836 791908140  19% /media/sf_Dropbox

where 'Dropbox' will be replaced by whatever shared folder name you chose above. Note that the mount point will always be of the form /media/sf_XXXX for all of your shared folders.

Step 5: Fix Permission Problems edit

Even though we set things up with 'Access=Full' above, there is one remaining step to realizing that situation. We must add the local user to the vboxsf group. To do this, choose System->Administration->Users and Groups to start up the User Manager application. You will have to provide the root password when prompted. Click on the local user to highlight that line, and then click on 'Properties'. Under the Groups tab in the window that pops up, scroll down and click the radio button beside the vboxsf group. Click OK, and then exit the User Manager application.

Log out of the Linux VM and then log back in. If you execute the command 'groups' from a terminal window that your local account will now below to the vboxsf group, as well as its own default group.

If desired, you can make a symbolic link in your home directory to the shared folder with:

cd
ln -sf /media/sf_Dropbox Dropbox

where of course 'Dropbox' would be replaced with the name of your shared folder.