Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Mount shared folder on CentOS in VirtualBox
# The VirtualBox documentation[1] for how to install guest additions
# for Linux on a virtual host is somewhat messy. So here is what
# I did to make it work.
# Install the packages required
yum update
yum install gcc kernel-devel make
reboot
# Click: Devices/Install Guest Additions...
# Mount the ISO image with the guest additions
mkdir /cdrom
mount /dev/cdrom /cdrom
# Install guest additions
/cdrom/VBoxLinuxAdditions.run
# Share a folder from the VirtualBox control panel, giving it a share name.
ls /media/sf_<share_name>
# You could always mount the directory yourself as well
mkdir /a_folder_name
mount -t vboxsf the_share_name /a_folder_name
[1] http://www.virtualbox.org/manual/ch04.html
@aderowbotham

This comment has been minimized.

Show comment
Hide comment
@aderowbotham

aderowbotham Nov 3, 2012

I'm running a fresh installation of CentOS 6 and running ./VBoxLinuxAdditions.run fails at:
Building the main Guest Additions module [FAILED]

Also, clicking Devices/Install Guest Additions apparently has no effect. The shared folder does not appear in /dev or /media

Any ideas?

I'm running a fresh installation of CentOS 6 and running ./VBoxLinuxAdditions.run fails at:
Building the main Guest Additions module [FAILED]

Also, clicking Devices/Install Guest Additions apparently has no effect. The shared folder does not appear in /dev or /media

Any ideas?

@travispaul

This comment has been minimized.

Show comment
Hide comment
@travispaul

travispaul Nov 12, 2012

@aderowbotham, make sure you update.

I ignored the part about the update since I did so a few days earlier and within that time span there was a kernel-update so I got headers for a different kernel and received the same error as you. Updating, then compiling the additions worked for me.

@aderowbotham, make sure you update.

I ignored the part about the update since I did so a few days earlier and within that time span there was a kernel-update so I got headers for a different kernel and received the same error as you. Updating, then compiling the additions worked for me.

@the5rb

This comment has been minimized.

Show comment
Hide comment
@the5rb

the5rb Jan 11, 2013

Sorry this might be a bit of a lame question but which ISO should i mount after installing guest additions?

the5rb commented Jan 11, 2013

Sorry this might be a bit of a lame question but which ISO should i mount after installing guest additions?

@andremalenfant

This comment has been minimized.

Show comment
Hide comment
@andremalenfant

andremalenfant Apr 18, 2013

Thanks! That worked like a charm!

Thanks! That worked like a charm!

@alfredo-gemma

This comment has been minimized.

Show comment
Hide comment

Thank you!

@bertao

This comment has been minimized.

Show comment
Hide comment
@bertao

bertao Nov 23, 2013

Great Tutorial

bertao commented Nov 23, 2013

Great Tutorial

@dtubest

This comment has been minimized.

Show comment
Hide comment
@dtubest

dtubest Dec 17, 2013

@travispaul, update works for me, but can you brief why a updating is necessary?

dtubest commented Dec 17, 2013

@travispaul, update works for me, but can you brief why a updating is necessary?

@samayo

This comment has been minimized.

Show comment
Hide comment
@samayo

samayo Mar 25, 2014

@linnv I tried that link, although well presented .. is by no means better. It did not work for me, but only wasted my time.

samayo commented Mar 25, 2014

@linnv I tried that link, although well presented .. is by no means better. It did not work for me, but only wasted my time.

@cheesegrits

This comment has been minimized.

Show comment
Hide comment
@cheesegrits

cheesegrits Apr 10, 2014

@simon-eq ... and of course any guide that contains the phrase "before you do anything we need to disable SELINUX" should probably be avoided!

@simon-eq ... and of course any guide that contains the phrase "before you do anything we need to disable SELINUX" should probably be avoided!

@andydeng

This comment has been minimized.

Show comment
Hide comment
@andydeng

andydeng May 23, 2014

thx a lot!

thx a lot!

@dreampuf

This comment has been minimized.

Show comment
Hide comment
@dreampuf

dreampuf Jul 7, 2014

Solved my problem. thx

dreampuf commented Jul 7, 2014

Solved my problem. thx

@dunithd

This comment has been minimized.

Show comment
Hide comment
@dunithd

dunithd Aug 14, 2014

Thanks for sharing! Worked like a charm!

dunithd commented Aug 14, 2014

Thanks for sharing! Worked like a charm!

@dvapelnik

This comment has been minimized.

Show comment
Hide comment
@dvapelnik

dvapelnik Aug 28, 2014

hi!
I have an idea! I want to get list of shared but not mounted folders in my guest CentOS. In future I will mount this all folders under /var/www/html with filtering by regexp (lsOfMySharedFolder | grep 'shared_' | mountEachOf) and reconfigure my web-server for using this folders as web-source.
So.. my question: can I get list of shared but not mounted folders under guest OS?

hm... i can use automount and get this list from ls /media | grep 'shared_'

hi!
I have an idea! I want to get list of shared but not mounted folders in my guest CentOS. In future I will mount this all folders under /var/www/html with filtering by regexp (lsOfMySharedFolder | grep 'shared_' | mountEachOf) and reconfigure my web-server for using this folders as web-source.
So.. my question: can I get list of shared but not mounted folders under guest OS?

hm... i can use automount and get this list from ls /media | grep 'shared_'

@qhu91it

This comment has been minimized.

Show comment
Hide comment
@qhu91it

qhu91it Jun 11, 2015

Hi, thanks for sharing, but my folder share is read-only (setting in VirtualBox is full access), I want full edit this folder in guest CentOS too.

qhu91it commented Jun 11, 2015

Hi, thanks for sharing, but my folder share is read-only (setting in VirtualBox is full access), I want full edit this folder in guest CentOS too.

@oscaroxy

This comment has been minimized.

Show comment
Hide comment
@oscaroxy

oscaroxy Sep 25, 2015

I've installed anything like this tutorial, but with CentOS 7 I obtain when type "mount -l":
schermata 2015-09-24 alle 22 29 41

none /media/sf_<share_name>

so I can't do a new mount

mount -t vboxsf the_share_name /a_folder_name

because "the_share_name" is "none".

I would to do a new mount because I would a shared folder for web server (apache) in read-write, now the automount (/media/a_folder_name) is for root:vboxsf

thanks

I've installed anything like this tutorial, but with CentOS 7 I obtain when type "mount -l":
schermata 2015-09-24 alle 22 29 41

none /media/sf_<share_name>

so I can't do a new mount

mount -t vboxsf the_share_name /a_folder_name

because "the_share_name" is "none".

I would to do a new mount because I would a shared folder for web server (apache) in read-write, now the automount (/media/a_folder_name) is for root:vboxsf

thanks

@codemedic

This comment has been minimized.

Show comment
Hide comment
@codemedic

codemedic Oct 28, 2015

Worked for me ... one improvement I can suggest is to remove the reboot line.

You need to reboot only if you catch an update of a something like the kernel itself in the yum update step ( which is IMO unnecessary ). Installing kernel-devel does not require a restart afterwards. They are just adding a bunch of header files that will be used by the VBox installer, later in the procedure mentioned above.

Worked for me ... one improvement I can suggest is to remove the reboot line.

You need to reboot only if you catch an update of a something like the kernel itself in the yum update step ( which is IMO unnecessary ). Installing kernel-devel does not require a restart afterwards. They are just adding a bunch of header files that will be used by the VBox installer, later in the procedure mentioned above.

@samayo

This comment has been minimized.

Show comment
Hide comment
@samayo

samayo Feb 4, 2016

@codemedic actually, reboot is important. I don't know why, but since I made this comment I regularly get the same error at least once, when I create/recreate my vBox and rebooting seems to fix the issue half the time. I am even here now, because I have the same problem, and guess what ... I worked with after the 2nd time.

samayo commented Feb 4, 2016

@codemedic actually, reboot is important. I don't know why, but since I made this comment I regularly get the same error at least once, when I create/recreate my vBox and rebooting seems to fix the issue half the time. I am even here now, because I have the same problem, and guess what ... I worked with after the 2nd time.

@gohrco

This comment has been minimized.

Show comment
Hide comment
@gohrco

gohrco Apr 30, 2016

Thank you - this instructional worked for me!

gohrco commented Apr 30, 2016

Thank you - this instructional worked for me!

@dushansachinda

This comment has been minimized.

Show comment
Hide comment

nice!!!

@indi60

This comment has been minimized.

Show comment
Hide comment
@indi60

indi60 Jul 22, 2016

work like a charm on my centos 6.4

indi60 commented Jul 22, 2016

work like a charm on my centos 6.4

@JohnathanMarkSmith

This comment has been minimized.

Show comment
Hide comment
@JohnathanMarkSmith

JohnathanMarkSmith Aug 20, 2016

my issue is that its telling me I dont have permission for the folder

my issue is that its telling me I dont have permission for the folder

@w4r0

This comment has been minimized.

Show comment
Hide comment
@w4r0

w4r0 Sep 16, 2016

Work great on my centos 7.2.

w4r0 commented Sep 16, 2016

Work great on my centos 7.2.

@nlevchuk

This comment has been minimized.

Show comment
Hide comment
@nlevchuk

nlevchuk Jan 2, 2017

Hi. You need to install extra package bzip2 for VirtualBox >=5.0.

nlevchuk commented Jan 2, 2017

Hi. You need to install extra package bzip2 for VirtualBox >=5.0.

@robertloo

This comment has been minimized.

Show comment
Hide comment
@robertloo

robertloo Jan 24, 2017

Thank you for this!

Thank you for this!

@SteveDevOps

This comment has been minimized.

Show comment
Hide comment
@SteveDevOps

SteveDevOps Feb 28, 2017

Thx. Been looking for this. In my case, I was doing a fresh install off the latest v7, 1611 minimal iso and had to also reboot after the .run file was executed before /media/sf_<share_name> was seen. Not sure if a fresh terminal window would've also worked, but I was good after 2nd reboot.

SteveDevOps commented Feb 28, 2017

Thx. Been looking for this. In my case, I was doing a fresh install off the latest v7, 1611 minimal iso and had to also reboot after the .run file was executed before /media/sf_<share_name> was seen. Not sure if a fresh terminal window would've also worked, but I was good after 2nd reboot.

@annec22

This comment has been minimized.

Show comment
Hide comment
@annec22

annec22 Apr 20, 2017

Thanks! This worked for me with the following additional steps:

  • reboot after running /cdrom/VBoxLinuxAdditions.run
    sudo reboot
  • adding my user to vboxsf group (reference: link) because I encountered permission issues when opening the shared folder
    sudo usermod -aG vboxsf $(whoami)

annec22 commented Apr 20, 2017

Thanks! This worked for me with the following additional steps:

  • reboot after running /cdrom/VBoxLinuxAdditions.run
    sudo reboot
  • adding my user to vboxsf group (reference: link) because I encountered permission issues when opening the shared folder
    sudo usermod -aG vboxsf $(whoami)
@rockts

This comment has been minimized.

Show comment
Hide comment
@rockts

rockts Apr 28, 2017

[vagrant@aliyun-local /]$ sudo mkdir /vv
[vagrant@aliyun-local /]$ sudo mount -t vboxsf vv_host /vv
mount: wrong fs type, bad option, bad superblock on vv_host,
       missing codepage or helper program, or other error

       In some cases useful info is found in syslog - try
       dmesg | tail or so.

I executed the sudo mount -t vboxsf vv_host / vv after the above error
How to solve it?

rockts commented Apr 28, 2017

[vagrant@aliyun-local /]$ sudo mkdir /vv
[vagrant@aliyun-local /]$ sudo mount -t vboxsf vv_host /vv
mount: wrong fs type, bad option, bad superblock on vv_host,
       missing codepage or helper program, or other error

       In some cases useful info is found in syslog - try
       dmesg | tail or so.

I executed the sudo mount -t vboxsf vv_host / vv after the above error
How to solve it?

@rbncha

This comment has been minimized.

Show comment
Hide comment
@rbncha

rbncha May 18, 2017

is there any way to permanently mount the shared folder in every reboots ?

rbncha commented May 18, 2017

is there any way to permanently mount the shared folder in every reboots ?

@rkasavaraju

This comment has been minimized.

Show comment
Hide comment
@rkasavaraju

rkasavaraju Oct 9, 2017

Thank you worked for me. I had to do this first. yum install dkms binutils gcc make patch libgomp glibc-headers glibc-devel kernel-headers
then yum install kernel-devel
followed your instructions to get the shared drive working on CentOs7.4

rkasavaraju commented Oct 9, 2017

Thank you worked for me. I had to do this first. yum install dkms binutils gcc make patch libgomp glibc-headers glibc-devel kernel-headers
then yum install kernel-devel
followed your instructions to get the shared drive working on CentOs7.4

@sofuca

This comment has been minimized.

Show comment
Hide comment
@sofuca

sofuca Jan 21, 2018

Mount with fstab as so

<name_of_share> /path/to/mountpoint vboxsf default 0 0

sofuca commented Jan 21, 2018

Mount with fstab as so

<name_of_share> /path/to/mountpoint vboxsf default 0 0

@pius-pworld

This comment has been minimized.

Show comment
Hide comment
@pius-pworld

pius-pworld Feb 2, 2018

/sbin/mount.vboxsf: mounting failed with the error: No such device

/sbin/mount.vboxsf: mounting failed with the error: No such device

@imtrobin

This comment has been minimized.

Show comment
Hide comment
@imtrobin

imtrobin Jun 4, 2018

Thank you worked for me. I had to do this first. yum install dkms binutils gcc make patch libgomp glibc-headers glibc-devel kernel-headers
then yum install kernel-devel
followed your instructions to get the shared drive working on CentOs7.4

I did that and

sudo mount -t vboxsf Share /root/Share
/sbin/mount.vboxsf: mounting failed with the error: Protocol error

imtrobin commented Jun 4, 2018

Thank you worked for me. I had to do this first. yum install dkms binutils gcc make patch libgomp glibc-headers glibc-devel kernel-headers
then yum install kernel-devel
followed your instructions to get the shared drive working on CentOs7.4

I did that and

sudo mount -t vboxsf Share /root/Share
/sbin/mount.vboxsf: mounting failed with the error: Protocol error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment