M HYPE SPLASH
// news

How to fix virtualbox's copy and paste to host-machine?

By John Campbell

Sometimes while using VirtualBox, I have tried copying text from the virtual machine to the host machine but failed. Whenever that happens, I fix it by rebooting the virtual machine. Is there a solution to this because I don't want to keep rebooting again and again.

Note: It is always possible for me to copy text from the host to the virtual machine.

1

17 Answers

If your guest OS is ubuntu then running following two commands in ubuntu terminal should help:

$ killall VBoxClient
$ VBoxClient-all
14

On a Windows XP guest, I can kill "VBoxTray.exe" using the Task Manager (Ctrl+Alt+Del), then restart it from "Program Files/VirtualBox Guest Additions".

8

In the Oracle virtual box setting go to

Settings > General > Advance

There is a an option Drag n Drop. Select the direction you want to copy the text.

7

Install VBoxClient (requirement for next step):

sudo apt install virtualbox-guest-x11

Restart the VBox clipboard module:

pkill 'VBoxClient --clipboard' -f & sleep 1 && VBoxClient --clipboard

5

For me, Windows 7 host and Ubuntu 16.04 guest, I had to install VirtualBox guest additions.

  1. Start the virtual machine
  2. Click Devices menu
  3. Select Insert Guest Additions CD image
  4. Change to the directory where your CD-ROM drive is mounted (typically /media/<user>/VBOXADDITIONS_x.x.x/)
  5. Install it sudo sh ./VBoxLinuxAdditions.run
  6. Reboot the virtual machine!

I found the complete steps in this link

5

In Ubuntu you may need to install virtualbox-guest-x11

sudo apt-get install virtualbox-guest-x11

and then start virutal box client

VBoxClient-all
4

On Ubuntu 18.04 running on VirtualBox 5.2.22, I did the following:

  1. On VirtualBox Manager, right click Ubuntu VM -> Settings -> General tab on left -> Advanced tab on right`.
    Now choose Shared Clipboard as : Bidirectional

  2. On Ubuntu, on the terminal run the following commands:

    sudo apt install virtualbox-guest-x11

Now I had to restart Ubuntu to run the below command run successfully:

VBoxClient --clipboard

After this, the bi-directional copy started working.

How to fix shared clipboard in VirtualBox (Windows Guest)

  1. In VirtualBox Windows Guest, Open Task Manager
  2. Go to Processes Tab, highlight VBoxTray.exe and select End Process
  3. Go to Applications Tab and select New Task
  4. Browse to the VirtualBox Guest Additions installation folder and select VBoxTray.exe and select OK.

The bidirectional shared clipboard should work afterwards.

In Ubuntu 16.10 I had to run following command to get it to work:

service virtualbox-guest-utils start

In addition to this, set the Shared Clipboard setting to Bidirectional in General/Advanced Virtual box settings.

If needed, upgrade VirtualBox to latest version, currently 4.1.2, they solved many issues. Then reinstall Guest Additions on the VM, as copy-paste is managed by guest additions drivers.

Enabling Shared Clipboard on Ubuntu 19.10 Host, Ubuntu 18.04 Guest, VirtualBox 6.1.

VirtualBox VM Menu ->
Machine ->
  General ->
   Advanced ->
    Shared Clipboard: Bidirectional

is set

The guest's Ubuntu terminal commands:

sudo apt install virtualbox-guest-x11 --reinstall
VBoxClient-all --clipboard

I used --reinstall option because of I had virtualbox-guest-x11 package installed and before reinstalling it I had:

$ VBoxClient-all --clipboard
VBoxClient: error: No service specified. Quitting because nothing to do!

After reboot screen resolution jumps to its minimal value, so

VirtualBox VM Menu ->
View ->
  Auto-resize Guest Display

clicking would be required if you want it.

I use a Mac Host OS, and Ubuntu Guest (with lubuntu desktop).

Dmitry's answer got me so close! But VBoxClient wasn't running when I looked for it with ps, and trying VBoxClient-all failed:

$ VBoxClient-all
Failed to connect to the VirtualBox kernel service
Failed to connect to the VirtualBox kernel service
Failed to connect to the VirtualBox kernel service
Failed to connect to the VirtualBox kernel service
Failed to connect to the VirtualBox kernel service

Then I found

Turns out, VirtualBox additions didn't launch automatically for some reason. Starting vboxadd manually allowed me to then run the VBoxClient with the clipboard enabled.

arin@arin-VirtualBox:~$ sudo /etc/init.d/vboxadd start
Starting the VirtualBox Guest Additions ...done.
arin@arin-VirtualBox:~$ ps -ef | grep -i vbox
arin 2687 22537 0 10:53 pts/1 00:00:00 grep --color=auto -i vbox
arin@arin-VirtualBox:~$ sudo /usr/bin/VBoxClient --clipboard
arin@arin-VirtualBox:~$ ps -ef | grep -i VBox
root 2693 22100 0 10:53 ? 00:00:00 /usr/bin/VBoxClient --clipboard
arin 2698 22537 0 10:53 pts/1 00:00:00 grep --color=auto -i VBox

And now copy/paste works!

As of time of this post,

In my case, I've noticed bidirectional copy/paste doesn't work when VM is started in detachable mode.

For bidirectional copy/paste to work, I had to start the VM in Normal mode.

Ubuntu 20.04, Virtual Box 6.1

Copy and paste does work (provided you have installed VBoxGuestAdditions), but there is a few caveats:

  • There is text copy-and-paste and there is file copy-and-paste
  • If your VM is Windows, copy and paste should work for both text and file
  • If your VM is Ubuntu (or a flavor thereof, eg. Lubuntu)
    • text copy and paste should work
    • to copy files, you have to use the VirtualBox file manager...

To use File Manager...

  • In the VM window, choose file manager...open file manager

  • Log in using a linux user that exist on the VM to create a sessionlog in to file manager

  • Then use the copy buttonscopy between host and guest

My configuration is Windows host, Xubuntu guest. I guess it doesn't hurt to restart everything, but this is the client that matters. (VBoxClient-all is merely a script that runs /usr/bin/VBoxClient --clipboard and others.)

$ ps -fe|grep -i clip
tbc 1400 1 0 Jan18 ? 00:00:00 /usr/bin/VBoxClient --clipboard
$
$ p=1400;kill -int $p;ps -fp $p
$ /usr/bin/VBoxClient --clipboard
$ ps -fe|grep -i clip
tbc 30555 1281 0 13:01 ? 00:00:00 /usr/bin/VBoxClient --clipboard
$ pstree -sp 30555
init(1)---lightdm(1094)---lightdm(1261)---init(1281)---VBoxClient(30555)---{VBoxClient}(30556)
$

Note it runs in the background by default. It was owned by init(1), but when I invoked it, it got adopted through a tree I'm not familiar with.

I was using VirtualBox 4.3.12. Once I upgraded to 5.0 the latest, the bugs were fixed.

No combination of reinstalling Vbox additions helped.

Solution: always try upgrading to the latest

Login to your guest machine and open the CD drive where "VirtualBox Guest Additions" should be inserted.

Open this CD drive and execute the file "VBoxWindowsAdditions.exe".

After the installation you have to restart, then it should work!