HOWTO extend the life of Gentoo laptop

Gentoo August 5th, 2007

*cough*, I may not qualify this discussion considering my bad record (1, 2), and I just replace the hard disk for the consequent I/O failure today. Anyway, the readers may learn some lesson from my good/bad practice and avoid the same pitfall.

Gentoo enjoys the reputation for its source-based distribution and highly-customizable package management, portage. However, we pay the price for the flexibility: synchronizing the portage, building applications from source code. Both of the two tasks are I/O extensive, and the latter is also computation-extensive. The following tips aim to offload the burden to the desktop workhorses and eliminate the unnecessary I/O operation as much as possible.

Choose the right file system

I am a big fan of JFS regarding its comparable performance with low CPU consumption. Unfortunately, JFS does not support bad block relocation. This is essential since we may still use the hard disk with some dysfunctional sectors, though not suggested. So I decide to take reiserfs as the default FS with LVM.
Pro: I could tell the difference of booting time.
Con: when emerging the package, especially boost, the whole system just lost the responsiveness due to the high I/O traffic.
It is really a tough decision. I may go back to JFS if this hard disk is dead, *touch wood*.

Using tmpfs

Check this tip in Gentoo Wiki. The temerge works as a charm. It builds the application in memory instead of hard disk, the emerge time is shortened dramatically and the hard disk access is decreased.

Share the portage over network

Another I/O extensive operation is emerge –sync. According to this HOWTO, a shared portage not only save the hard disk access, but network bandwidth of the sync servers as well. The file server used in my home network, hippo servers the multimedia files using Samba for one Dell 700m laptop tiger and one Dell Dimension E521 desktop gorilla. Follow this HOWTO to get Samba works, and we may adapt the changes mentioned in this HOWTO to the system:
Add the emerge –sync task to the cron: /etc/cron.daily/emerge.cron

#!/bin/sh
emerge –sync > /dev/null 2>&1

Export the portage to the public: /etc/samba/smb.conf

[portage]
comment = public portage
path = /usr/portage
public = no
writable = yes
browseable = yes
valid users = share admin

Auto mount the portage in tiger: /etc/fstab

//hippo/portage /usr/portage cifs user=share,password=foo,iocharset=utf8

If the laptop is roaming, local /usr/portage would be used. The distfiles and packages are left in the local disk just in case we may need them without network: /etc/make.conf

FEATURES=”sandbox ccache -distlocks autoaddcvs confcache”
PORTDIR=/usr/portage
DISTDIR=/usr/local/portage/distfiles
PKGDIR=/usr/local/portage/packages
PORTDIR_OVERLAY=”/usr/local/portage/myportage”
source /usr/local/portage/layman/make.conf

For eix users: /etc/eixrc

PORTDIR_CACHE_METHOD=’none’

and put the update-eix into cron.daily

For layman users: /etc/layman/layman.cfg

storage : /usr/local/portage/layman

Offload the build to desktop workhorse

TO BE CONTINUED…

Dilema of Kernel upgrade

Gentoo July 28th, 2007

I enjoy upgrading kernels in my Dell 700m laptop, the new kernel usually brings more functionalities and fixes bugs. In the recent upgrade to suspsend2-source-2.6.22, I found Fn + F7 VGA output does work any longer, which worked so perfect in suspend2-sources-2.6.18-r6 that I even regarded it as a built-in feature of BIOS. Right now, I need to explicitly call i855crt to output either shaking rawpipe or 8-bit color palette images to external monitor, both suck.

Maybe it required some other bleeding-edge components. I upgraded the x11-drm and xf86-video-i810 to the unstable ~x86 branch in the portage. Things got even worse. xf86-video-i810-2.0.0 could mirror screen to the external monitor if it was attached in X server launch, that suffice the need of presentation, however, there were two screen 1152×768 and 1280×800 sharing the same desktop in the sole head, that totally confused KDE, and windows’ behavior s were quite weired.

So I went back to xf86-video-i810-1.7.4 for the daily working environment, and reboot the machine to kernel 2.6.18-r6 for the presentation, — that is ridiculous but I could not stick to 2.6.18 kernel since the source tree is deleted, and also removed from the portage. What I have in the hand is the monolithic kernel only.

For the troubleshooting, I compared the .config of 2.6.18 and 2.6.22 head by head, and still could not figure it out what I did wrong. If you manage to make the VGA output work in 2.6.22 kernel, or point out the mistake I have made, please drop a comment here. Thanks.

Small fix for libnjb to transfer Chinese tags

Desktop, Gentoo July 17th, 2007

I once mentioned that some Chinese characters are missing in Creative ZenMirco when using Amarok + libnjb. I checked the libnjb-2.4.4 source code and found that the text codec conversion from UTF-8/ISO8859-1 to UCS2 big-endian is home-brew instead of the standard libiconv, maybe the libiconv is overkill since only three codecs are really needed. According to the specification of UTF-8

U-00000000 – U-0000007F: 0xxxxxxx
U-00000080 – U-000007FF: 110xxxxx 10xxxxxx
U-00000800 – U-0000FFFF: 1110xxxx 10xxxxxx 10xxxxxx
U-00010000 – U-001FFFFF: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
U-00200000 – U-03FFFFFF: 111110xx 10xxxxxx 10xxxxxx 10xxxxxx
10xxxxxx
U-04000000 – U-7FFFFFFF: 1111110x 10xxxxxx 10xxxxxx 10xxxxxx
10xxxxxx 10xxxxxx

while the libnjb developers made a small mistake, so all 0×80xx characters are categorized as abnormal.

if (numbytes == 2 && str[i+1] > 0×80) {
                        … …
                } else if (numbytes == 3 && str[i+1] > 0×80 && str[i+2] > 0×80) {
                        … …
                } else {
                  /* Abnormal string character, just skip */

Here is a patch against libnjb-2.2.4, you may adapt it to libnjb-2.2.5 as well. For Gentoo users’ convenience, here is the ebuild.

I am just curious why this bug has been here for such a long time. How many Chinese Linux/BSD users take UTF-8 as the locale, transfer music to Creative ZenMicro? Are these three factors are really small that make this almost never gonna happen?

HOWTO Gentoo 2007.0 on Dell 700m

Gentoo July 14th, 2007

During the last disaster, I lost the root partition, while the good news is the irresponsible mkstage4.sh backup the /etc that saves a huge amount of time for me to emerge world.

This post would summarize the efforts for my record and for your convenience. This HOWTO is originally posted in the official forum three years ago, and I once tried to update it in my previous post as well. Since then, some devices get supported, some software packages are obsolete, Life runs fast. Read the rest of this entry »

Where is the time machine?

Gentoo July 11th, 2007

After several times unsuccessful hibernation, the JFS file system is screwed up by the forceful shutdown. There are some directories with weired access control in the portage, that cause the fsck.jfs exit abnormally. Eventually, I decided to clean up this morning using the ultimate way: format.

I did a full stage4 backup first, and then format the disk and tried to recover from the stage4 tar ball. Oops, here is an fatal error. It looks like the backup met some errors then exited with a success message. That is really not funny.

Anyway, I had a backup one week ago, it is old since I update the system everyday, yes, that is the typical Gentoo users’ behavior. But wait, I just got the second half of the split stage4 tar ball, where is the first half?

Where is the time machine?