Archive for June, 2007

Gentoo Linux on the MSI S270

Saturday, June 2nd, 2007

I got myself the 12,1″ notebook S270 from MSI. As Linux is the best choice to me, I’ve chosen to equip this black beauty with a Gentoo installation. These pages explains how to basically install the system. In addition I’ve collected some experiences and hints for the configuration.

Hardware details

AMD Turion 64 MT-30
Lancaster | Sockel 754 | 1.600 MHz | 800 MHz HyperTransport (HT800) | 64 + 64 KB L1 | 1.024 KB L2 | MMX, Extended 3DNow!, SSE, SSE2, SSE3, AMD64, PowerNow!, NX-Bit | 22 W TDP
512 MB RAM
SO-DIMM | DDR333 | PC2700
ATI Radeon Xpress 200M + Mobility Radeon X300 IGP
OHCI USB 1.1 | EHCI USB 2.0 | DDR400 | PCI Express x16 | UltraDMA/133 2 vertex units | 4 pixel pipelines | 350 MHz GPU clock | 0,13µm Low-K | PCI-Express | 64-Bit memory interface | PowerPlay 5.0 | SmoothVision 2.1 | SmartShader 2.0
Toshiba MK8025GAS
80 GB | UltraDMA/100 | 8.192 KB cache | 4.200 rpm
Realtek RTL8139 Fast Ethernet Adapter
InProComm IPN 2220 Wireless LAN Adapter
IEEE 802.11b/g
Ricoh R5C522 OHCI IEEE 1394 Controller
Ricoh RL5c476 II CardBus Bridge
SD/MMC
SiW Bluetooth Adapter

Partitioning and file systems

Partitioning

As usual on Linux, we need a swap and the root file system. We don’t need boot partitions anymore as boot loaders have advanced quite a bit. First of all, I’m setting up an extended partition with 60 GB, so that I can install a further operating system later on. I’m creating the two partitions as logical partitions inside the extended one. The swap should be about 30% greater than the system’s memory to be able to use Suspend2. Disk space is plentiful, so 1 GB swap should be enough. The rest is used for root.

File systems

For the root file system I’m using the powerful ReiserFS. See here for a survey of several file systems.

fstab

The configuration above results in the following /etc/fstab:

/dev/hda6    /           reiserfs    noatime,notail         0 1
/dev/hda5    none        swap        sw                     0 0
proc         /proc       proc        nodiratime             0 0
shm          /dev/shm    tmpfs       nodev,nosuid,noexec    0 0

Basic system setup

32-bit vs. 64-bit

If you don’t exceed the address space of 4 GB and don’t have use for the more precise arithmetic, then 64-bit computing will not provide any impovement. I’m setting up a 32-bit system to avoid the memory oberhead produced by a 64-bit one (many objects stored in memory are 64 bits wide). Memory is a precious resource, especially in case of a notebook.

make.conf

In 32-bit legacy mode, the Turion 64 acts just like an Athlon XP with SSE3, so the /etc/make.conf looks like this:

CFLAGS="-march=k8 -O2 -pipe -msse3 -fomit-frame-pointer"
CHOST="i686-pc-linux-gnu"
CXXFLAGS="${CFLAGS}
MAKEOPTS="-j2"
ACCEPT_KEYWORDS="~x86"
USE="..."
LINGUAS="de"

X11

Sadly, the X.org open source driver for Radeon GPUs does not support the PowerPlay feature and is unable to make use of the DRI in case of the X300. So I’m using ATIs proprietary driver.

Setting the VIDEO_CARDS variable

Your /etc/make.conf file must contain the following to prepare the X.org server for the fglrx driver:

VIDEO_CARDS="radeon fglrx vesa"

Kernel configuration

The kernel must be able to load modules and support MTRRs. The AGPgart driver must be compiled as a module and the DRM should be deactivated. PCI-Express is needed, too:

Loadable Module Support --->
  [*] Enable loadable module support
    [*] Module unloading

Processor type and features ---><br/>
  [*] MTRR (Memory Type Range Register) support

Bus options (PCI, PCMCIA, EISA, MCA, ISA) --->
  --- PCI support
    [*] PCI Express support

Device Drivers --->
  Character Devices --->

    [M] /dev/agpgart (AGP Support)
      [M] ATI Chipset
    [ ] Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)

Proprietary ATI driver

The driver itself and some extra tools must be installed:

$ emerge ati-drivers ati-drivers-extra

The tool can be used to display all options…

$ /opt/ati/bin/aticonfig --help | less

…and then write a new configuration

$ /opt/ati/bin/aticonfig --initial --input=/etc/X11/xorg.conf

Of course, the driver has to be selected in your /etc/X11/xorg.conf, for details see Downloads.

Wireless LAN

Wireless tools and DHCP client

First of all, the tools necessary for establishing any wireless connection and a DHCP client must be installed:

$ emerge wireless-tools dhcpcd

W-LAN driver

The kernel does not provide a driver for the integrated InProComm IPN2220, so I’m using the NDISWrapper. Bodo only describes the 64-bit installation and the 32-bit driver that comes with the notebook is incompatible with the NDISWrapper. I’ve found out that many Acer notebooks use the IPN2220 and so their W-LAN driver works fine.

$ emerge ndiswrapper
$ ndiswrapper -i neti2220.inf
$ ndiswrapper -l

lists all installed drivers. To activate the NDISWrapper, the according module has to be loaded with

$ modprobe ndiswrapper

To do so automatically, you can add the module to /etc/modules.autoload.d/kernel-2.6.

The S270 may also come with a RaLink RT2500 wireless chipset. If you have such a device, you can skip the installation of NDISWrapper and do

$ emerge rt2500

This driver creates the device node ra0 instead of wlan0.

Establish a connection

$ iwconfig

displays the configuration of the wireless interfaces,

$ iwlist wlan0 scan

scans for access points,

$ iwconfig wlan0 essid "ESSID"

connects to access point ESSID and

$ dhcpcd wlan0

fetches the network information from the DHCP server.

Automating things

You may then set up a runlevel script for the interface and activate it on boot:

$ cd /etc/init.d
$ ln -s net.lo0 net.wlan0
$ rc-update add net.wlan0 default

You propably have to change /etc/conf.d/wireless. See here for details.

4k kernel stack

The NDISWrapper forms a thin layer around the Windows driver and therefore needs a kernel stack of 8k minimum. Accordingly, the kernel must not be compiled with the 4k stack feature activated – unless you can do without the W-LAN adapter.

Power management

CPU

The processor features the PowerNow! technology (and Cool’n'Quiet respectively), meaning that core voltage and clock can be throttled. Therefor, the right kernel driver has to be selected and control be given to a userspace application:

Power management options (ACPI, APM) --->
  [*] CPU Frequency scaling --->
    Default CPUFreq governor (userspace) --->

    <*> 'performance' governor
    <*> 'powersave' governor
    --- 'userspace' governor for userspace frequency scaling
    <*> 'ondemand' cpufreq policy governor
    <*> 'conservative' cpufreq governor
    --- CPUFreq processor drivers
    <*> AMD Opteron/Athlon64 PowerNow!

Now, we need a daemon handling the frequency scaling for us:

$ emerge cpufreqd
$ rc-update add cpufreqd default

W-LAN

The W-LAN adapter may also be put into an energy-saving mode. You can add the command to /etc/conf.d/local.start:

$ iwconfig wlan0 power on power max period 3

This instructs the adapter to sleep after 3 seconds of inactivity.

Save even more energy

There may be a lot more possibilities to save power, but I think that most of them are too complicated or just in vain.

Hardware sensors

At the moment, the CPU temperature (per ACPI Thermal Zone) and the hard disk temperature (per S.M.A.R.T.) can be monitored. To access the Thermal Zone, a special kernel driver is needed:

Power management options (ACPI, APM) --->

  ACPI (Advanced Configuration and Power Interface) Support  --->
    [*] ACPI Support
      <*> Processor
        <*> Thermal Zone

After that, you can read the temperature in /proc/acpi/thermal_zone/THRM/temperature or let an applet do this for you (e.g. the sensors-applet). A small tool called hddtemp can be used to obtain the hard disk’s temperature:

$ emerge hddtemp
$ hddtemp /dev/hda
/dev/hda: TOSHIBA MK8025GAS: 47°C

Suspend-to-Disk

Hibernating works fine with the Suspend2 patch (which is now called TuxOnIce). Here you find more detailed information in on that. I’ve just concluded the essential steps here.

Setup

There are Kernel sources already patched. Besides the patch, they are equal to the official Gentoo sources.

$ emerge suspend2-sources

To avoid problems, the USB driver and the NDISWrapper module should be unloaded before hibernating. The hibernate script may assume that (/etc/hibernate/common.conf):

UnloadModules ndiswrapper ohci_hcd ehci_hcd

In addition, the proprietary ATI driver needs more pages – 7,500 will suffice:

ProcSetting extra_pages_allowance 7500

The kernel has to know where the memory image resides and where to store it, so you have to pass resume2=swap:/dev/hdaX at boot (see GRUB configuration in Downloads).

Hard disk performance

The hard disk performance may be increased by tweaking some parameters with hdparm. To make these settings permanent, you can store them in /etc/conf.d/hdparm and add hdparm to your boot runlevel with

$ rc-update add hdparm boot
hda_args="-W0 -u1 -c1 -d1 -K1 -A1 -m16"
-W0 disables write-caching as recommended for journaling filesystems
-u1 permits the driver to unmask other interrupts during processing of a disk interrupt
-c1 enables 32-bit IDE I/O support
-d1 enables DMA
-K1 enables the driver to retain -APSWXZ parameters over a soft reset
-A1 enables read-lookahead
-m16 sets sector count to 16 for multiple sector I/O (IDE Block Mode)
The S270 may also come with a WD Scorpio hard disk. It seems that this drive doesn’t understand the -K switch.

Prelinking

Though prelinking is nothing specific to this notebook, I just want to mention it here as it may really speed up the system. When you run an application, shared libraries need to be loaded and references resolved. Prelink carries out this dynamic linking and stores the results in the executable. See the here for details.

MMC/SD card reader

Since Kernel 2.6.17, there should be a driver for the Ricoh RL5C476 II CardBus controller. Just issue

$ pmount /dev/mmcblk0p1 mmc

after you’ve inserted the SD card to mount it to /media/mmc. The device name may vary, just take it from the output of

$ cat /proc/partitions

Further Reading