Oracle VirtualBox: Fix the Drag and Drop Operation From Host to Guest Failed error

Introduction

I recently needed to drag and drop a file from my host PC to an Ubuntu virtual machine running on Oracle VirtualBox. I was working on my introductory tutorial on how to parse a CSV file with Python ​, and I wanted to transfer a sample CSV file to the virtual machine.

Installing Guest Additions

I knew the first step was to install the Oracle Virtual Box Guest Additions ​. So, I completed the following steps to install them.

  1. With the virtual machine running, click Devices > Insert Guest Additions CD Image…
  2. In my case, on Ubuntu Desktop, a CD image will display in the Dock. This is the area similar to the Windows Taskbar.
  3. Open the CD Rom image.
  4. Right-click on the autorun.sh file and select “Run as a Program” to run it.
  5. Enter the root password when prompted.
  6. The program runs and takes a few minutes.
  7. Restart the virtual machine.

Drag and Drop Error

After completing these steps, the Guest Additions were installed. I set up drag-and-drop to give me the feature I needed by clicking Devices > Drag and Drop > Host to Guest. Then I tried dragging my file from my host PC file system to a directory on the virtual machine. As soon as my file hit the virtual machine window, I received the following error:

Screenshot of drag and drop operation from host to guest failed error

Drag and drop operation from host to guest failed error

The Details section of the error stated: “DnD: Error: Drag and drop to guest not possible – either the guest OS does not support this, or the Guest Additions are not installed.”

Display Protocols

After some trial and error and additional research, I was able to find the root cause. The issue was that my Ubuntu installation had defaulted to the Wayland display protocol. Wayland being the default makes perfect sense, since Wayland is the preferred display protocol and was designed to replace X11. Without going into too much detail, Wayland and X11 are display server technologies for Linux that are used to render graphical user interfaces. Wayland is the more modern version. It performs better and is more secure than X11. Unfortunately, Guest Additions only has limited support for Wayland. Features like Drag and Drop and the shared clipboard are more reliable when using X11.

To determine which display protocol your virtual machine is using, run this command:

echo $XDG_SESSION_TYPE

This will show one of two outputs, either x11 or wayland.

If you see wayland as the output, Guest Additions will not work correctly. In order to fix this, we need to switch to X11. In my case, since this virtual machine is only for educational purposes, and not something I plan to continue using long-term or for storing any sensitive data, I decided to switch to the X11 protocol. Then I could enable the shared features. You will need to consider your specific scenario to determine the risks of switching from Wayland to X11. If there is risk in your case, you may want to use an alternate file transfer solution.

Switching from Wayland to X11

WARNING: These instructions work on any Ubuntu Desktop installation, even non-virtual machine versions. Please take into consideration any security risks you may be taking before switching to the older, less secure X11 protocol.

The instructions for making the change are as follows:

  1. Log out the user.

  2. Select the user or enter the user name.

  3. Before entering the password, click the gear icon in the bottom-right corner of the screen.

    Screenshot of login screen showing gear icon in bottom-right corner

    Login screen gear icon.

  4. Clicking the gear icon will show two options Ubuntu and Ubuntu on Xorg. Ubuntu uses the Wayland protocol and Ubuntu on Xorg uses the older X11 protocol.

  5. Select Ubuntu on Xorg.

  6. Enter the password.

  7. If any errors occurred during previous attempts to install Guest Additions, then follow the same instructions as before to install again and ensure the process completes without errors.

  8. Restart the virtual machine.

Final Thoughts

After following these instructions, I still got the same error the very first time I tried to drag a file from my host PC to the virtual machine. However, after that first time, further attempts mostly worked without issue. I would still occasionally get the same error off-and-on, but for the most part it worked.


The postings on this site are my own and do not necessarily reflect the views of my employer.

The content on this blog is for informational and educational purposes only and represents my personal opinions and experience. While I strive to provide accurate and up-to-date information, I make no guarantees regarding the completeness, reliability, or accuracy of the information provided.

By using this website, you acknowledge that any actions you take based on the information provided here are at your own risk. I am not liable for any losses, damages, or issues arising from the use or misuse of the content on this blog.

Please consult a qualified professional or conduct your own research before implementing any solutions or advice mentioned here.