VirtualBox bidirectional clipboard sharing stops working after some time on a Linux guest OS
Solution 1
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 :)
Solution 2
How to fix shared clipboard in VirtualBox
- In VirtualBox Windows Guest, Open Task Manager
- Go to Processes Tab, highlight VBoxTray.exe and select End Process
- Go to Applications Tab and select New Task
- Browse to the VirtualBox Guest Additions installation folder and select VBoxTray.exe and select OK.
The clipboard should work afterwards.
Solution 3
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
Solution 4
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.
Solution 5
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.
Related videos on Youtube
Amelio Vazquez-Reina
I'm passionate about people, technology and research. Some of my favorite quotes: "Far better an approximate answer to the right question than an exact answer to the wrong question" -- J. Tukey, 1962. "Your title makes you a manager, your people make you a leader" -- Donna Dubinsky, quoted in "Trillion Dollar Coach", 2019.
Updated on September 18, 2022Comments
-
Amelio Vazquez-Reina over 1 year
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 checkedps -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 over 11 yearsThanks! But when I type
vboxadd-timesyn start
I get:command not found
. Any suggestions? -
Amelio Vazquez-Reina over 11 yearsThe commands available are:
VBoxClient
,VBoxClient-all
,VBoxControl
andVBoxService
. -
user1301428 over 11 yearsCan you try running
/etc/init.d/vboxadd-timesync start
? -
Amelio Vazquez-Reina over 11 yearsThe only commands completing
/etc/init.d/vboxadd
arevboxadd
,vboxadd-service
andvboxadd-x11
-
user1301428 over 11 yearsI'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. -
Amelio Vazquez-Reina over 11 yearsThanks. this is indeed helpful. Unfortunately I am unable to restart or stop the service. If I try to
stop
it, it complains withCannot umount vboxsf folders
, whereas if I try torestart
it, it complains withCannot change owner vboxadd:1 for device
/deb/vboxguest. In both cases it prints that the service I am attempting to stop or restart is the
VirtualBox Guest Additions`, so I am probably heading in the right direction. -
user1301428 over 11 yearsDid you set up any shared folders? If so, unmount them before you run the stop command.
-
Amelio Vazquez-Reina over 11 yearsThanks, I didn't set up any shared folders. I haven't touched that feature since my last installation.
-
user1301428 over 11 yearsThen I suggest to proceed with the other options included in the answer, maybe this one is not the way to solve the issue.
-
Andrew Lott almost 11 yearsWhat does that command actually do for you? Where would you type that in, Windows host or Linux guest?
-
slhck almost 11 years@AndrewLott It's obviously a Linux command (
sudo
andinit.d
scripts). But still, having a little more explanation as to what it does would be nice. -
Andrew Lott almost 11 yearsYou and I can tell it's a Linux command, but I'm thinking about other visitors who might not be so certain.
-
Sentient almost 10 yearsHow does this work? The question description is 'Linux Ubuntu guest' Or do you mean the Windows Host?
-
starlocke over 9 yearsThanks for providing a copy/paste solution! The catch: one has to fetch superuser.com/questions/536827 in the guest machine to be able to copy/paste that!
-
Evelina over 8 yearsWorth noting these are both for the guest.
-
Evelina over 8 yearsI found
VBoxClient
was installed in/usr/sbin
on Debian 8 - this may well not be on the path for non-root users. -
Evelina over 8 yearsI 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).
-
Evelina over 8 yearsThe question is about a Linux guest, and the VBoxTray.exe only applies to a Windows guest.
-
Evelina over 8 yearsChanging away from bidirectional sharing didn't help.
-
raylu about 7 yearsThat
kill
is a really long-winded way of sayingpkill -f 'VBoxClient --clipboard'
. If you don't care about the other services, you can justkillall VBoxClient
-
Sarke over 6 yearsThank you, these both work great! It sucks that it's now 3 years later and this bug still exists.
-
peedee over 6 yearsLinux one-liner worked great, upvoted. Didn't try powershell.
-
Jeff Learman over 3 yearsNOTE: this will stop any other VboxClient services, such as drag-and-drop (and --seamless and --vmsvga, whatever they are.) Presumably they're just as easy to restart, so first use
ps -ef | grep -i vbox
. -
Oskar Berggren over 2 yearsWith regards to the commenters, it can be noted that they same problem occurs on Windows guest still in 2021 VB version and this answer is a workaround for it.
-
Community over 2 yearsYour answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.