How to mount host share directory in Virtualbox Linux system

in virtualbox •  6 years ago  (edited)

It's quite easy to install Virtual Box Additions under Windows.
You just mount the .iso file and double click on the drive under
My Computer. It gets installed and once you set up shared
directory in VirtualBox for the choosen virtual a new drive
appears under My Computer. Boom done.

But under Linux it's not that easy. Sometimes you don't even
have a graphical environment installed (yet) and you just want
to access your host filesystem. I couldn't find any official
guide but I figured that out. Here is what made the trick for
me.

To prepare the virtual

  1. select the virtual you want to modify on the left side.
  2. right click -> Settings.
  3. click Shared Folders and then the tiny directory icon
    with green plus to add a new shared directory
  4. set following:
    • Folder Path: "/"
    • Folder Name: ROOT (should get filled in automatically)
    • Make Permanent: check
  5. hit OK button.
  6. start the virtual.

To prepare the machine

  1. switch to root user with su command.
  2. run mkdir /media/root.
  3. run apt update.
  4. run apt install linux-headers-$(uname -r) gcc make bzip2.

To install the additions

  1. in the running Virtual window hit Devices on the top then
    Insert Guest Additions CD Image
  2. run mount /media/cdrom
  3. run cd /media/cdrom
  4. run sh VBoxLinuxAdditions.run
  5. run mount -t vboxsf ROOT /media/root

Your host / path is now mounted under /media/root inside your
virtual.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Congratulations @n1-cz! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 1 year!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!