Pristine FreeBSD installation

Sometimes when doing some testing you need to make sure that you know exactly what pkgs you have installed. Often pkgs keep getting installed on top of each other and you aren't exactly sure what you have because of the odd tweak here and there, so I've devised a short script which will create a pristine FreeBSD environment for testing. It assumes that you have FreeBSD installation files somewhere on your network and that you want to install FreeBSD 11.1-RELEASE amd64 on an external disk which exists as /dev/da0. No swapfile is created but that would be easy to add.... It does a minimal install and creates a /etc/fstab and /etc/rc.conf which should be adjusted to suite your requirements. The new installation needs no manual intervention apart from tailoring to one's own needs and takes less than two minutes to install..
Code:
gpart destroy -F da0
gpart create -s gpt da0
gpart add -t freebsd-boot -s 512k da0
gpart add -t freebsd-ufs da0
newfs /dev/da0p2
mkdir /mnt/pristine
mount /dev/da0p2 /mnt/pristine
tar zxf /mnt/projects/FreeBSD/11.1-x64/base.txz -C /mnt/pristine
tar zxf /mnt/projects/FreeBSD/11.1-x64/kernel.txz -C /mnt/pristine
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1  da0
#
# create /etc/fstab and /etc/rc.conf
#
cat <<EOF  >> /mnt/pristine/etc/fstab
# Device        Mountpoint    FStype    Options    Dump    Pass#
#/dev/da0p2        /        ufs    rw    1    1
/dev/da0p2        /        ufs    rw    1    1

//guest@FREENAS/PROJECTS    /mnt/projects    smbfs    rw,-N,-I192.168.1.2    0    0
//guest@FREENAS/repo    /mnt/repo    smbfs    rw,-N,-I192.168.1.2    0    0

192.168.1.2:/mnt/nas/tftproot      /mnt/tftproot  nfs    rw,noatime,readahead=4,intr,soft,nfsv4    0    0
EOF

cat <<EOF  >> /mnt/pristine/etc/rc.conf
keymap="uk"
ifconfig_em0="DHCP"
kld_list="i915kms"
EOF

#
# create dirs on mnt
#
mkdir /mnt/pristine/mnt/projects
mkdir /mnt/pristine/mnt/repo

umount /mnt/pristine
rmdir /mnt/pristine

If necessary you could automatically install any required pkgs from a pkg list.
 
Back
Top