Created
February 4, 2012 18:03
-
-
Save morsik/1739236 to your computer and use it in GitHub Desktop.
script for install freebsd 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
#!/bin/sh | |
msg() { | |
echo -e "\033[1;32m >> \033[1;37m$1\033[0m..." | |
} | |
msg "Creating zroot" | |
zpool create -f zroot mirror /dev/gpt/disk0 /dev/gpt/disk1 | |
msg "Configuring zroot" | |
zpool set bootfs=zroot zroot | |
zfs set checksum=fletcher4 zroot | |
zfs set mountpoint=/mnt zroot | |
msg "Creating zpool.cache" | |
zpool export zroot | |
zpool import -o cachefile=/var/tmp/zpool.cache zroot | |
msg "Creating zfs dirs" | |
zfs create zroot/usr | |
zfs create zroot/usr/home | |
zfs create zroot/var | |
zfs create -o compression=on -o exec=on -o setuid=off zroot/tmp | |
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 -o compression=lzjb -o exec=off -o setuid=off zroot/usr/src | |
zfs create -o compression=lzjb -o exec=off -o setuid=off zroot/var/crash | |
zfs create -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 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=gzip -o exec=off -o setuid=off zroot/var/mail | |
zfs create -o exec=off -o setuid=off zroot/var/run | |
zfs create -o compression=lzjb -o exec=on -o setuid=off zroot/var/tmp | |
#zfs create -V 2G zroot/swap | |
#zfs set org.freebsd:swap=on zroot/swap | |
#zfs set checksum=off zroot/swap | |
msg "Fixing chmod" | |
chmod 1777 /mnt/tmp | |
cd /mnt | |
ln -s usr/home home | |
chmod 1777 /mnt/var/tmp | |
cd /usr/freebsd-dist | |
export DESTDIR=/mnt | |
BASE='kernel.txz base.txz' | |
PORTS='ports.txz src.txz' | |
DOC='doc.txz' | |
#LIB32='lib32.txz' | |
#GAMES='games.txz' | |
for file in ${BASE} ${PORTS} ${DOC}; | |
do | |
msg "Unpacking $file" | |
(cat $file | tar --unlink -xpJf - -C ${DESTDIR:-/}); | |
done | |
msg "Copying zpool.cache into system" | |
cp /var/tmp/zpool.cache /mnt/boot/zfs/zpool.cache | |
msg "Configuring zfs" | |
echo 'zfs_enable="YES"' >> /mnt/etc/rc.conf | |
echo 'zfs_load="YES"' >> /mnt/boot/loader.conf | |
echo 'vfs.root.mountfrom="zfs:zroot"' >> /mnt/boot/loader.conf | |
touch /mnt/etc/fstab | |
msg "Finishing" | |
zfs set readonly=on zroot/var/empty | |
zfs umount -af | |
zfs set mountpoint=legacy zroot | |
zfs set mountpoint=/tmp zroot/tmp | |
zfs set mountpoint=/usr zroot/usr | |
zfs set mountpoint=/var zroot/var |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment