/をraid0にしたら、とても快適になった

騙されたと思って、/をraid0にしたら、とてつもなく快適になりました。hdd2台使ってる人にはオススメです。linuxの場合は、特別なハードウェアを用意しなくても、気軽にraidを試せるのはポイント高いです。

参考にしたのは、http://en.gentoo-wiki.com/wiki/Root_filesystem_over_LVM2,_DM-Crypt_and_RAIDとかhttp://en.gentoo-wiki.com/wiki/Initramfsですね。

キモとなるのは、initramfsを使ういこなすことですが、最初はなかなか難かしいです。ここで重要なのは、まずdevtmpfsを使うこと。devtmpfsは、まだudevが起動する前の段階で、デバイスノードを動的に生成してくれるので、hddをつけたり外したりして、デバイスの構成が変った時にも柔軟に対応できます。もうひとつ重要なのは、rescue_shellを利用することですね。何かエラーがあっても、rescue_shellを使って、自力でブートできるので、便利です。initramfsが上手く動かない原因は、大半が適切なデバイスノードがないことですので、devtmpfsとrescue_shellを使いこなせれば、殆どの問題を解決できるとおもいます。

<参考> 今つかっている/usr/src/initram/init

#!/bin/busybox sh

rescue_shell()
{
	echo "Something went wrong. Dropping you to a rescue shell"
	busybox --install -s
	exec bin/sh
}

/bin/busybox mount -t proc none /proc
/bin/busybox mount -t sysfs none /sys
/bin/busybox mount -t devtmpfs none /dev

CMDLINE=`cat /proc/cmdline`

#if RESCUE_SHELL is included in CMDLINE, open rescue shell
if (echo ${CMDLINE} | grep 'RESCUE_SHELL'); then
	rescue_shell
fi

#wait a little to avoid trailing kernel output
#sleep 3

#raid
/sbin/mdadm --assemble /dev/md3 /dev/sda3 /dev/sdb3

#lvm
#/sbin/vgscan
/sbin/lvm vgchange -ay 


#root filesystem
/sbin/mount.nilfs2 -r /dev/eltro/gentoo /newroot || rescue_shell


#unmount pseudo FS
/bin/busybox umount /sys
/bin/busybox umount /proc
/bin/busybox umount /dev

#root switch
exec /bin/busybox switch_root /newroot /sbin/init ${CMDLINE}