chenpc May 19th, 2009
=====bashrc=======
if [[ $- != *i* ]] ; then
# Shell is non-interactive. Be done now!
return
fi
PATH=”/usr/pkg/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${ROOTPATH}”
LANG=en_US.UTF-8
PS1=’\[\033[01;34m\](\033[01;32m\]\h\[\033[01;00m\]:\033[01;34m\]\w)\[\033[01;32m\] \u%\[\033[00m\] ‘
INPUTRC=~/.inputrc
export PATH LANG PS1 INPUTRC
if [[ $OSTYPE == 'netbsd' ]];
then
alias ls=’gls –color’
fi
=====inputrc=======
set meta-flag on
set input-meta on
set convert-meta off
set output-meta on
“\e[1~”: beginning-of-line
“\e[4~”: end-of-line
“\e[5~”: beginning-of-history
“\e[6~”: end-of-history
“\e[3~”: delete-char
“\e[2~”: quoted-insert
“\e[5C”: forward-word
“\e[5D”: backward-word
Tags: BSD
chenpc May 13th, 2009
原理大致上是利用/dev/shm把portage放到記憶體裡面去。
而portage的特性是容量沒有很大,但是小檔案很多。
而小檔案在硬碟上面操作速度很慢,不管是sync或者是search。
我想要做的是寫一個boot up script,可以在開機的時候把portage tar開。
關機的時候把portage打包起來。
所以情況是
start: HD(portage.tar.gz)->RAM(/dev/shm/portage)
stop: RAM(/dev/shm/portage) -> HD(portage.tar.gz)
不管start or stop都不會讓硬碟作大量的小檔案存取。
作法:
mv /usr/portage /usr/portage.bak
mkdir /dev/shm/portage
ln -sf /dev/shm/portage /usr/portage
emerge --sync
這樣你的portage就在ram裡面了。
/etc/init.d/portage start --->解開你的portage
/etc/init.d/portage stop --->備份你的portage
在/etc/conf.d/portage裡面,指定你要備份的目錄。
PORTAGE_DIR=/dev/shm/portage #放portage的目錄。
BACKUP_DIR=/usr #放備份檔的目錄,記得不要放在/tmp,重開機可能會被清掉。
記得/usr/portage/distfiles 和packages 要移出來。
這部份可以在/etc/make.conf裡面用:
PKGDIR="somewhere"
DISTIDR="somewhere"
在make.conf指定,或是用link把他link進去。
http://dsppc16.cs.nctu.edu.tw/~chenpc/portage
這裡是一個run script,放到/etc/init.d下面。
執行
/etc/init.d/portage start|stop|restart
即可
程式已經有稍微防呆,只要portage裡面有檔案他就不會tar 開。
裡面要是沒有檔案,他也不會打包。
目前我還沒遇到問題,但是使用前最好還是確定自己有備份。
效能:
df -h顯示shm吃了大約500MB,但是top看到只加了130MB左右,不知道怎麼回事。
RAM很多的話,可以玩看看。
start的速度大概是5秒。stop的速度也差不多5秒。
而emerge search速度非常快。
我的機器是:E8400,4G RAM,WD6400AACS。
Tags: Gentoo
chenpc May 8th, 2009
簡介:libconfig是一個config file 的parser,非常小只有38k,適合用在容量受限制的系統。
用法:
gcc -lconfig
=程式範例=
#include <libconfig.h>
config_t conf;
const char *hostname;
config_init(&conf);
hostname=(char*)config_lookup_string(&conf,”host”);
=設定檔範例=
host=”10.1.0.1″;
Tags: Program
chenpc May 8th, 2009
tune2fs -O extents,uninit_bg,dir_index /dev/sdxx
Tags: linux