Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save WaleedMortaja/1e346237a2424c00e7cdb3a43405d6fd to your computer and use it in GitHub Desktop.
Save WaleedMortaja/1e346237a2424c00e7cdb3a43405d6fd 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 (You must have internet on the CentOs machine)
yum update
yum install tar bzip2 kernel-devel make gcc elfutils-libelf-devel
# Click: Devices/Insert Guest Additions CD Image
# Mount the ISO image with the guest additions
mkdir /cdrom
mount /dev/cdrom /cdrom
# Install guest additions
/cdrom/VBoxLinuxAdditions.run
# If you see a message like:
# VirtualBox Guest Additions: Kernel headers not found for target kernel
# 4.18.0-147.el8.x86_64. Please install them and execute
# /sbin/rcvboxadd setup
# Then you have a mismatch between kernel and kernel-devel versions. One way to solve it is to update the kernel
# yum install kernel
# reboot
# Then remount and install guest additions
# mount /dev/cdrom /cdrom
# /cdrom/VBoxLinuxAdditions.run
# If you did not see the previous message, you can skip updating the kernel.
# Share a folder from the VirtualBox control panel, giving it a share name.
# You can access the shared folders using: (replace <share_name> with the name of your share)
cd /media/sf_<share_name>
# You could always mount the directory yourself as well
# (replace <folder_name> with the name you want to use to access the share. You can use any legal, not existing name)
# (replace <share_name> with the name of your share)
mkdir ~/<folder_name>
mount -t vboxsf <share_name> ~/<folder_name>
cd ~/<folder_name>
# Optional: unmount and remove "/cdrom" folder
umount /cdrom
rm -rf /cdrom
[1] http://www.virtualbox.org/manual/ch04.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment