Created
October 7, 2010 15:49
-
-
Save lyo/615329 to your computer and use it in GitHub Desktop.
FreeBSD+Root on ZFS環境構築メモ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#FreeBSD+Root on ZFS | |
#install memo | |
#ad0 と da0(USB)の表示確認 | |
gpart show | |
#対象を絞って... | |
gpart show ad0 | |
#前回分削除 | |
gpart delete -i 1 ad0 | |
gpart delete -i 2 ad0 | |
gpart destroy ad0 | |
#削除確認 | |
gpart show | |
#パーティション作成 | |
#開始位置の確認 | |
gpart create -s gpt ad0 | |
# 128 block * 512 = 64Kbyte -s 64Kでもok | |
gpart add -b 34 -s 128 -t freebsd-boot ad0 | |
gpart add -b 162 -t freebsd-zfs -l disk0 ad0 | |
#bootcodeをfreebsd-boot(1番目)につっこむ | |
gpart bootcode -b /mnt2/boot/pmbr -p /mnt2/boot/gptzfsboot -i 1 ad0 | |
#必要なカーネルモジュールを読み込み | |
kldload /mnt2/boot/kernel/opensolaris.ko | |
kldload /mnt2/boot/kernel/zfs.ko | |
# プールの作成。-f で以前作成したのがいても強制的に上書き | |
zpool create -f zroot /dev/gpt/disk0 | |
zpool set bootfs=zroot zroot | |
#チェックサムアルゴリズム変更 | |
zfs set checksum=fletcher4 zroot | |
#zfsファイルシステム作成(compression=offは指定無しでも同じ) | |
zfs create -o compression=on -o exec=on -o setuid=off zroot/tmp | |
chmod 1777 /zroot/tmp | |
zfs create zroot/usr | |
zfs create -o compression=lzjb zroot/usr/home | |
cd /zroot; ln -s /usr/home home | |
zfs create -o compression=lzjb -o setuid=off zroot/usr/ports | |
zfs create -o compression=off -o exec=off -o setuid=off zroot/usr/ports/distfiles | |
zfs create -o compression=off -o exec=off -o setuid=off zroot/usr/ports/packages | |
zfs create zroot/var | |
zfs create -o compression=lzjb -o exec=off -o setuid=off zroot/var/crash | |
zfs create -o compression=off -o exec=off -o setuid=off zroot/var/db | |
zfs create -o compression=lzjb -o exec=on -o setuid=off zroot/var/db/pkg | |
zfs create -o compression=off -o exec=off -o setuid=off zroot/var/empty | |
zfs create -o compression=lzjb -o exec=off -o setuid=off zroot/var/log | |
zfs create -o compression=lzjb -o exec=off -o setuid=off zroot/var/mail | |
zfs create -o compression=off -o exec=off -o setuid=off zroot/var/run | |
zfs create -o compression=lzjb -o exec=on -o setuid=off zroot/var/tmp | |
chmod 1777 /zroot/var/tmp | |
#スワップ用 | |
zfs create -V 2G zroot/swap | |
zfs set org.freebsd:swap=on zroot/swap | |
zfs set checksum=off zroot/swap | |
#確認 | |
zfs list | |
#もっと詳しく | |
zfs list -o name,used,available,compress,compressratio,checksum | |
#FreeBSD手動インストールの前の設定 | |
export DESTDIR=/zroot | |
#確認 | |
echo $DESTDIR | |
##base のインストール | |
cd /dist/8.1-RELEASE/base | |
sh ./install.sh | |
##You are about to extract the base distribution into /pzkw/system - are you SURE | |
##you want to do this over your installed system (y/n) ? って聞かれるので | |
##y と返答 | |
##kernel のインストール | |
cd /dist/8.1-RELEASE/kernels | |
sh ./install.sh generic | |
cd $DESTDIR/boot | |
rmdir kernel | |
mv GENERIC kernel | |
##src のインストール | |
cd /dist/8.1-RELEASE/src | |
sh ./install.sh all | |
#設定 | |
zfs set readonly=on zroot/var/empty | |
chroot /zroot tcsh | |
echo 'zfs_enable="YES"' >> /etc/rc.conf | |
echo 'zfs_load="YES"' >> /boot/loader.conf | |
echo 'vfs.root.mountfrom="zfs:zroot"' >> /boot/loader.conf | |
#ついでにSpeedStep有効化 | |
echo 'powerd_enable="YES"' >> /etc/rc.conf | |
#rootのパスワード設定 | |
passwd | |
#その他設定 | |
sysinstall | |
#Configure -> User Managementでユーザ追加 | |
# Timezone設定 | |
# /etc/mail/aliases.dbの作成 | |
cd /etc/mail | |
make aliases | |
#chroot環境から抜ける | |
exit | |
#zfs設定の保存 | |
mkdir /boot/zfs | |
cd /boot/zfs | |
zpool export zroot && zpool import zroot | |
cp /boot/zfs/zpool.cache /zroot/boot/zfs/zpool.cache | |
#export LD_LIBRARY_PATH | |
export LD_LIBRARY_PATH=/mnt2/lib | |
#Unmount all zfs filesystems | |
zfs unmount -a | |
#zfsのマウントポイントを設定 | |
zfs set mountpoint=legacy zroot | |
zfs set mountpoint=/tmp zroot/tmp | |
zfs set mountpoint=/usr zroot/usr | |
zfs set mountpoint=/var zroot/var | |
#おしまい。リブートして再起動。 | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment