When working with VirtualBox shared folders between an Ubuntu guest (11.04) and OS X host (10.6.6), attempting to create symbolic links results in the frustrating error:
ln: creating symbolic link foo': Read-only file system
This occurs exclusively in shared folders, while normal symlink creation works fine in non-shared directories and on the host OS directly.
The core issue stems from VirtualBox's shared folder implementation (vboxsf). By design, this filesystem driver:
- Doesn't support UNIX-style symlinks due to cross-platform compatibility concerns
- Treats shared folders as read-only for certain operations
- Has different permission handling between host and guest systems
Option 1: Use alternative sharing methods
Replace vboxsf with NFS for more UNIX-like behavior:
# On host (OS X):
sudo vi /etc/exports
# Add: /path/to/share -alldirs -mapall=youruser:yourgroup localhost
# On guest (Ubuntu):
sudo apt-get install nfs-common
sudo mount -t nfs -o resvport,rw localhost:/path/to/share /mnt/share
Option 2: Use hard links (when applicable)
ln source_file linked_file # Instead of ln -s
Note: Hard links only work for files, not directories, and must be on the same filesystem.
Option 3: Configure shared folder with symlink support
For VirtualBox 5.0+, you can try:
VBoxManage setextradata "VM name" VBoxInternal2/SharedFoldersEnableSymlinksCreate/sharename 1
Then restart the VM. This may require running VirtualBox as root/admin.
For development environments where symlinks are crucial:
- Consider using Vagrant with rsync or NFS synced folders
- Set up Samba sharing instead of vboxsf
- Move the project directory entirely into the guest OS
Many development tools and package managers (npm, composer, etc.) rely heavily on symlinks. When they fail silently or produce cryptic errors, it can waste hours of debugging time. Understanding these VirtualBox limitations upfront saves frustration during environment setup.
For example, when Node.js projects fail with EPERM: operation not permitted
during npm install
, the root cause might be symlink creation attempts in shared folders.
Many developers working with VirtualBox shared folders between Linux guests and macOS hosts encounter this frustrating error when trying to create symbolic links:
ln: creating symbolic link foo': Read-only file system
While symlinks work perfectly in non-shared directories and on the host OS directly, the shared folder interface presents this limitation. Let's examine why this occurs and how to work around it.
The VirtualBox shared folder functionality (vboxsf) doesn't fully support Linux filesystem features like symlinks due to:
- Filesystem protocol differences between host and guest OS
- Security restrictions in the shared folder implementation
- Incomplete emulation of Linux filesystem capabilities
Here are several approaches developers can take:
1. Use Bind Mounts Instead
Create a bind mount in your Linux guest that points to the shared folder:
sudo mkdir /mnt/shared
sudo mount --bind /path/to/shared/folder /mnt/shared
Then create symlinks within this mounted directory.
2. Configure Shared Folder with Symlink Support
Add this line to your VM configuration file (.vbox):
<SharedFolder name="shared" hostPath="/path/on/host" accessMode="2" writable="true" autoMount="true"/>
The key parameter is accessMode="2"
which enables full write access.
3. Alternative Sharing Methods
Consider these more symlink-friendly alternatives:
- NFS shares:
sudo mount -t nfs host:/path /mnt/nfs
- Samba shares:
sudo mount -t cifs //host/path /mnt/smb
After implementing any solution, verify with:
ln -s /path/to/target /path/to/link
ls -l /path/to/link # Should show the symlink
If you're stuck with vboxsf, consider these approaches:
# Create the symlink elsewhere then move it
ln -s /target /tmp/link
mv /tmp/link /shared/folder/link
# Or use hard links if possible
ln /target /shared/folder/link
Remember that these workarounds have limitations and may not suit all use cases.