Setting up shared folders in Oracle VirtualBox on RHEL 8 can be tricky, especially when working offline or without a Red Hat subscription. This guide walks you through a complete, step‑by‑step process to configure a shared mount point inside your VM, install VirtualBox Guest Additions, and enable seamless file sharing between host and guest systems. You’ll learn how to create a local offline repository using the RHEL ISO, install essential build tools like gcc, kernel-devel, and elfutils-libelf-devel, verify kernel compatibility, and mount VirtualBox shared folders manually or automatically using /etc/fstab. Whether you’re preparing a MongoDB lab environment, setting up development workflows, or simply trying to move files between host and VM, this tutorial ensures a smooth and reproducible setup. Perfect for sysadmins, developers, and Linux enthusiasts working in isolated or enterprise environments.
- Make sure the shared folder is defined in VirtualBox
Inside VirtualBox Manager:
- Select your VM → Settings
- Go to Shared Folders
- Add a folder:
- Folder Path: your host folder
- Folder Name: e.g., shared
- Check Auto-mount (optional)
- Check Make Permanent
If you already did this, great — move on.
🔧 2. Install Guest Additions (required for shared folders)
First install the RPMS by creating an offline repository :
3. Mount the RHEL ISO inside VirtualBox
In VirtualBox:
Devices → Optical Drives → Choose a disk file… → select RHEL 8.6 ISO
Then inside the VM:
sudo mkdir -p /mnt/rhel8
sudo mount /dev/cdrom /mnt/rhel8
Verify:
ls /mnt/rhel8
You should see BaseOS, AppStream, Packages, etc.
4. Create local repo files
BaseOS repo
tee /etc/yum.repos.d/local-BaseOS.repo <<EOF
[local-BaseOS]
name=RHEL8 BaseOS
baseurl=file:///mnt/rhel8/BaseOS
enabled=1
gpgcheck=0
EOF
AppStream repo
tee /etc/yum.repos.d/local-AppStream.repo <<EOF
[local-AppStream]
name=RHEL8 AppStream
baseurl=file:///mnt/rhel8/AppStream
enabled=1
gpgcheck=0
EOF
5.Clean and rebuild DNF cache
dnf clean all
dnf makecache
6. Install your packages offline
Now your original command works perfectly:
dnf install -y gcc kernel-devel kernel-headers make perl elfutils-libelf-devel
Everything is pulled from the ISO — no subscription, no internet.
🧪 Verify kernel-devel matches your running kernel
This is important for VirtualBox Guest Additions.
uname -r
rpm -qa | grep kernel-devel
If they mismatch, install the correct version:
sudo dnf install kernel-devel-$(uname -r)
Inside the VM:
sudo dnf install -y gcc kernel-devel kernel-headers make perl elfutils-libelf-devel
sudo /usr/lib/virtualbox/vboxadd setup
If you haven’t installed Guest Additions yet, you can also mount the ISO:
Devices → Insert Guest Additions CD image
Then run:
sudo sh /run/media/$USER/VBox_GAs_*/VBoxLinuxAdditions.run
📁 7. Create a mount point inside the VM
Pick a clean, reproducible location:
sudo mkdir -p /mnt/mongodb_software
📌 8. Mount the shared folder manually
If your shared folder name in VirtualBox is shared:
mount -t vboxsf mongodb_software /mnt/mongodb_software
If you get a “protocol error”, it usually means Guest Additions aren’t installed or the folder name doesn’t match.
🔄 9. Make it auto-mount on boot (optional but nice)
Add this line to /etc/fstab:
shared /mnt/shared vboxsf defaults,_netdev 0 0
Then test:
sudo mount -a
🧪 Quick verification
Run:
ls /mnt/shared
You should see your host files immediately.