Sunday 23 January 2011

Preparing lightweight operating system

Every time when I build a new operating system I am not sure if I don't forget about something so I decided to prepare list of steps necessary to build lightweight system.
Let's start:
  1. At first we need to choose a file system which will be used on our root partition. It is important to adjust fs (file system) according to type of files which will be stored. For example gnu/linux OS consists of many little files, so in this case we should choose eg. ext3 instead of xfs beacause seccond one work's better with large size files like movies. Below I put short list of different file systems and their destination.

    • EXT - small files (good choice for root file system)
    • JFS - small and bigger files (in my opinion better than ext3)
    • XFS - large size files
    • ReiserFS 4 - good compression of data, but unstable (more possible data loss than other FS)

  2. Next step is installing an operating system, personally I prefer do it manually so I control every part of my system not like "out of the box" distributions which install many unnecessary applications.
  3. When your basic system is ready now it is time to install tools running in the background but significantly improve comfort of usage of a laptop.

    • Laptop-Mode-Tools - power consumption manager
    • Pdnsd - lightweight DNS server which can remember IP address of domain names (even after reboot) and increases browsing speed
    • Cpufreq - CPU frequency manager
    • acpid - daemon delivering ACPI events (without it you can't manage devices so eg. cpufreqd won't work)
    • xbacklight - program adjusts brightness of a screen
    • hdparm or sdparm - hard disc drive managers

  4. Finally we are ready to create environment which we use to our daily work. Common thing is X window system (I suppose everyone today use graphical interface, if not then skip to 6th point). If you do it manually, you can choose suitable packages (many "out of the box" distributions install everything including drivers for all types graphic cards).
  5. Now it is time for window managing application. There can be distinguished window managers (WM) and graphical desktop environments (GDE), the difference between them is that first one is part of second one and GDE except WM contains also many additional apps like desktop, background, bars, clock etc. This is quite logic that WM is more lightweight than GDE. I suggest apply window manager and install additional widgets if necessary. Below I compose list of WM and GDE and short opinion about them.

    Desktop Environments:
    • KDE - unstable and heavy
    • Gnome - more lightweight than KDE but difficult to use
    • LXDE - quite lightweight
    • Xfce - based on the same library as Gnome but easier to use

    Window Managers:
    • OpenBox - very lightweight but it takes some time to accustom
    • Fluxbox - little heavier than Openbox but nice to use
    • Compiz - 3D graphic window manager, I suppose it is havy

    If you want more, look at these links:

  6. At the end, installation of applications necessary to work. I can't write here about each app or apps to each purpose because there are too many of them but I can recommend this page (people from Arch made a great job) where you should find some valuable informations.

Friday 27 November 2009

Laptop Mode Tools - program which you have to have

There are many laptop power saving managers, I tested a lot of them but only one meet my expectations, which isn't so strict. This manager or rather set of a tools is of course Laptop Mode Tools, its posibilities are incredible, it takes care whole your hardware and software, you need to only fit configuration to your requirements. All configuration files are located in path:
/etc/laptop-mode
Directory contains following files/directories:
  • laptop-mode.conf  - main, most important configuration file
  • lm-profiler.conf - configuration file of lm-profiler tool, lm-profiler detects processes that use system resources and that cause activity of hard disc drive and help disable them
  • batt-start, batt-stop - directories containing scripts which will be executed depend on battery mode is starts or stops
  • lm-ac-start, lm-ac-stop - directories containing scripts which will be executed in case AC mode starts or stops and laptop-mode management is active during working on AC
  • nolm-ac-start, nolm-ac-stop - ame as above, but in case laptop-mode management is inactive during working on AC
  • conf.d - directory containing additional configuration files targeted to special parts of system like ethernet card, lcd brightness, auto hibernate, kernel schedulers etc.
All configuration files are very well commented, of course remember to add/enable init script of laptop-mode to a runlevel.

Advantages of Laptop Mode Tools:
  • automaticaty detection AC or battery power source
  • decreased hdd's usage (data read ahead and buffering data designed to write on a hdd)
  • data loss protection
  • you decide about each option, nothing is imposed on you
  • default configuration is effective
  • laptop-mode-tools manage everything, so you need no more programs
Disadvantages of Laptop Mode Tools:
  • CPU frequency management, this is only function having better substitution. I recomend Cpufreqd which is more flexible
http://samwel.tk/laptop_mode/   -  Link to Laptop Mode Tools project

Friday 13 November 2009

rmmod or modprobe?

Usually when we use our laptop, we needn't all resources working (for example we connect to Internet or local net via WIFI card or Ethernet card or modem but not all of them together), nevertheless operating system sets them ready to work. That means there are spend power necessary to run device even it isn't used, obviously nowadays most of hardware supports power save modes reducing power consumption, but there is no reason to turn on something which won't be used. Important requirements to manipulate hardware are:
  • drivers should be compiled as kernel modules
  • enabled option of loading and unloading modules 
If you use default kernel everything is done, but if you compile kernel with your own configuration, remember about above requirements.

OK, let's profit extra minutes working on battery.

To turn off the device we use following command (as root user):
rmmod < name of module >

Of course if we want running device back, command loading module is:
modprobe < name of module >

What we may turn off:
  • Wireless card
  • Ethernet card
  • Modem
  • USB device
  • Sound card and speakers
  • Web camera
  • Optical disc drive (like DVD-R/RW, CD-R/RW etc.)
  • many other
Research:
Hardware:       Wireless card Realtek RTL8187B
Mean Value:    WIFI on = 16.0396      WIFI off = 14.1703

As you see I profit almost 2 Watts when I am unload WIFI driver. I want to mention that wireless card wasn't connected.

How unloading kernel's modules affect power consumption

Saturday 26 September 2009

How color of screen affects power consumption

Probably everybody who has laptop knows that decreasing backlight reduces power consumption, but this is not only way to manipulate screen power.
There was a time when I interested in construction of LCD monitors and how they work, then I realized that power consumption depends on color and its hue. How is this possible, I will tell you. The most rear layer (called backlight) emit white light which passes through polarizer next glass layer next liquid crystal next second glass layer and finally second polarizer oriented perpendicular to the first one. Now we will focus on liquid crystal which is surrounded on two sides by electrodes. Unless we applied voltage on the electrodes, molecules of liquid crystal lay the perpendicular to the light (polarized before) and light will be rotated through an angle of 90 degrees, therefore it can passes through next polarizer. If we applied voltage on the electrodes, light isn't rotate (molecules lay the parallel to the light) and can't passes through second polarizer so pixel will be black. Summarizing, brighter colors uses less power or colors with higher value per each RGB bit uses less power.

Diagram of LCD monitor
diagram of LCD monitor
Research:
Hardware: 15.4'' TFT WXGA Toshiba TruBrite

Research for screen filled with colors white and black.
how color of screen affects power consumption

Thursday 13 August 2009

Frequency

CPU is just after the screen most power consuming part of laptop. The higher frequency the greater power consumption, each cycle uses a given amount of power, even there is nothing to do. Usually when you working on laptop you needn't full speed of processor, so why not decrease it? Each laptop's CPU supports technology called frequency scaling. Available frequencies depend on the model. You may check it by entering in terminal as root below commands.
Commands:
available frequencies
     cat /sys/devices/system/cpu/cpuN/cpufreq/scaling_available_frequencies

current frequency
     cat /sys/devices/system/cpu/cpuN/cpufreq/scaling_cur_freq

set frequency to X (only when 'userspace' governor is enabled)
     echo X > /sys/devices/system/cpu/cpuN/cpufreq/scaling_setspeed

 

 *where cpuN is processor/core number counted from 0.

Next thing are scaling governors which sets frequency depending on CPU usage.

Here is list of scaling governors:

  • Performance sets the speed to maximum, essentially disabling frequency scaling. 
  • Powersave drops CPU to its lowest supported frequency.
  • Userspace allows the CPU speed to be set manually or dynamically by software. 
  • Ondemand runs at the lowest possible frequency and increases to maximum when CPU usage hits 100%.
  • Conservative runs at the lowest possible frequency and increases incrementally as more power becomes necessary.
Commands:
available scaling governors
     cat /sys/devices/system/cpu/cpuN/scaling_available_governors

current scaling governor
     cat /sys/devices/system/cpu/cpuN/scaling_governor

set scaling governor
     echo 'governor' > /sys/devices/system/cpu/cpuN/scaling_governor

 

 *where cpuN is processor/core number counted from 0.

Attention

If above functions doesn't work, probably:
  • you haven't installed acpi or acpid or both packets
  • acpi-cpufreq module isn't loaded 
  • you haven't compiled this features into kernel
  • your processor doesn't support frequency scaling
Research:

Hardware: Intel Pentium Dual-Core Processor T2390 1,86 GHz

Available frequencies: 1867 1600 1333 1067 800 MHz


How CPU frequency affect power consumption

Monday 27 July 2009

Linux on Toshiba Satellite L300-129

Last updated: 31 July 2009

General Hardware Specifications of Toshiba Satellite L300-129

Hardware ComponentsStatus under Linux / Notes
Processor: Intel Pentium dual-core T2390 1.86 GHzWorking
System memory: 2048 MB DDR2 RAM (667 MHz)Working
Hard disk: 160 GB S.M.A.R.T. (5,400 rpm)Working
DVD/CD drive:DVD Super Multi driveWorking
Display: 15.4" TruBrite WXGA TFT High BrightnessWorking
Graphics adapter: Intel GMA X3100 358 MBX11 7.4 and higher
Expansion: Express Card slotNot checked
Wireless card: Realtek 8187B (0bda:8198) 802.11b/gkernel 2.6.29 and higher
Ethernet card: Fast Ethernet LAN 10BASE-T/100BASE-TXWorking
Modem: V.92 modem 56 Kbps data, 14.4 Kbps faxNot checked
Sound system: 24-bit stereoWorking
Pointing device: Touch PadWorking
Battery: Lithium-IonWorking
Web camera: 0.3 MPx VGA with built-in microphoneWorking
USB port3 x USB 2.0Working (since kernel 2.6.30 visible works on autosuspend)
Other ports:

- external monitor port

- external microphone

- headphone (stereo)

Working

lspci returns:

00:00.0 Host bridge: Intel Corporation Mobile PM965/GM965/GL960 Memory Controller Hub
00:02.0 VGA compatible controller: Intel Corporation Mobile GM965/GL960 Integrated Graphics Controller
00:02.1 Display controller: Intel Corporation Mobile GM965/GL960 Integrated Graphics Controller
00:1a.0 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #4
00:1a.1 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #5
00:1a.7 USB Controller: Intel Corporation 82801H (ICH8 Family) USB2 EHCI Controller #2
00:1b.0 Audio device: Intel Corporation 82801H (ICH8 Family) HD Audio Controller
00:1c.0 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 1
00:1c.4 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 5
00:1d.0 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #1
00:1d.1 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #2
00:1d.2 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #3
00:1d.7 USB Controller: Intel Corporation 82801H (ICH8 Family) USB2 EHCI Controller #1
00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge
00:1f.0 ISA bridge: Intel Corporation 82801HEM (ICH8M) LPC Interface Controller
00:1f.1 IDE interface: Intel Corporation 82801HBM/HEM (ICH8M/ICH8M-E) IDE Controller
00:1f.2 SATA controller: Intel Corporation 82801HBM/HEM (ICH8M/ICH8M-E) SATA AHCI Controller
00:1f.3 SMBus: Intel Corporation 82801H (ICH8 Family) SMBus Controller
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8101E/RTL8102E PCI Express Fast Ethernet controller

In conclusion, Toshiba L300-129 hardware is supported by kernel especially 2.6.29 and higher version. I recommend update kernel to the newest one by virtue of intel's hardware, they do much work improving kernel's support, so you often observe that your laptop works better.

Checked GNU/Linux distributions:

  • openSUSE 11.1

Installation, configuration and using are indeed easy. During installation you need only check some basic options like language, desktop environment etc. and next wait until the end of installation. If I am not wrong, version 11.1 has 2.6.27 kernel, so you need update it to 2.6.29 cause drivers in earlier releases not support wireless properly. If everything was done correct you may start using this system.

  • Gentoo

Installation is a bit more difficult than openSUSE, but beside this discomfort you get powerful abilities. To do that you have to follow instructions contained in this manual, but personally I suggest read alternative installation method before, especially point five "Installing Gentoo from an existing Linux distribution".

REMEMBER!!! Use only the newest releases of stage and portage.

When you will have ready basic system, you may start install your favorite packages.

REMEMBER!!! Use primarily stable ebuilds, otherwise your life change into nightmare.

Of course sometimes unstable package may be better as in the case of x11-xorg, so if you have x11-xorg-7.2 installed or it doesn't work properly then update driver for Intel cards (xf86-video-intel) to unstable version (add ~ in ACCEPT_KEYWORDS variable in make.conf file).

Soon I write post dedicated to Gentoo's configuration on Toshiba Satellite L300-129 laptop with every details like kernel and X configuration. Please be patient.


If you have any questions, my email is: kamilzmija@gmail.com 

Wednesday 22 July 2009

Dictionary

  • read-ahead - it is a system that loads data with excess into the RAM, so next time when data is loaded from the following area it is readed from RAM not disc, which is much faster.
  • noatime - mounting option which doesn't update access timestamp when a file is readed
  • DNS - (Domain Name Server) server translating domain names to IP address eg. powerlinxlap.blogspot.com is translated to 66.102.13.132, this operation takes some time