VirtualBox, sharing a Linux hosts file system in a Linux guest
Published:
| by Julian Knight Reading time ~1 min.
📖 Posts
| 📎
Linux, Virtualisation
| 🔖
VirtualBox
When you want to access the hosts file system from a guest OS in VirtualBox, you need to mount the virtual share. However, the default mount: sudo mount -t vboxsf <VBox-share-name> <mount-location> Will mean that only root can write to the shared folders. You need to tweak things to get a system that an ordinary user can write to. Here is the script I use:
#!/bin/bash
echo " "
echo "Script to mount the host disk under VirtualBox"
echo " "
USR=`whoami`
SHARE='Host-Root'
MNT="/home/$USR/VBoxHostRoot"
echo " Mounting $SHARE to $MNT ..."
mkdir $MNT
sudo mount -t vboxsf -o uid=$USR $SHARE $MNT
echo " Done."
echo
You can, of course, have this mounted by the guest OS at boot time by putting an entry into /etc/fstab
. Just make sure that every user that is set up has the appropriate folder created or move the folder to somewhere central and give it permissions so that all users have read/write access.