Skip to content

Instantly share code, notes, and snippets.

@larsar
Created January 27, 2012 08:04
Show Gist options
  • Save larsar/1687725 to your computer and use it in GitHub Desktop.
Save larsar/1687725 to your computer and use it in GitHub Desktop.
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
@rbncha
Copy link

rbncha commented May 18, 2017

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

@rkasavaraju
Copy link

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

@markdavidburke
Copy link

Mount with fstab as so

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

@pius-pworld
Copy link

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

@imtrobin
Copy link

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

@lokeshhadoop
Copy link

One of the best post .. wasted almost whole day for this issue .... once i landed here ..able to resolve in few mins

@bbarthelemy
Copy link

Great post ! Worked like a charm !

@ozyalhan
Copy link

Thanks man ! good job.

@CreatureFear
Copy link

Thanks! this worked with my CentOs image from Osboxes
CentOS 7-1908 (64bit).vdi

@Bill-Wisotsky
Copy link

worked great thanks

@bambrozio
Copy link

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

@pius-pworld - I got the same error. If you look at the suggested log to figure out what went wrong /var/log/vboxadd-setup.log you probably will see the message asking you to install libelf-dev, libelf-devel, or elfutils-libelf-devel.

I did install the elfutils-libelf-devel by: yum install elfutils-libelf-devel. After that, the /cdrom/VBoxLinuxAdditions.run worked for me.

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