Пример скрипта установки системы:
#!/bin/sh
sysctl kern.geom.debugflags=16
gpart destroy -F ada0
gmirror clear ada0
gpart create -s MBR ada0
gpart add -t freebsd -a 4k ada0
gpart create -s BSD ada0s1
gpart add -t freebsd-ufs -a 4k -s 4g ada0s1
gpart add -t freebsd-swap -a 4k -s 5g ada0s1
gpart add -t freebsd-ufs -a 4k -s 20g ada0s1
gpart add -t freebsd-ufs -a 4k -s 5g ada0s1
gpart add -t freebsd-ufs -a 4k -s 40g ada0s1
gpart add -t freebsd-ufs -a 4k ada0s1
gpart bootcode -b /boot/mbr ada0
gpart set -a active -i 1 ada0
gpart bootcode -b /boot/boot ada0s1
newfs -U /dev/ada0s1a
newfs -U /dev/ada0s1d
newfs -U /dev/ada0s1e
newfs -U /dev/ada0s1f
newfs -U /dev/ada0s1g
mount /dev/ada0s1a /mnt
mkdir /mnt/var
mkdir /mnt/tmp
mkdir /mnt/usr
mkdir /mnt/data0
mount /dev/ada0s1d /mnt/var
mount /dev/ada0s1e /mnt/tmp
mount /dev/ada0s1f /mnt/usr
mount /dev/ada0s1g /mnt/data0
cd /usr/freebsd-dist
DESTDIR="/mnt"
for file in base.txz kernel.txz doc.txz src.txz ; do (cat $file | tar --unlink -xpJf - -C ${DESTDIR:-/}); done
echo "end script"
Пример скрипта создания конфигурационных файлов:
#!/bin/sh
echo '# Device Mountpoint FStype Options Dump Pass#
/dev/mirror/ada0s1a / ufs rw 1 1
/dev/mirror/ada0s1b none swap sw 0 0
/dev/mirror/ada0s1d /var ufs rw 2 2
/dev/mirror/ada0s1e /tmp ufs rw 2 2
/dev/mirror/ada0s1f /usr ufs rw 2 2
/dev/mirror/ada0s1g /data0 ufs rw 2 2
' > /mnt/etc/fstab
echo 'nameserver 8.8.8.8
' > /mnt/etc/resolv.conf
echo 'keymap="ru.koi8-r.kbd"
scrnmap="koi8-r2cp866"
font8x16="cp866b-8x16"
font8x14="cp866-8x14"
font8x8="cp866-8x8"
dumpdev="NO"
sendmail_enable="NONE"
fsck_y_enable="YES"
background_fsck="NO"
hostname="ftest.home.ru"
defaultrouter="192.168.0.1"
ifconfig_em0="inet 192.168.0.101 netmask 255.255.255.0"
sshd_enable="YES"
' > /mnt/etc/rc.conf
echo 'geom_mirror_load="YES"
' > /mnt/boot/loader.conf
echo 'end script'