Sunday, November 30, 2008

pimp my x40

After a brief look at the market, I decided to keep using my sturdy X40. Looking at what could be done to improve the 4 years old workhorse, three things came to mind:

* new battery (old one dies in 45min, new one lasts easily 5+h)
* replace the hard drive (preemptively before it breaks)
* more ram (from 512MB -> 1.5G)



The only one worth detailing is the hard drive upgrade, since I decided to go SSD. less moving parts, less heat, less power consumption. I followed the Thinkwiki CompactFlash boot howto. This basically involves getting a CF-IDE adapter (from ebay, around $5) and any CF card. The first CF-IDE adapter $2.99, but it didn't work. After some research it was concluded that the SMT soldering was bad. The second adapter bought worked fine, and as a bonus the dimensions match the X40 HD perfecty:

In order to minimize writing to flash:

* Make sure root filesystem is mounted noatime,nodiratime (see /etc/fstab)
* make /tmp a tmpfs partition
* disable swap
* more tips can been seen at Linux on Flash guide

Generally I'm very happy with the results of the upgrade. X40 is now most of the time completly silent, without the spinning and clicking HD. Fan turns on less often than previously. The cheapo compactflash is fast enough on reading, and the REALLY slow write speed is usually not a problem thanks to the loads of RAM. Ofcourse, the exception is when a application uses fsync() ... which leads to.

FIREFOX SUCKS GOAT BALLS WHEN RAN FROM A SLOW SSD

Seriously. It's like watching snail cross a tarpit. That's what happens when you fsync() a 30MB places.sqlite on a 6MB/s write speed flash media every fucking time a page has finished loading (and seeming every now and then too). Now here's a really simple workaround: make ~/.mozilla tmpfs and rsync it to/from a backup dir every time you log in/out.

* /etc/fstab: tmpfs /home/user/.mozilla tmpfs size=100m,user 0 0
* and two helper scripts:

aardvark:~$ cat bin/mozilla-mount
#!/bin/sh
mount /home/$USER/.mozilla
rsync -av /home/$USER/.mozilla-safe/ /home/$USER/.mozilla/
aardvark:~$ cat bin/mozilla-umount
#!/bin/sh
rsync -av /home/$USER/.mozilla/ /home/$USER/.mozilla-safe/
umount /home/$USER/.mozilla


It does what mozilla should be doing in the first place - write to temporary files when running and on exit synchronize to the real database and fsync(). With this hack, suddenly the web browser UI doesn't freeze every time a page has finished loading.

You'll also want to disable the urlclassifier anti-forgery tool, which can grow to a over 50MB sqlite database which also gets fsynced all the time...

8 comments:

  1. "It does what mozilla should be doing in the first place - write to temporary files when running and on exit synchronize to the real database and fsync()"

    That wouldn't be nice given that my Firefox used to crash regularly.

    ReplyDelete
  2. Thanks for the nice writeup! Two notes:

    I think most (all?) current distributions use relatime in mount options, which is a safe replacement for noatime,nodirtime.

    If you value your battery’s life and happen to mostly work on AC, consider

    modprobe tp-smapi
    echo 30 > /sys/devices/platform/smapi/BAT0/start_charge_thresh
    echo 80 > /sys/devices/platform/smapi/BAT0/stop_charge_thresh

    This will make your ThinkPad start charging only when the battery’s below 30% and stop when it’s at 80%.

    If you mostly work on AC, the less often you charge your battery the better, but you shouldn’t let it fall below 20%. Also, the top 20% (when over 80%) is done with impulse charging, which is also quite a killer.

    (Of course feel free to change these when you need to charge your battery to max before a longer unplugged session.)

    ReplyDelete
  3. Thanks for the advice!

    My X40 (4 years of continuous use) got fried two months ago by this problem, so hopefully it won't bit you either: http://forums.cnet.com/5208-7586_102-0.html?forumID=68&threadID=151816.

    Your advice on Firefox does work very well on my new EeePC 901, though!

    ReplyDelete
  4. garotosopa said:
    > That wouldn't be nice given that my Firefox used to crash regularly.

    I was kinda expecting this response. However, the correct action is to fix firefox to crash much more rarely. If crashes are rare, it's not that big deal to loose a freshly added bookmark.

    ReplyDelete
  5. I'm about to attempt this, too. Got the adaptor and the new battery but I haven't bought a CF card yet. Any tips on how to identify CF cards with good speeds? Most of them are marketed purely on a capacity basis, but I've heard that there is quite a lot of variation in IO speeds.

    ReplyDelete
  6. I replaced the HDD in my x40 with two CFs two months ago and have been very happy with the setup.

    Highly recommended :-)

    On the topic of CF speed,

    Jon Dowland said:
    > Any tips on how to identify CF cards with good speeds?

    A colleague pointed me to this site comparing speed of several popular CF models in different adapters:

    http://www.hjreggel.net/cardspeed/

    I decided to go with a fast Transcend CF 300x 8GB for often accessed data (currently / and parts of /home) and a (much) slower Transcend CF 133x 32GB for longer-term storage like music.

    It has worked out pretty well.

    ReplyDelete
  7. Thanks for the blog and I find it informative especially after I replaced 2 hard drives on my x40 already. Can you suggest the specs for the CF card and the adapter brand that I need to use for my system? Thanks

    ReplyDelete
  8. Jon,

    I can't recommend any CF card, and the IDE-CF adapter is anonymous. You can find it on ebay with subjects like:

    "compact flash 2.5 IDE adapter as Hitachi 1.8HDD"

    ReplyDelete