n1 avatar

How to mount host share directory in Virtualbox Linux system

n1-cz

Published: 24 Feb 2019 › Updated: 24 Feb 2019How to mount host share directory in Virtualbox Linux system

How to mount host share directory in Virtualbox Linux system

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.

Leave How to mount host share directory in Virtualbox Linux system to:

Written by

Python dev, tomorrow tech guy.

Read more #virtualbox posts


Best Posts From n1

We have not curated any of n1-cz's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From n1