MacOS – Shared directory with Guest Ubuntu has become empty: a problem of virtualbox guest addition

macosunixvirtualbox

I installed Ubuntu under Virtualbox in MacBook Pro with OS X El Capitan.

To share my OS X home directory /Users/tli folder with the guest Ubuntu, I downloaded the Virtualbox Guest Addition iso file to /Users/tli/Downloads/virtualbox/VBoxGuestAdditions_5.0.16.iso, specified it under the virtual machine's Settings -> Storage -> Optical Drive (see the screenshot below), and installed it under the guest Ubuntu.
Then the shared directory worked: my OS X home directory /Users/tli folder is mounted as /media/sf_tli, and I could access the content in my OS X home directory from guest Ubuntu.

enter image description here

But after restarting the guest Ubuntu and virtualbox maybe abnormally or maybe not (I forgot), the content of the shared directory became empty in the guest Ubuntu. To solve the problem, I tried to reinstall the Guest Addition, by clicking Devices -> Insert Guest Addition CD Image, but got the following error:

Unable to insert the virtual optical disk
/Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso
into the machine Ubuntu14.04.

Would you like to try to force insertion of this disk?

Details:

Could not mount the media/drive
'/Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso'
(VERR_PDM_MEDIA_LOCKED).

Result Code: NS_ERROR_FAILURE (0x80004005) Component: ConsoleWrap
Interface: IConsole {872da645-4a9b-1727-bee2-5585105b9eed} Callee:
IMachine {f30138d4-e5ea-4b3a-8858-a059de4c93fd}

Also see the following screenshot:

enter image description here

I feel it strange to look for the Guest Addition under /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso of my OS X, rather than /Users/tli/Downloads/virtualbox/VBoxGuestAdditions_5.0.16.iso which I specified earlier.

By the way, my user account under the guest Ubuntu is a member of group vboxsf.

What shall I do to make the shared directory work under the Guest Ubuntu?

Thanks.

Best Answer

Just solved the shared directory problem (showing the content of the shared directory), by installing the guest addition under gnome terminal of the guest Ubuntu:

cd /media/t/VBOXADDITIONS_5.0.16_105871/

sudo ./VBoxLinuxAdditions.run 

See "Installing Guest Additions from a Terminal" in https://askubuntu.com/a/22745/1471.

Questions:

  1. Why did the above command line solution succeed in showing the content of the shared directory.

  2. What is the cause of my problem in my post here? I still get the same error when clicking Devices -> Insert Guest Addition CD Image as in my post here.