13 Oktober 2010

Configuration for 'optimal' eco performance linux on USB disk

It has been around 1 year I've been using my USB-disk linux installation as my main computing platform. Generally it is slow, particularly for writing. I even feel it runs much slower during shutdown. Just like general flash-disk devices, USB-disks have limited read-write lifetime, therefore I try to minimize any access to the disk. The idea is maximizing the usage of memory for read-write operations that occur very often.
Here are my configuration:

  1. /tmp. This directory is used for temporary read-write by default. I think in some distro this directory is put on memory by default when there are vast amount of memory. I also put the cache of favorite application there. Add a starting script on /etc/rcS.d/. Copy from one of it, change the name into Ssomething and modify the content as the following:

    ...
    ### END INIT INFO

    . /lib/init/vars.sh
    . /lib/lsb/init-functions

    make_tmp() {
    #preparing /tmp
    mkdir /dev/shm/tmp
    chmod 777 /dev/shm/tmp
    #we also prepare the browsers cache
    mkdir /dev/shm/tmp/google-chrome
    chmod 777 /dev/shm/tmp/google-chrome
    mkdir /dev/shm/tmp/epiphany
    chmod 777 /dev/shm/tmp/epiphany
    }
    case "$1" in
    start)
    # Using 'no !=' instead of 'yes =' to make sure async nfs
    # mounting is the default even without a value in
    # /etc/default/rcS
    make_tmp
    ;;
    ...
    Note: I usually use those two browser, haven't found out where are the cache of opera nor firefox/iceweasel.
  2. Swap file. Never ever use the flash disk as swap file/swap partition, I think it will shortened the lifespan of the disk a lot. I use my unused VGA memory as my swap file. The script is following. Note that sometime you need to run it twice, I don't know why.
    modprobe slram map=VRAM,0xc4000000,+0x0c000000
    modprobe mtdblock
    mkswap /dev/mtdblock0
    swapon /dev/mtdblock0
    swapon -s

  3. Installation cache and configuration (/var/cache/apt/) can be put on external disk and make a symlink to its proper directory
Warning: you must aware that having cache on memory may cause your computer runs out of memory, and using VGA card as swap file is unsafe.

Tidak ada komentar: