Multi-OS gaming w/o dual-booting: Excelent graphics performance in a VM with VGA passthrough

Note: This articles is a technology/technique outline, not a detailed guide and not a how-to. It explains what is VGA passthrough, why you might be interested in it, and where to start.

Even with the current abundance of Linux native games (both indies and AAAs), with WINE reliably running almost any not-so-new software, many gamers who use Linux on a daily basis tend to switch to Windows for playing games. Regardless of one’s attitude towards non-free software, it has to be admitted that if you wish to try out some of the newest titles, you have no other choice than running them on a Windows installation. This is why so many gamers dual-boot: having installed two operating systems on the same machine and using Windows for playing games and Linux for virtually anything else, they limit their usage of Microsoft’s OS for gaming only. This popular technique seems handy – you get the luxury of using a Linux, and the gaming performance of Windows.

But dual-booting is annoying because of the need of reboot to switch your context. Need to IM your friend while playing? Save your game, shut down Windows, reboot to Linux, launch IM, reboot to Windows, load your game. Switching takes a long time, is inconvenient, and therefore the player may feel discouraged to do so.

What if you could run both operating systems at once? That’s nothing new, run a virtual machine in your Linux, install Windows within it, and voilà! But a virtual machine is no good for gaming, the performance will be utter cr terrible. Playing chess might work, but any 3D graphics won’t do because of the lack of hardware acceleration. The VM emulates a simple graphics adapter to display it’s output in a window of the host OS.

And that is where VGA passthrough comes in, and solves this issue.

Read the rest of this entry »

Dynamic linker tricks: Using LD_PRELOAD to cheat, inject features and investigate programs

This post assumes some basic C skills.

Linux puts you in full control. This is not always seen from everyone’s perspective, but a power user loves to be in control. I’m going to show you a basic trick that lets you heavily influence the behavior of most applications, which is not only fun, but also, at times, useful.

A motivational example

Let us begin with a simple example. Fun first, science later.

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(){
  srand(time(NULL));
  int i = 10;
  while(i--) printf("%d\n",rand()%100);
  return 0;
}

Simple enough, I believe. I compiled it with no special flags, just

gcc random_num.c -o random_num

I hope the resulting output is obvious – ten randomly selected numbers 0-99, hopefully different each time you run this program.

Now let’s pretend we don’t really have the source of this executable. Either delete the source file, or move it somewhere – we won’t need it. We will significantly modify this programs behavior, yet without touching it’s source code nor recompiling it.

For this, lets create another simple C file:

int rand(){
    return 42; //the most random number in the universe
}

We’ll compile it into a shared library.

gcc -shared -fPIC unrandom.c -o unrandom.so

So what we have now is an application that outputs some random data, and a custom library, which implements the rand() function as a constant value of 42.  Now… just run random_num this way, and watch the result:

LD_PRELOAD=$PWD/unrandom.so ./random_nums

If you are lazy and did not do it yourself (and somehow fail to guess what might have happened), I’ll let you know – the output consists of ten 42’s.

Read the rest of this entry »

e4rat – decreasing bootup time on HDD drives

This time I will describe how to set up e4rat in order to speed your Ubuntu’s boot time. Let’s begin with some motivation: my netbook used to boot-up in ~40 seconds. Using e4rat, it takes ~10-15 seconds. Impressive, isn’t it? Let’s see how does this trick work, and I’ll teach you how to enable it on your machine.

Read the rest of this entry »

FitBit trophies as a milestone for Ubuntu Accomplishments

Accomps logoYou may have heard about FitBit badges support in Ubuntu Accomplishments system. Matt Fisher and Chris Wayne have written a new collection of accomplishments which pulls in your FitBit badges to other trophies. You can learn more about what awesome work they did by reading their articles [Matt] [Chris].

To those of you thinking “Hey, that app is Ubuntu accomplishments. How does FitBit relate to Ubuntu?”: that’s what a separate collection means. All trophies are grouped in sets – each set may relate to a different community, may be developed by completely different people – and such sets are called collections. You can think about them as of plugins or add-ons. Collections are installed separatelly, and are optional. That means that you are free to install FitBit accomplishments alongside Ubuntu trophies, and that you can also use just FitBit badges and remove default collections that award you for being active in Ubuntu community.

Now why do I consider FitBit trophies a milestone for the project?

Read the rest of this entry »

Getting involved in Ubuntu by programming IS EASY!

It seems to be quite a common belief among potential Ubuntu contributors, that it is very difficult to contribute source code to Ubuntu. I have met with such opinion many times, in bug reports, comments at OMG!Ubuntu!, at AskUbuntu. There is quite a lot of people who might help and write some real code, but are not willing to do so, because they are overwhelmed by the size of the project.

It indeed may be sort of frightening for new developers to get started.  And it may seem even harder, if there is an established team working around the code one might contribute to. Is it so?

Some time ago I got involved in the Ubuntu Accomplishments System. Describing how I got here may be treated as encouraging material for those who might be helpful for Ubuntu Community, but for some reasons feel it’s out of their might.

Read the rest of this entry »

Changing ‘new message’ indicator color

Recently I got annoyed by the fact, that the messaging indicator on Unity’s panel is dark-blue. Although it is perfectly elegant, and is very consistent within the whole system (the same color expresses any other form of urgency), I found it difficult to notice whether it is lit up from a greater distance, say – 10 meters from the screen. As I like to wander around in my flat, I would prefer that color to be more vivid, loud.

Surprisingly, I’ve come up with a amazingly simple solution, that quickly led me to this result:

preview
Read the rest of this entry »