VirtualBox bidirectional clipboard sharing stops working after some time on a Linux guest OS

17

6

Clipboard sharing starts working fine, but it stops working after some time (until I reboot the machine).

From what I understand sometimes the guest additions stop working. I read that I should see vboxadd-timesyn running on my system. I checked ps -A | grep -i vbox and I don't see it. All I get is:

VBoxSerive
VBoxClient
VBoxClient
VBoxClient
VBoxClient

If this is indeed the problem, how do I restart the service? If it isn't, what else I could look at?

This is with a Windows 7 host and Linux Ubuntu guest.

Amelio Vazquez-Reina

Posted 2013-01-15T22:33:16.123

Reputation: 5 686

Answers

22

The linux one-liner:

pkill -f VBoxClient; VBoxClient --clipboard


A Windows powershell script.

echo "Trying to restart VBoxClient"

$vbox_process = Get-Process VBoxTray
Write-verbose $vbox_process
$procID = $vbox_process.id

if ($procID  -gt 0)
{    
    $cmdline = (Get-WMIObject Win32_Process -Filter "Handle=$procID").CommandLine
    Write-Verbose $cmdline

    Write-Verbose "Stopping VBoxTray"
    $vbox_process.Kill()
    $vbox_process.WaitForExit()
    Write-Verbose "VBoxTray stopped"

    Write-Verbose "Starting VBoxTray"
    Start-Process -FilePath $cmdline.Split(' ')[0]
    echo "VBoxTray Restarted. All Done"
} else {    
    Write-Warning 'Could not find existing vboxTray process. Launching direct?'
    Start-Process -FilePath "C:\Windows\System32\VBoxTray.exe"     
}

Note: powershell is not really my field of expertise, so I'm expecting some community edits here :)

Sentient

Posted 2013-01-15T22:33:16.123

Reputation: 356

1Worth noting these are both for the guest. – RichVel – 2015-09-21T16:33:48.047

Thank you, these both work great! It sucks that it's now 3 years later and this bug still exists. – Sarke – 2017-08-17T01:23:46.380

Linux one-liner worked great, upvoted. Didn't try powershell. – peedee – 2017-09-18T09:05:09.663

7

How to fix shared clipboard in VirtualBox

  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 clipboard should work afterwards.

user227392

Posted 2013-01-15T22:33:16.123

Reputation: 79

How does this work? The question description is 'Linux Ubuntu guest' Or do you mean the Windows Host? – Sentient – 2014-07-31T23:53:10.013

The question is about a Linux guest, and the VBoxTray.exe only applies to a Windows guest. – RichVel – 2015-09-21T18:00:25.367

5

I found out that on Linux guests (Ubuntu in my case) and Windows 7 hosts (I guess that doesn't matter) you just have to restart the following process on your guest machine:

/usr/bin/VBoxClient --clipboard

Find out the PID of the process with ps and kill it. Afterwards start the process with the above command again and the clipboard starts working again. I use this for example:

kill $(ps aux | grep '/usr/bin/VBoxClient --clipboard' | grep -v grep | awk '{print $2}')

/usr/bin/VBoxClient --clipboard

d.k.

Posted 2013-01-15T22:33:16.123

Reputation: 51

Thanks for providing a copy/paste solution! The catch: one has to fetch http://superuser.com/questions/536827 in the guest machine to be able to copy/paste that!

– starlocke – 2014-09-26T15:23:34.373

I found VBoxClient was installed in /usr/sbin on Debian 8 - this may well not be on the path for non-root users. – RichVel – 2015-09-21T17:49:28.387

That kill is a really long-winded way of saying pkill -f 'VBoxClient --clipboard'. If you don't care about the other services, you can just killall VBoxClient – raylu – 2017-02-11T04:53:17.357

1

Try running vboxadd-timesyn start to restart the service.

One other thing that I remember reading was to change the clipboard sharing from bidirectional to host to guest.

Here you can find an old bug ticket that looks similar to your problem. It's a long read, but you may find some suggestions in there useful.

Finally, if nothing solves the problem, I suggest you to open a bug report in VirtualBox's Bugtracker yourself, because you are not the first one having problems with the shared clipboard.

user1301428

Posted 2013-01-15T22:33:16.123

Reputation: 2 985

Changing away from bidirectional sharing didn't help. – RichVel – 2015-09-21T18:01:20.360

Thanks! But when I type vboxadd-timesyn start I get: command not found. Any suggestions? – Amelio Vazquez-Reina – 2013-01-15T22:50:59.533

The commands available are: VBoxClient, VBoxClient-all, VBoxControl and VBoxService. – Amelio Vazquez-Reina – 2013-01-15T22:52:06.460

1Can you try running /etc/init.d/vboxadd-timesync start? – user1301428 – 2013-01-15T22:53:01.447

The only commands completing /etc/init.d/vboxadd are vboxadd, vboxadd-service and vboxadd-x11 – Amelio Vazquez-Reina – 2013-01-15T23:04:22.053

1I've googled around a bit, and it looks like that command may have been renamed to vboxadd. If this is true, you might want to try running /etc/init.d/vboxadd and similar commands. – user1301428 – 2013-01-15T23:22:03.307

Thanks. this is indeed helpful. Unfortunately I am unable to restart or stop the service. If I try to stop it, it complains with Cannot umount vboxsf folders, whereas if I try to restart it, it complains with Cannot change owner vboxadd:1 for device/deb/vboxguest. In both cases it prints that the service I am attempting to stop or restart is theVirtualBox Guest Additions`, so I am probably heading in the right direction. – Amelio Vazquez-Reina – 2013-01-15T23:38:07.670

Did you set up any shared folders? If so, unmount them before you run the stop command. – user1301428 – 2013-01-15T23:42:40.477

Thanks, I didn't set up any shared folders. I haven't touched that feature since my last installation. – Amelio Vazquez-Reina – 2013-01-16T16:21:00.727

Then I suggest to proceed with the other options included in the answer, maybe this one is not the way to solve the issue. – user1301428 – 2013-01-16T18:03:58.057

1

I had similar problem: but in my case the process /usr/bin/VBoxClient --clipboard were closing multiple times per session.

To deal with that I created bash program:

#! /bin/bash

ps aux | grep '/usr/bin/VBoxClient --clipboard' | grep -v grep || /usr/bin/VBoxClient --clipboard

I just run it every time, I lost ability to use clipboard.

Murval

Posted 2013-01-15T22:33:16.123

Reputation: 11

I found that the problem was due to VirtualBox Guest Additions not installing properly (missing dependency of kernel headers etc causing a Virtualbox kernel module to not be built). – RichVel – 2015-09-21T17:50:52.590

1

I found that the problem was due to VirtualBox Guest Additions not installing properly (missing dependency of kernel headers etc causing a Virtualbox kernel module to not be built).

Try installing the guest additions manually through the command line, and read the errors carefully. The HOWTO below has detailed instructions.

One tip is to check the output of sudo lsmod | grep vbox, which shows the kernel modules for Virtualbox - this was empty initially. Here's the output after fix:

$ sudo lsmod | grep vbox
vboxsf                 40674  0 
vboxvideo              12405  1 
drm                   203590  3 vboxvideo
vboxguest             173675  6 vboxsf

Once the kernel modules were done, I just had to run /usr/sbin/VBoxClient --clipboard (on Debian 8 jessie) and the clipboard started working. Virtualbox version was 4.3.30.

The commands I ran for this setup (yours may differ) were:

aptitude install dkms build-essential linux-headers-generic
aptitude install linux-headers-3.16.0-4-586     # See HOWTO, match running kernel
cd /media/cdrom0
sh ./VBoxLinuxAdditions.run 
less /var/log/vboxadd-install.log     # If you get errors

A systematic way to fix this issue (and probably others) is to go through the Guest Additions HOWTO for Linux. The name of the install script has changed since 2009, but the HOWTO is still very helpful, and gives commands for Debian/Ubuntu and RHEL/CentOS style distributions.

RichVel

Posted 2013-01-15T22:33:16.123

Reputation: 218

0

The problem may be caused by VirtualBox Addons not starting correctly. Try this command in the guest OS:

sudo /etc/init.d/vboxadd start

jones

Posted 2013-01-15T22:33:16.123

Reputation: 21

What does that command actually do for you? Where would you type that in, Windows host or Linux guest? – Andrew Lott – 2013-07-05T07:18:58.827

@AndrewLott It's obviously a Linux command (sudo and init.d scripts). But still, having a little more explanation as to what it does would be nice. – slhck – 2013-07-05T08:10:55.500

You and I can tell it's a Linux command, but I'm thinking about other visitors who might not be so certain. – Andrew Lott – 2013-07-05T08:12:54.207

0

This is what worked for me..

I'm on linux mint 17.1 xfce. The official distro package supports 4.3.18.. I was on .22 and having lots of separate issues so I downgraded to .18. Then once booted I ran the Devices -> Insert Guest Additions iso and ran the .run installer as root. Despite the warning about detecting a package install version, I allowed it to overwrite. Bingo. no more problems with network & clipboard. I think the key thing, at least for my distro is to play off what the official package is, but use the iso that comes with client.

-Steve

Steve

Posted 2013-01-15T22:33:16.123

Reputation: 1