Fix for Unable to Create Symlinks in Shared Folders Between VirtualBox Linux VM and Windows Host

Software Setup:

  • VirtualBox VM: Ubuntu 22
  • Host: Windows 10

When attempting to create symbolic links in a shared folder within an Ubuntu 22 VirtualBox VM, you may encounter several errors:

1.Error during npm install esbuild:

    Error: EPERM: operation not permitted, symlink '../esbuild/bin/esbuild' -> '/var/www/reverb.test/node_modules/.bin/esbuild'

    2.Error when creating symlinks in PHP:

    symlink(): Operation not permitted

    3.Error when running the ln command:

    ln: failed to create symbolic link 'xxx.so.0': Read-only file system

    4.Error when running the cp command:

    cannot create symbolic link `xxxx': Read-only file system

    5.Another error during cp:

    cannot create symbolic link `xxxx': Protocol error

    These issues occur because VirtualBox restricts the creation of symbolic links in shared folders for security reasons. To allow symbolic link creation, you’ll need to enable the option VBoxInternal2/SharedFoldersEnableSymlinksCreate/<share_folder_name>. For Vagrant users, this option is automatically configured when running vagrant up. For VirtualBox users, you can manually enable this setting using the VBoxManage.exe tool, which is located in the same directory as the VirtualBox GUI on Windows.

    Step-by-Step Guide:

    1.Close VirtualBox.

    2.Open a command prompt with administrator privileges and navigate to the VirtualBox installation directory (e.g., cd C:\Programs\Oracle\VirtualBox). Then, execute the following command:

    VBoxManage setextradata YOURVMNAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/YOURSHAREFOLDERNAME 1

    1) Replace YOURVMNAME with the name of your Ubuntu VM.

    2) Replace YOURSHAREFOLDERNAME with the name of the shared folder, which corresponds to the “Shared Folder Name” you set in VirtualBox, not the actual folder path or its name.

    Example:

    VBoxManage setextradata Ubuntu22 VBoxInternal2/SharedFoldersEnableSymlinksCreate/share 1

    3 Run VirtualBox as an administrator to apply the changes.

    References:

    发表回复

    您的电子邮箱地址不会被公开。 必填项已用 * 标注