Friday, May 5, 2017

Oracle Enterprise Linux side by side with Microsoft Windows using a software kvm

Environment / assumptions for this post:
  • Oracle Enterprise Linux 7.2 (OEL)
  • Windows 7
  • Both OEL and Windows have their own monitor
  • TigerVNC for Windows, version 1.7.1
  • x2vnc version 1.7.2
Goal: to use one keyboard and mouse between two physical computers and monitors without any hardware.

I was excited to switch from Windows to Linux (in my case Oracle Enterprise Linux, basically RedHat) for development, although I wasn't too thrilled about having two mice and two keyboards on my desk. I kept doing things like moving the Linux mouse and then typing on the Windows keyboard. There are many cheap KVM solutions, but I wanted to try a software solution. 

To make this work, you need to run a piece of software on the Linux side, and a VNC server on the Windows side. 

Step 1 - installing a VNC server on Windows

There are a few freely available VNC servers around, but we need one that specifically is backwards compatible with protocol version 3.3 - the version used by x2vnc. I had issues with TightVNC, so I tried TigerVNC. I found a 64bit Windows binary here:

https://github.com/TigerVNC/tigervnc/releases

Install the normal way. Make sure to change the port if required (default is 5900), and add a connection password. If you install as a service, it will restart when you boot.

Step 2 - installing x2vnc on OEL

This is a program written by Fredrik Hubinette. It was based on vncviewer code, and uses the RFB protocol, specifically version 3.3. As of this writing, the version is up to 3.8. More on this below. The steps are as follows:

Download the code from:

http://fredrik.hubbe.net/x2vnc.html

Extract into a temp directory:

cd my_temp_folder
tar -xvf x2vnc-1.7.2.tar.gz
cd x2vnc-1.7.2

Run configure:

./configure

Run make:

make

Do the install:

sudo make install

Don't forget to put this in your .xinitrc if you want it to run every time you log in to your graphical environment.

It is probably a good idea to put the VNC server connection password into a file. The first time you run the program, if you specify the filename it will ask you for the password and create it for you. It will create the password with permissions 600. In the following, I use "west" since my physical Windows monitor is on the left of my Linux desktop, so I want my mouse to roll off to the left, or west direction.

x2vnc -passwdfile ~/.vncpasswd -west 192.168.88.88:0

Finally, to get this to run automatically when you log in (Gnome in my case), you need to add a .desktop file to the autostart folder. The location is here:

~/.config/autostart/filename.desktop

And the file should contain something like this:

[Desktop Entry]
Name=x2vnc
GenericName=Connects to VNC on another server for screen sharing
Comment=This is basically a software KVM, but for mouse and keyboard only. 
Exec=/home/jjames/scripts/x2vnc.sh
Terminal=false
Type=Application
X-GNOME-Autostart-enabled=true

And the x2vnc.sh file is the following.
Note: we need the sleep 5, since the script has to run only when the desktop is fully loaded.

sleep 5
echo hello >~/.x2vnc.log
x2vnc -passwdfile ~/.vncpasswd -west 192.168.5.5:0 >>~/.x2vnc.log 2>&1 &

I had a few little glitchy issues that had workarounds:
  1. When sliding from Windows back to Linux, the Windows desktop program windows would appear as outlines. This may not matter, unless you are comparing files, or doing any other activity between the two monitors. I found a not-so-good solution was to click the Windows menu button in the bottom-left, and just leave it open. 
  2. To slide from Linux to Windows, you simply move the mouse in the direction you specified e.g. I chose West, which is left side. But I had a Gnome toolbar loaded, so I had to make sure the pointer was above the bar to work. 
  3. Occasionally, sliding over to Windows didn't work. The solution for me was to simply switch my Gnome from, say, desktop 2 to desktop 3 and try again.

No comments:

Post a Comment