Установка FreeBSD 9.0 release и выше на ZFS в виде скрипта

Надоело  бегать в инет искать порядок ручной установки сабжа, потому как кое-что из инсталяции постоянно выпадает из головы, поэтому в качестве шпоры  привожу скрипт автоматной установки. Из него можно вытащить необходимые действия…

#!/bin/sh

# Vars
dev=ada0
tank=tank
if_wan=re0
if_lan=rl0
hostname=myhostname

# gpart
echo "script: Create GPT, add partitions..."

gpart create -s GPT $dev
gpart add -b 40 -s 1024 -t freebsd-boot $dev
gpart add -b 2048 -s 4G -t freebsd-swap -l swap0 $dev
gpart add -s 3898636000 -t freebsd-zfs -l data0 $dev

echo " "
echo "script: GPT on $dev created, partitions added."
echo " "

sleep 5

gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 $dev

gpart show $dev

sleep 5

# Create ZFS pool
echo "script: Create ZFS pool..."

zpool create -f $tank /dev/gpt/data0
zpool set bootfs=$tank $tank

sleep 3

# Create ZFS-filesystem
echo "script: Create filesystem..."

zfs set atime=off $tank
zfs set checksum=fletcher4 $tank
zfs set mountpoint=/mnt $tank

# Export and import the pool
zpool export $tank
zpool import -o cachefile=/var/tmp/zpool.cache $tank

zfs create -o compression=on -o exec=on -o setuid=off $tank/tmp
chmod 1777 /mnt/tmp

zfs create $tank/usr
zfs create $tank/usr/home

cd /mnt ; ln -s /usr/home home
zfs create -o compression=off -o setuid=off $tank/usr/ports
zfs create -o compression=off -o exec=off -o setuid=off $tank/usr/ports/distfiles
zfs create -o compression=off -o exec=off -o setuid=off $tank/usr/ports/packages

zfs create -o compression=lzjb -o exec=off -o setuid=off $tank/usr/src

zfs create $tank/var
zfs create -o compression=lzjb -o exec=off -o setuid=off $tank/var/crash
zfs create -o exec=off -o setuid=off $tank/var/db
zfs create -o compression=lzjb -o exec=on -o setuid=off $tank/var/db/pkg
zfs create -o exec=off -o setuid=off $tank/var/empty
zfs create -o compression=lzjb -o exec=off -o setuid=off $tank/var/log
zfs create -o compression=gzip -o exec=off -o setuid=off $tank/var/mail
zfs create -o exec=off -o setuid=off $tank/var/run
zfs create -o compression=lzjb -o exec=on -o setuid=off $tank/var/tmp
chmod 1777 /mnt/var/tmp

sleep 3
clear
echo "script: ZFS-filesystem structure:"

zfs list
sleep 15
clear

# install base system
echo "script: Install base system..."

cd /usr/freebsd-dist
export DESTDIR=/mnt
for file in base.txz doc.txz kernel.txz ports.txz src.txz; do (cat $file | tar --unlink -xpJf - -C ${DESTDIR:-/}) ; done

echo "script: System has bin installed..."
sleep 1
echo "script: Copy zpool cache..."
cp /var/tmp/zpool.cache /mnt/boot/zfs/zpool.cache

sleep 1
# install base config
echo "script: Install base config..."

cat << EOF > /mnt/etc/rc.conf
# ZFS
zfs_enable="YES"

#
# NET OPTIONS
#
hostname="$hostname"
ifconfig_$if_wan="DHCP"
ifconfig_$if_lan="inet 192.168.1.1 netmask 255.255.255.0"

sshd_enable="YES"
EOF

echo 'zfs_load="YES"' > /mnt/boot/loader.conf
echo "vfs.root.mountfrom=\"zfs:$tank\"" >> /mnt/boot/loader.conf
echo 'vfs.zfs.prefetch_disable=1' >> /mnt/boot/loader.conf
echo 'vm.kmem_size="1500M"' >> /mnt/boot/loader.conf
echo 'vm.kmem_size_max="1500M"' >> /mnt/boot/loader.conf
echo 'vfs.zfs.arc="1024M"' >> /mnt/boot/loader.conf
echo 'vfs.zfs.arc_max="1024M"' >> /mnt/boot/loader.conf
echo 'vfs.zfs.vdev.cache.size="20M"' >> /mnt/boot/loader.conf
echo 'loader_logo="beastie"' >> /mnt/boot/loader.conf

sleep 1
echo "script: Make fstab..."

cat << EOF > /mnt/etc/fstab
# Device          Mountpoint     FStype  Options         Dump    Pass#
/dev/gpt/swap0    none           swap    sw              0       0
EOF

sleep 5
clear

# correct ZFS mount points and quotas
echo "script: Set mount points and quotas..."
zfs unmount -af
zfs set mountpoint=legacy $tank
zfs set mountpoint=/usr   $tank/usr
zfs set quota=4G   $tank/tmp   &amp;amp;amp;amp;&amp;amp;amp;amp; zfs set mountpoint=/tmp   $tank/tmp
zfs set quota=4G  $tank/var   &amp;amp;amp;amp;&amp;amp;amp;amp; zfs set mountpoint=/var   $tank/var

sleep 5
clear
zpool status
sleep 15
echo "script: Choice your time zone..."
sleep 5
tzsetup
cd /etc/mail
make aliases
clear
echo "script: done!"

Добавить комментарий

Ваш e-mail не будет опубликован. Обязательные поля помечены *

CAPTCHA изображение

*