Sunday, October 21, 2012

Dnsmasq as a local DNS and DHCP server

Lately it is fairly common to have quite a few devices connected in local network, be it wireless or wired: computers, tablets, smartphones, media players, gaming consoles... wouldn't it be nice to call them by name instead of IP?
Also some internet providers rent you a router to access their services, which may have few configuration options; in this case if it gives you by default  unreliable DNS servers and no way to change them you could get a lot of undesired errors when contacting internet servers.
Finally maybe you have an old or low power computer you can leave on 24/7...

Dnsmasq to the rescue: three birds with one stone!

You could use a low spec (and hopefully low power drain) computer, like a Raspberry PI or similar (or my faithful Dockstar, see http://archlinuxarm.org/platforms/armv5/seagate-dockstar), to solve both issues using dnsmasq; this machine from now on will be called server.
All major distributions have a package for it, so I won't go into specifics on how to install it or have it run at startup and go straight to configuration.

Problem 1: home computer by names, not IP

That's the easiest part, just edit /etc/hosts on server:
...
192.168.1.1 router router.local livebox livebox.local
192.168.1.100 eeepc eeepc.local
...
and restart dnsmasq.
If you plan not to use dnsmasq as DHCP server, configure all other devices to use server as DNS server, using your usual one  as secondary server; otherwise, take a look at point 2 for a better alternative.

Problem 2: replace broken router DHCP

If you go further and configure dnsmasq to also be a DHCP server you won't have to configure the other devices one by one; let's see how. First remember to give the server a static address; it won't know it otherwise!
Let's edit /etc/dnsmasq.conf:
domain=local
dhcp-range=192.168.1.100,192.168.1.200
dhcp-host=00:11:22:33:44:55,192.168.1.100,eeepc
dhcp-option=3,192.168.1.1
dhcp-option=6,192.168.1.101,8.8.8.8,8.8.4.4,192.168.1.1
this way your eeepc will always get the same IP address and will be given the name "eeepc"; the address before the IP is the mac address. You also configure it to give addresses in the range 192.168.1.100 - 192.168.1.200 and to use the router (192.168.1.1) as gateway (option 3) and to use a list of DNS (option 6 - 192.168.1.101,8.8.8.8,8.8.4.4,192.168.1.1), which will be used in order to resolve host names.
In the fairly common case of a device (like a netbook or notebook) which has bot ethernet and wifi and you want to have it always pick the same IP:
dhcp-host=00:11:22:33:44:55,66:77:88:99:AA:BB,192.168.1.100,eeepc
where the two mac addresses are for ethernet and wifi (the order doesn't matter in the common case of the two interfaces never being used together). 
No further configuration is needed on the clients, just set them to dhcp if they're not and you're done; you will have to renew the DHCP lease, this varies depending on the device.
Restart dnsmasq and turn router's DHCP off and you will have the comfort of dhcp and the full freedom of configuring it the way you likeit. 

This is just a simple example, check dnsmasq doc out to know about its many options and as always: enjoy :-) 

Sunday, August 26, 2012

Cedar trail still not for linux gamers

Let's play on Lubuntu with my Eeepc 1025C

After the good results I got from videos, I was confident also the games would play decently. Sadly I was wrong, here is a short detail of the games I tried (mostly open source, plus the ones from recent Humble Bundle for Android 3).

The good

Battle for Wesnoth: I love this game, everyone who likes turn based strategic games should give it a try: this plays ok, sometimes there is some slowdown but completely enjoyable otherwise.
World of goo: this is a great puzzle game: it works with low framerate, but it seems still playable. I put in the good because it's far better then the rest. Note: on Windows 7 it plays ok, some slowdowns here and there, but completely playable - I mean far better than on Lubuntu... :-(
Uplink: I haven't played it much but it seems to work just ok.

The bad

Sauerbraten: 2 frame per second, need I say more? It is so slow it is even annoying to try to change the options to get a decent framerate
Neverball: a little better than Sauerbraten but still unplayable; also the screen flashes continually...
Spacechem: annoyingly slow
The rest from Humble Bundle for Android 3 either refuses to install due to bad graphics or simply crashes at start.

The result are so bad that I am not motivated to try more games; I think the only ones which will work are the ones without 3D graphics...
Better watch videos :-)

Saturday, August 11, 2012

Lubuntu on Eeepc 1025C with correct resolution and accelerated video playback

This article focuses on installing accelerated graphics drivers for Lubuntu on an eeepc 1025c, but most of the content should apply also to any other Ubuntu 12.04 derivate and any other cedar trail netbook.
WARNING: using the terminal may easily lead to serious problems; the procedure is a bit complicated and has various steps, but it's the result of many failed attempts and a few reinstallations! If in trouble at any point ask and I can try to give some advice.
No more comments please: sorry for that but comment are not working right. Write me a public post on google+ instead, I will reply from there.

Why Lubuntu?

The 1025c, as well as many other netbooks in the same price range, is sold with Windows 7 Starter Edition preinstalled, a decent operating system, but very much resources hungry; since the 1025c can't be easily upgraded to more than its starting 1GB, just opening a few applications easily fills the memory up and results in disk swapping and terrible sluggishness.
Lubuntu 12.04 is much lighter on this eeepc and can run Skype and Chromium with a few open tabs while still leaving 500MB of free RAM; also it can easily browse windows and mac shares to get multimedia contents for example.
Also Min 13 Cinnamon works very well; a little heavier but still completely usable.

STATUS ubuntu 12.04: Ubuntu 12.04 (and derivates like Mint 13) is working ok, with decent 2D  performance and accelerated hi-res video playback; 3D is poor. Unity is not recommended if you only have less than 2GB RAM - better go with lighter desktops like Cinnamon, Mate, Lxde, Xfce...
Please be aware that recent Ubuntu LTS updates like 12.04.2, 12.04.3 and 12.04.4 use a more recent kernel and xorg which are not compatible with these drivers.

STATUS ubuntu 12.10: Not recommended. Basic unaccelerated desktop functionality can be achieved by tweaking both live and installed version setup.
Live session: 
1. On boot push F5 (or Tab, it depends on the tool you use to start it) and add to kernel option at the end: "text". In case you already have the "persistent" option you must remove it.
2. It will boot to a shell with user ubuntu
3. sudo nano /etc/X11/xorg.conf (it will create this file):
Section "Device"   
Identifier             "Intel GMA3600"   
Driver                 "fbdev"
EndSection
4. Save the file
5. Start the graphical session whith command:sudo service lightdm start
6. After installation (before reboot) modify /etc/X11/xorg.conf in the same way you did for live
UPDATE ubuntu 12.10 11/21/2012 : according to launchpad a fix has been added to quantal-proposed. Since it is just a hack to use fbdev (totally unaccelerated) driver I still consider Ubuntu 12.10 not recommendable and I won't even try this update (not worth the time for me given the best attainable results). At this point I am afraid that the situation will stay like this for a long time, if not for good.

STATUS ubuntu 13.04 onwards: the resolution is correctly set, but it uses unaccelerated drivers. It's good only for basic desktop use and low res video, only at native resolution, not fullscreen. Not recommended.

Installing the drivers

All following commands are meant for a root terminal, as usual they can be executed using sudo instead.

We first have to install the drivers:
apt-get install cedarview-graphics-drivers libva-cedarview-vaapi-driver cedarview-drm
It will take around 10-15 minutes. If it complains about missing packages you have two options:

  1. (recommended) Open Synaptic Package Manager, then Settings/Repositories, in the Update tab check precise-update and close, then Reload.
  2. Add just this drivers' PPA:

apt-add-repository ppa:sarvatt/cedarview
apt-get update

The following step could be Lubuntu specific, but it only takes a minute to check:
cd /etc/lightdm/
If  lightdm.conf and lightdm.conf.cedarview-drm are different, you have to copy the second one over the first one, otherwise you will get a strange "broken pipe" error:
mv lightdm.conf lightdm.conf.old
mv lightdm.conf.cedarview-drm lightdm.conf
IMPORTANT UPDATE: it seems that lightdm support in Lubuntu for this drivers is really bad; I recommend using gdm instead, otherwise anytime you update the kernel or the drivers you are at risk of having that broken pipe issue. To do this you just have to install the "gdm" package and select "gdm" when it gives you the choice.
apt-get install gdm 
dpkg-reconfigure gdm
The next step depends much on which model you use; for the eeepc 1025C there should be no adjustment to make.
If at reboot your computer is stuck in text only mode (it doesn't open the GUI login), open a text shell by pressing CTRL-ALT-F1, login as usual and become root:
nano /etc/default/grub
find the line:
GRUB_CMDLINE_LINUX=""
and try adding between the double quotes:
video=LVDS-1:d
 update grub and reboot:
update-grub2 
If you want  to try different configurations (like different values after LVDS- ) without changing permanently the grub configuration, you can press e at the boot menu and put the options you want near "quiet splash"; then when you have found the right you can change grub configuration.

Important note:
Those drivers are not compatible with PAE kernel, so better double check you don't have one:
sudo apt-get install linux-headers-generic linux-image-generic
sudo apt-get remove linux-headers-generic-pae linux-image-generic-pae
 really get rid of it (source http://askubuntu.com/questions/168986/cedar-view-drivers-arent-working):

find out name of correct operating system kernel (one without pae) dpkg --list | grep linux-image
purge the rest of them using
sudo apt-get purge (paste the names from the above command in one at a time, except for one you don't wish to zap)
sudo update-grub2

At this point you will be able to play 720p videos at around 30% CPU use; that means that you won't have full video acceleration on linux yet (in windows you can do the same with less than 10% CPU), but the system is fully usable and is overall much more responsive because it uses much less RAM. 1080p video will play, but will be quite stressing for the CPU, see next pararagraph to learn how to do far better :-)
I also tried the game Battle for Wesnoth and it works a little faster than the windows version; I didn't try 3D games but I wouldn't expect much from those anyway.
UPDATE: games don't play well...

All hotkeys, WI-FI and suspend work great, the only problem I had is that, when you suspend the computer, AFP shares stop working and you have to reset them on the command line; I think this is more of a PCManFM issue than a graphics drivers one, but maybe there is a workaround.

Install vaapi accelerated mplayer

As I told videos play ok so far, but the full capabilities of the graphic chip are not yet exploited; time to install a mplayer version which will fully use those drivers' power.
apt-add-repository  ppa:sander-vangrieken/vaapi
apt-get update
apt-get install mplayer-vaapi 
It will tell you it conflicts with mplayer2 (it's ok to remove it) and it will install a few dependencies; this is the vaapi enabled version which will use GMA3600 hardware decoding, it may be a little less stable than the no-vaapi version, but I think the performance gain is well worth a few crashes once in while.
Last step: open Gnome Mplayer and go to Edit/Preferences, Mplayer tab (any other mplayer frontend should have a similar tab or a way to configure mplayer) and in the "Extra Options to Mplayer" field add:
-vo vaapi -va vaapi
and close.
Now you have full acceleration: 720p video play with 3-4% CPU use and 1080p are well below 10%!
Enjoy!