scnr.net

It’s not possible? Says who?

Clipboard sharing over VNC broken? (Linux server)

without comments

I use ‘vnc4server’ on an Ubuntu machine. After some recent update ‘vnc4config’ refuses to start and clipboard sharing with clients (Windows, UltraVNC in one case) does not work.

Apparently the problem is this: vnc4server syncs the “cutbuffer”, but most applications use “Selections” (“PRIMARY” and “CLIPBOARD”); somehow this reminds me of XKCD #927. For a better explanation and a solution go to the autocutsel website: http://www.nongnu.org/autocutsel/

Written by johnLate

February 1st, 2013 at 1:24 am

Posted in Uncategorized

VGA passthrough to a Xen HVM DomU (Windows 7; Dom0: Arch Linux)

with 2 comments

I don’t like dual boot solutions to switch between Windows and Linux. I’m considering to put Windows into a virtual machine. However, the main reason to keep Windows at all is occasional gaming. Therefore I did a quick & dirty Xen installation to figure out whether this is a viable option for me.

Here are my notes:

  • basic Arch installation using archlinux-2012.12.01-dual.iso
  • as usual, the arch wiki pages were helpful: Official Arch Linux Install Guide, Unofficial Beginners’ Guide, Xen
  • installed xen-hg-unstable using packer
  • used lsusb -t to figure out which usb devices are connected to which root hub
  • used lsusb -v to get PCI-ID (iSerial) of that hub
  • to unbind a device from its driver and make it available for passthrough:
    • echo $ID > /sys/bus/pci/device/$ID/driver/unbind
    • echo $ID > /sys/bus/pci/drivers/pciback/new_slot
    • echo $ID > /sys/bus/pci/drivers/pciback/bind
  • after unbinding the VGA adapter: blank screen – therefore: ssh!
  • created a qcow2 Container for the guest system
  • config file for the VM:
  • name="windows"
    builder="hvm"
    vcpus=4
    memory=2048
    disk = [
            "/root/windows.qcow2.img,qcow2,hda,w",
    #       "/dev/sda,,hdb,w",
            "/root/en_windows_7_professional_x64.iso,,hdc,r,devtype=cdrom"
    ]
    vif=[ 'bridge=xenbr0' ]
    boot="cd"
    pae=1
    nx=1
    gfx_passthru=1
    pci=["00:02.0", "00:1a.0", "00:1b.0"]
     
    vnc=1
    vnclisten="0.0.0.0:2"
    vncpasswd="********"
  • VNC just shows “serial0 console”, but delivers mouse events!
  • lspci:
  • [...]
    00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09)
    [...]
    00:1a.0 USB controller: Intel Corporation 6 Series/C200 Series Chipset Family USB Enhanced Host Controller #2 (rev 04)
    00:1b.0 Audio device: Intel Corporation 6 Series/C200 Series Chipset Family High Definition Audio Controller (rev 04)
    [...]
  • 00:02.0 is Intel HD Graphics 2000 (from a Core i5-2500T)
  • 00:1a.0 has a keyboard and a mouse attached to it
  • the VM went into standby once, waking it up with ‘xl trigger windows s3resume’ resulted in a bluescreen -> disabled standby in Windows

I installed drivers from the Intel website for the graphics adapter, everything else worked fine out of the box.

To test the performance I used the “Windows Experience Index” and StarCraft II, once in the VM and once in a similar installation running directly on the same hardware:
xen-passthrough-perf
I combined three screenshots here… left to right: running without Xen; Xen (vcpus=2); Xen (vcpus=4). The degraded hard disk performance is probably due to using a container file instead of a real partition. Apart from the memory operations the results are quite good.

StarCraft II was running at 1920×1200 “Windowed (Fullscreen)”, low settings. I chose one of my last replays, about 20 minutes long, set it to follow the camera of the other player and used Fraps to measure the performance:

[FPS]  min   max   avg
VM:     19    60    41.160
real:   21    60    45.109

For a quick and dirty proof of concept this was quite successful. Next will be an attempt to do VGA passthrough on another machine with a NVidia GeForce GTX560Ti, but I don’t know when I will find time for that, yet.

Written by johnLate

December 17th, 2012 at 1:40 am

Posted in Uncategorized

fakeuname

without comments

I recently needed to compile a proprietary kernel module for a different kernel than was currently running. There were multiple Makefiles involved and several references to header and kernel object directories based on “uname -r”.

Why didn’t I just boot the target kernel version? Well, the module is a driver for a specific device required for a certain service. Rebooting into the new kernel before building the new module would have caused more downtime for the service.

As I didn’t want to carefully edit several Makefiles and other files, I did a quick web search and found fakeuname. It worked fine and enabled me to fix some other unexpected compile errors, before shutting down the service. So I didn’t need to manually tamper with the version detection and still had minimal service downtime.

Written by johnLate

May 7th, 2012 at 1:11 am

Posted in Uncategorized

Arch: post installation; herbstluftwm, flash

without comments

Using the Beginners’ Guide and the Xorg wiki pages, installing X is not very hard. I just installed the required packages with pacman.

Then I needed a window manager. I chose herbstluftwm, which I haven’t used until now. Thorsten, the author, studies at the same university as I and I think it’s a cool project. As I’m trying out new stuff anyway, the decision was a no-brainer.

I installed herbstluftwm-git via yaourt. I copied the example configuration files from /etc/xdg/herbstluftwm to ~/.config/herbstluftwm and created a .xinitrc.

Launching X with startx worked at the first attempt. chromium and flashplugin also were easy to install. Just sound didn’t work right away, which I solved by consulting the Advanced Linux Sound Architecture (ALSA) wiki page.

But fullscreen flash didn’t work right away. Read the rest of this entry »

Written by johnLate

March 31st, 2012 at 2:45 pm

Posted in Uncategorized

First steps with Arch Linux

without comments

Core message (aka “TL;DR”): If you’re new to Arch Linux, start with:

those pages will probably save you a lot of time and frustration.
 

I finally decided to try out Arch Linux. I did the base install a few days ago. A bunch of unrelated stuff has happened since then, so I hope I recall the following correctly.

As always when trying out new stuff, I could rely on my talent to immediately run into some issues. Read the rest of this entry »

Written by johnLate

March 27th, 2012 at 10:50 pm

Posted in Uncategorized

Quick & Dirty git statistics (commits, insertions, deletions)

with one comment

Need to know who made how many commits and how many changes in your source tree?

Here’s a quick and dirty way to generate such statistics:

perl -e 'foreach(`git shortlog -s -n`){'\
'($c,$a)=$_=~/^\s*(\d+)\s*(.+?)\s*$/;$p=$m=0;'\
'foreach(`git log --author="$a" --pretty=tformat: --numstat -C`)'\
'{($pp,$mm)=$_=~/^\s*(\d+)\s+(\d+)/;$p+=$pp;$m+=$mm;}'\
'printf "%5dc %8d+ %8d- %s\n",$c,$p,$m,$a;}'

result:

   72c    26183+     2506- Bob Byte
   20c     1270+      104- Jim Vim

Written by johnLate

January 31st, 2012 at 8:30 pm

Posted in Uncategorized

Creating a custom keyboard layout for Windows

without comments

I recently switched from a keyboard with German layout to one with US layout. But I still need German umlauts and other special characters.

US International seemed to contain everything I needed. There was just one annoying problem: Dead keys.

In Ubuntu this was no problem, there is a “US Intl. – no dead keys” layout.

I didn’t find this layout in Windows. But Microsoft provides a tool to create own keyboard layouts, The Microsoft Keyboard Layout Creator.

With this tool you can open existing layouts and modify them. Have fun.

Written by johnLate

October 5th, 2011 at 6:31 pm

Posted in Uncategorized

Cracking a BIOS password

with 2 comments

Situation

Someone in my family owns an older laptop, but they have lost the BIOS password. You can boot into Windows XP, but you can not enter the BIOS Setup (e.g. for changing the order of boot devices) without password.

Solution

I found a tool called CmosPwd which tries to decrypt BIOS passwords. However, there was a problem: it only runs on DOS.  Therefore I took a DOS boot floppy disk image and added CmosPwd to it (you can use e.g. MagicISO to edit floppy images).

But how to boot a floppy disk image when the machine boots directly into Windows XP?  You can instruct the NTLDR (XP’s bootloader) to boot Grub4DOS instead of the Windows kernel and use Grub4DOS to load the floppy image into memory and boot from it. Copy the floppy image, grldr from Grub4DOS to C:, edit your boot.ini and create a menu.lst.

Finally you just need to reboot the machine, select Grub4DOS in the boot menu, and run cmospwd.

Written by johnLate

September 9th, 2010 at 8:27 pm

Posted in Uncategorized

Installing XenServer 5.5 on a remote machine (gPXE + HTTP)

with 7 comments

Situation

Imagine you have a remote machine several kilometers/miles away. It is running Linux and you have root access via ssh over the internet. But you can not operate the BIOS screen or any regular installers (because you have no access to keyboard-in or VGA-out). Furthermore, the machine is not configured for booting from network. The currently running Linux installation is no longer needed and you have to install XenServer.

There is a section “PXE installation” in the official manual, but that requires setting up or reconfiguring a DHCP server and a TFTP server. But what if there is no DHCP server in that network or if you have no access to it? Let’s do this with a fixed IP and just an HTTP server.

Precautions

Imagine something goes wrong: Especially if you have to drive all the way to the server or call and pay someone to reboot it, you should test everything on another machine you have physical access to.

Battle Plan: automatic installation

  1. Store the installation data on a HTTP server
  2. Provide the installer with an answer file, so it does not require user input.
  3. Modify the installation image to fix some issues regarding the use of a static IP.
  4. Setup the network bootloader
  5. Reboot the remote machine / start installation

Read the rest of this entry »

Written by johnLate

April 24th, 2010 at 5:30 pm

Posted in Uncategorized

AVM Fritz!Card USB and Linux – an odyssey

with 3 comments

I want to send and receive faxes and I have a AVM Fritz!Card USB (v1). For sending I could just hook it up to my Windows XP machine, but my XP machine isn’t running all the time. My only computer running 24/7 runs Linux (Ubuntu Server Edition 9.04).

So, how hard can it be?

Let’s see: AVM has a driver from Jul 07, 2005 for SuSE. I don’t use SuSE, but I think there have been some releases since 2005. Then I found a RPM from Oct 08, 2007 containing a few patches to the AVM version.

So I download the RPM, apply the patches, install kernel-headers for my current kernel and try to compile the glue code for this kernel module. And it fails. Surprise, surprise.

Apparently there have been some API changes, let’s try to address them. First I had to replace DECLARE_MUTEX_LOCK with DECLARE_COMPLETION. Then it complained about this line:

1
if (NULL == find_task_by_pid (thread_pid)) {

After some searching on Google I replaced it with:

1
if (NULL == find_task_by_pid_ns (thread_pid, 0)) {

It also complained about not finding the header file asm/semaphore.h, which I found in linux/semaphore.h.

Then there was a problem with several USB functions not working. Apparently somebody was (understandably) fed up with non-free modules using their GPL code, so some checks concerning MODULE_LICENSE were introduced. Of course there are some tricks around this, but almost nobody is comfortable to distribute a patch containing such silly shenanigans.

So now I have a kernel module I can’t redistribute, but it loads. And it still doesn’t work. capiinfo returns a lot of fields containing just 00000000. This can be tracked down to the use of strncpy instead of lib_strncpy in src/driver.c. After changing this I can finally send and receive faxes with capisuite.

Conclusion: Getting older hardware with out of date and non-free drivers to work under Linux is possible but very annoying and time consuming.

Written by johnLate

September 25th, 2009 at 3:12 pm

Posted in Uncategorized