2012/05/15

zshで這いよられてみる

https://twitter.com/#!/Manabii_R/status/197645984208134144にインスパイアされて作ってみた。

u_nyah.sh
#!/bin/zsh export u_nyah_count=${u_nyah_count:-"1"} u_nyah_prompt() { pstr[1]='(」・ω・)」うー! ' pstr[2]='(/・ω・)/にゃー!' pstr[3]='(」・ω・)」うー! ' pstr[4]='(/・ω・)/にゃー!' pstr[5]='(」・ω・)」うー! ' pstr[6]='(/・ω・)/にゃー!' pstr[7]="Let'\(・ω・)/にゃー!" RPROMPT="$pstr[$u_nyah_count]" u_nyah_count=$(( $u_nyah_count + 1 )) if [ $u_nyah_count -gt 7 ] ; then export u_nyah_count=$(( $u_nyah_count - 7 )) fi } precmd_functions=($precmd_functions u_nyah_prompt)

使うには、source u_nyah.shするか、上の内容のshebang行を取り除いて~/.zshrcに突っ込む。
かんたん!

Let'\(・ω・)/にゃー!

2012/05/11

gentooでcpufreqを動かす

cpufreqdとかをインスコしてから何をすればいいかのメモ。
設定ファイルとかは省略。どっか他のページをggってくださいな

自動で起動するように

# sudo rc-update add cpufreqd default これでおk。

モジュールを自動でロード

これに引っ掛って苦労した…
ここの作業を抜くと、起動時に

 * cpufreqd requires the kernel to be configured with CONFIG_CPU_FREQ
 * Make sure that the appropiate kernel drivers for your CPU are
 * built-in or loaded.
 * ERROR: cpufreqd failed to start
とエラーが出る。

まず、現在のcpuの動作周波数を確認するのには $ cat /proc/cpuinfo | awk -F':' '$1~/^cpu MHz */{print $1}' でわかる。
さて、cpufreqdはカーネルにモジュールをロードしなければ動作しないらしい。
$ sudo depmod -n | grep -i cpu してみると、
alias acpi acpi_cpufreq
などという行があったので、 $ sudo modprobe acpi した瞬間、クロックが変化しだした。
どうやら俺の場合はこれでビンゴだったようだ。
あとは # vim /etc/conf.d/modules とでもして modules="vboxdrv acpi" といった感じでacpiを追加すれば完了。

Ubuntuでオフラインでの起動時に120秒待たされる原因がわかった

唐突だが、俺が使っているメインの娘はリビングにある。
そしてルータは最も遠い、親父の部屋にある。
つまり親父の作業中(だいたいは休日だが)はLANケーブルを引っこぬかれるのである。
つまりUbuntuで俺は休日の起動に120秒待たされる。
オフラインで起動したことがあるなら、「Waiting up to 60 more seconds for network configuration...」などというメッセージを見たことがあるはずだ。
今回Ubuntu12.04LTSを入れて再設定したところで存在を思いだしたので、原因の設定と解決法をここにメモしておく。

面倒なので、変更点の周辺のみを貼っておく。

/etc/init/failsafe.conf
# The point here is to wait for 2 minutes before forcibly booting # the system. Anything that is in an "or" condition with 'started # failsafe' in rc-sysinit deserves consideration for mentioning in # these messages. currently only static-network-up counts for that. sleep 20 # Plymouth errors should not stop the script because we *must* reach # the end of this script to avoid letting the system spin forever # waiting on it to start. $PLYMOUTH message --text="Waiting for network configuration..." || : #sleep 40 sleep 15 #$PLYMOUTH message --text="Waiting up to 60 more seconds for network configuration..." || : #sleep 59 $PLYMOUTH message --text="Booting system without full network configuration..." || : # give user 1 second to see this message since plymouth will go # away as soon as failsafe starts. sleep 1 exec initctl emit --no-wait failsafe-boot

丁寧な解説がはじめから付いているうえ元のコードもコメントアウトしてあるのでわかると思うが、このsleepというのが犯人である。
本来はネットワークが使用可能になるまで待機するためのものなのだろうが、オフラインでの起動でそれはありえないので時間を短くする。
ついでに、このplymouthというのはUbuntuの起動時のロゴと5つの点のスプラッシュ画面のやつらしい。