Improving battery life time in Linux

Today I received a new battery for my Dell Latitude E6400 laptop. The old battery (a 6 cell one) only lasted for about 15 minutes any more, 1,5 year after I acquired this system. The new battery is a 9 cell version. gnome-power-manager estimates I should be able to run 6 hours now without a charge, which corresponds with what I expected.

Now that I have a new battery, it is time to take a look again at trying to lower power consumption as much as possible. On my system I am using Mandriva 2010.1 Cooker with GNOME 2.30 and laptop-mode-tools 1.54, but this howto should apply (sometimes with slight modifications) to other distributions too.

Continue reading “Improving battery life time in Linux”

Using KVM on Mandriva 2009.0

Introduction

My new Dell Latitude E6400 laptop, is my first system which support hardware visualization. It also has 4 GB RAM, making this an ideal machine to start experimenting with KVM, the kernel based virtual machine system which is now integrated in Linux itself.

In the past I had already used different virtualization systems. VMWare Server is annoying because you have to rebuild the kernel modules by hand each time you install a new kernel and it’s not Free (as in Free Speech). Virtualbox handles the modules rebuild nicely thanks to the use of DKMS in Mandriva, but always randomly crashes on an assert, making it totally unusable for serious work. Also it does not really include a server mode, where virtual machines just run in the background. Xen is especially nice if you have a system which does not support hardware virtualization and you just want to run a paravirtualized Linux in it. However, the host system (Dom0) needs to run a very specific kernel version (normally version 2.6.18, although Debian has a 2.6.26 based one now). OpenVZ is nice for lightweight Linux server containers (some kind of chroot on steroids), but is not a complete virtualization solution.

Because KVM is built into the standard Linux kernel, this means there won’t be any problems with kernel modules which have to be installed separately. It’s a complete virtualization system which means that you can run all kind of operating systems on it, like for example also Windows. KVM is evolving very quickly and its performance and features are constantly improving. Thanks to libvirt and virt-manager, it also has a nice GUI front-end which make configuring and managing virtual machines very easy (libvirt and virt-manager also include support for Xen and OpenVZ, but I don’t know how well that works).

Installing and using KVM on Mandriva 2009.0

Before installing KVM, it’s important to verify that the CPU on your system has hardware virtualization support. Start up a terminal, and run


$ cat /proc/cpuinfo

If you have an Intel CPU, you should have vmx in the flags. If you are using an AMD CPU, you should have svm.

It’s best to use KVM, libvirt and virt-manager from Mandriva’s backports repositories. The versions included there, are the most recent ones, and fix a few problems which made networking not work out of the box with the ones included in the standard repositories. So start up the Mandriva Control Center (Tools – System Tools – Configure Your Computer), and in the Software category, launch the media sources configuration tool and enable the Main Backports and Contrib Backports sources by checking the checkboxes.

Before we install the necessary packages, it’s necessary to make a change to udev’s configuration file to prevent the virbr* and vnet* virtual ethernet devices and bridges being configured automatically by Mandriva’s configuration tools. To do so, edit the file /etc/sysconfig/udev_net and add virbr* and vnet* to the BLACKLIST_ALL line if they are not there yet. The line should look like this:

BLACKLIST_ALL="ppp*|ippp*|isdn*|plip*|hso*|lo*|irda*|dummy*|ipsec*|vmnet*|wifi*|
wmaster*|br*|vbd*|vtpm*|vif*|ax*|nr*|rose*|bce*|scc*|virbr*|vnet*"

Then install the kvm and virt-manager packages with the graphical software installation utility or with urpmi. Some extra dependencies will be installed, such as dnsmasq-base, libvirt-utils and python-virtinst.

After the installation, make sure that the libvirtd service is running. You can use the graphical tool in the Mandriva Control Center in the category System – Manager system services, or you can run “service libvirtd status” to verify whether it’s running and “service libvirtd start” to start it.

Now start the Virtual Machine Manager from Tools – Emulators. Choose File – Add Connection and set up a Local QEMU connection. Double click on the localhost/qemu connection in the virtual machine manager, and enter your root password. You can now create new virtual machines by clicking on the New button. To use KVM, choose a fully virtualized system, and choose KVM as hypervisor. If you want to run Mandriva 2009.0 or later in a KVM based virtual machine, you can probably choose Linux as OS type and Ubuntu Hardy as OS variant, because that should give better performance than the generic options.

I currently have Windows Vista and Debian Lenny running in KVM. It works very fast and very reliably. The only problem I encounter, is that sometimes I cannot switch back from my Windows virtual machine to my host system: the mouse and keyboard cannot leave the VNC window anymore and also the Ctrl-Alt keystroke does not release the mouse pointer. The only solution is to shut down the Windows system.

Mandriva Linux 2009.0 on a Dell Latitude E6400

Introduction

A few weeks ago the hard drive in my Apple Powerbook G4 which I was using at work, had died. As this machine was already a few years old, it was already planned to be replaced soon. The hard drive crash only accelerated things a bit.

I wanted a not too heavy laptop with 14″ screen and a high resolution (1440×900) screen and an Intel CPU of the latest generation (style Core 2 Duo P8400/P8600/T9400). Lenovo’s Thinkpad T400 with such a high resolution screen seemed to be difficult (impossible?) to find here in Belgium currently and generally Thinkpads are rather costly here. HP’s Elitebook 6930p did not seem to be shipping in Belgium yet. So in the end, I chose a Dell Latitude E6400. Also a big advantage of Dell, is that I could easily choose in detail which features I preferred, while you are limited to standard models with most other brands.

Specifications

So here are the specifications of the Dell E6400 machine I have now:

  • Intel Core 2 Duo P8400 (2,26 Ghz, 3MB cache)
  • 4 GB RAM
  • Intel G45 chipset graphics card
  • DVD+/-RW
  • 160 GB hard drive
  • Intel based 1Gbps Ethernet
  • Intel WiFI 5300 wireless card
  • Bluetooth
  • SD card reader
  • SmartCard reader
  • Firewire, eSATA, USB, VGA, DisplayPort outputs
  • Dell Simple E-Port docking station

Mandriva Linux 2009.0 on Dell Latitude E6400

On my Powerbook I used Debian Testing (Lenny), because it supports the PowerPC architecture very well and is very stable. I was very pleased with this distribution. Even as a desktop OS, I personally liked it much better than Ubuntu. On this new machine, I decided to install Mandriva because it permits me to follow Cooker if I want and also permits me to create and use custom packages more easily (I’m not too experienced in creating DEB packages).

Installation

I did a network installation of Mandriva 2009.0 x86_64 edition, which I started with a CD burnt from the boot.iso file which can be found on every Mandriva mirror in the install/images directory. I had some trouble in finding a reliable mirror at first, but once I found one, the installation itself went fine. If you are installing from a CD or DVD set, be sure to install all available updates at the end of the installation. By the time you are reading this, this might solve some of the problems I encountered with the just released Mandriva 2009.0 and which I will discuss here.

X lock ups

Once the installation had finished, I booted Mandriva for the first time. Unfortunately, every time as soon as the X server started up, the machine completely locked up though. In the end, this turned out to be a problem with the Intel X driver. A fixed version is currently available in the main/testing repository. If you are suffering from this problem, in the boot loader press F2 with the Mandriva line selected, and then add 3 at the end of the kernel line, in order to start the linux system in console mode. Log in as root, and run

# urpmi http://ftp.free.fr/mirrors/ftp.mandriva.com/MandrivaLinux/official/2009.0/x86_64/media/main/testing/x11-driver-video-intel-2.4.2-7mdv2009.0.x86_64.rpm

to install the fixed driver from testing. Then run

# init 5

to go to init lever 5 (graphical mode).

Speaker noise

Another problem was that as soon as the sound drivers were loaded, a loud noise came out of the speakers. To fix this, open the volume control in LInux, and deactivate the Analog Loopback 1 and 2 switches (in GNOME, you will need to click on the Preferences button first, and check the checkboxes next to Analog Loopback 1 and 2 to show these switches). I also completely muted PC Beep because even on the lowest level, the console beep was still extremely loud.

Kernel choice

Because my laptop has 4GB of RAM, the installer decided to install kernel-server instead of kernel-desktop. However this is not needed if you installed Mandriva’s x86_64 edition. To check whether you are suffering from this problem, run

$ uname -a


If it installed the server kernel, you can install the desktop kernel by running

# urpmi kernel-desktop-latest


The desktop kernel will give you better performance and battery lifetime than the server kernel. Another alternative is kernel-tmb-desktop-latest, which I had also good experiences with.

If you installed Mandriva’s i586 edition, you will need the server kernel to support 4GB of RAM. That’s why you really should try to install the x86_64 edition if you have that much RAM.

Intel VT

Because I want to make use of the Intel VT (virtualisation features in Intel CPUs), I went in the BIOS (press F2 when the Dell logo appears when starting up the machine) and enabled these features. After that, Linux became extremely unstable. Kernel oopses happened during start up, in some cases completely locking up the OS when booting. I could fix this by adding intel_iommu=off to the kernel command line. At the boot loader, again select the Mandriva 2009.0 line and press F2 and add this option. To make this permanently, start up the Mandriva Control Center (“Configure your computer” in the program menu Tools – System Tools), go to the Boot category and choose “Set up boot system”. Click on the next button, and then for all Linux kernel, click on Modify and add intel_iommu=off to the Append field.

Wireless and Bluetooth

After the installation, be sure to also start up the drakroam wireless utility, in order to make it install all needed tools to use the wireless networking card because the installer did not install these by default. To use the wireless network card, don’t forget to enable the wireless functionality with the wireless kill switch at the right side of the laptop. I have the impression that it’s best to make sure this is enabled at boot, otherwise the wireless does not always seem to work when enabling later on.

In order to use the Bluetooth, I had to install the gnome-bluetooth package myself. For KDE, you will need to install kdebluetooth4. The pin can be set in the text file /etc/bluetooth/pin.

Other things

Currently I have not yet tried the SmartCard and SD card readers and I did not succeed yet in setting up a dual screen configuration with a flat panel connected to the VGA output on the docking station. For some reason, xrandr only permits me to use a 640×480 resolution on the external monitor, possibly because it seems to ignore the Virtual lines I added to my xorg.conf. I’ll need to investigate this a bit more to find out what is really going wrong here. Suspending the machine also seems problematic: when I tried this, the machine locked up completely when it resumed.

I did not buy this laptop with the integrated webcam, however according to what I read on the Internet, it should also work out of the box with Linux kernerl 2.6.27, which is used by Mandriva 2009.0.

Conclusion

All in all, I’m pretty satisfied with this laptop. The specifications are nice and the price we got from Dell was nice (much cheaper than the standard prices on the Dell website). The biggest disadvantage of this laptop is that parts of the casing seem to be made of cheap plastic. It does not feel as sturdy as a Thinkpad or HP laptop. Time will tell whether that’s a real problem. The most important things can be get working with Mandriva 2009.0 without too much problems and I guess I will find solutions too for the remaining bits in the near future.

Links