Mac – How to copy/paste into a minimal installation of CentOS on VirtualBox

centosclipboardcopy/pastevirtual machinevirtualbox

I am trying to copy&paste from my local Windows machine into my CentOS guest machine, running on VirtualBox. The CentOS installation is minimal (only the console).

I followed this guide, and enabled both shared clipboard and drag and drop, and rebooted. Now, when I get to the end of the article, it says

That’s it!  When you log back into the guest machine, you should be able to copy text from the host machine to the guest easily. The Drag’n’Drop option lets you select a whole data file from the host to the guest or vice versa.

I am not able to copy&paste. I tried right clicking on my guest OS, expected a copy/paste dialog to open up. No dice. I can't even see a mouse arrow on my guest OS.

I tried Ctrl+V and Ctrl+Shift+V….but they didn’t work.

Ctrl+Shift+V caused a ^V to appear on the command line, but nothing got pasted.

I was able to paste into Notepad on my Windows host machine, so I know my copy buffer (clipboard) is at least getting filled with what I want to copy on the host side of things.

The article just treats it as self-evident that there are no further instructions to be given. Did anyone run into this dilemma? What combination of keystrokes / mouse clicks do I need to copy/paste into my guest OS?

EDIT
I managed to track down this forum which was talking about Guest Additions/Centos and a .iso that I would need to replace another with. I downloaded the .iso, so…. now what?

I tried going into

> devices
    >> Insert Guest additions CD image

Which looked promising. But then I got hit with this error.

Unable to insert the virtual optical disk D:\virtualbox\VBoxGuestAdditions.iso into the machine Centos 7.

Would you like to try to force insetion of this disk?

Could not mount the media/drive 'D:\virtualbox/VBoxGuestAdditions.iso'
(VERR_PDM_MEDIA_LOCKED).

Clicking force unmount appears to do nothing.

Best Answer

For that to work, you have to install the Guest Additions. That will give you a shared clipboard.

After starting your VM, you can install the Guest Additions from the menu. Click on Devices and then select Insert Guest additions CD image.

Another way is, when your VM is off, you can attach an ISO image to it from the VirtualBox GUI. It is under the Storage tab.

When you install VirtualBox, it should contain the Guest Additions ISO image as well. If you can't find it, you can download it from here. Make sure it matches the exact version of Virtualbox.

The reason you need to install the Guest Additions to get copy and paste working is that your VM is a separate machine running in its own environment that is unaware of the host machine. You have to install drivers on the guest machine so it can communicate with the Virtualbox instance running on the host.

You can use your mouse without Guest Additions, but then it is either captured by the guest or owned by the host. You transfer control to the Guest by clicking in the Guest window. You have to "release" the mouse from the guest using a key combination (Right-Alt by default) to use it on the host again. See imgur.com/a/Ci5HM

If you have the Guest Additions installed, you mouse moves seamlessly between guest and host.

Note that if you don't have a GUI on your VM, but only a console, then you won't get a mouse pointer. A console system has no mouse. The Bash shell has no clipboard i.e. you can't copy/paste from/to a console-only system.

The easiest way to get around that is to use ssh to your VM from your host. You can then use copy and paste in the ssh terminal.

Related Question