Created
November 17, 2012 15:54
-
-
Save mitchty/4097004 to your computer and use it in GitHub Desktop.
A contrived freebsd install script
This file contains hidden or 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 | |
| zpool destroy zroot | |
| for disk in 0 1 2 3 4 5; do | |
| gpart destroy -F ada${disk} | |
| gpart create -s gpt ada${disk} | |
| gpart add -b 34 -s 94 -t freebsd-boot ada${disk} | |
| gpart add -b 2048 -t freebsd-zfs -l disk${disk} ada${disk} | |
| gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada${disk} | |
| gnop create -S 4096 /dev/gpt/disk${disk} | |
| done | |
| zpool create -f -o altroot=/mnt -o cachefile=/var/tmp/zpool.cache zroot raidz2 gpt/disk0 gpt/disk1 gpt/disk2 gpt/disk3 gpt/disk4 gpt/disk5 | |
| zpool create -f -o altroot=/mnt -o cachefile=/var/tmp/zpool.cache zroot raidz2 gpt/disk0.nop gpt/disk1.nop gpt/disk2.nop gpt/disk3.nop gpt/disk4.nop gpt/disk5.nop | |
| zpool export zroot | |
| for disk in 0 1 2 3 4 5; do | |
| gnop destroy /dev/gpt/disk${disk}.nop | |
| done | |
| zpool import -o altroot=/mnt -o cachefile=/var/tmp/zpool.cache zroot | |
| zpool set bootfs=zroot zroot | |
| zfs set checksum=fletcher4 zroot | |
| zfs create zroot/usr | |
| zfs create zroot/usr/home | |
| zfs create zroot/var | |
| zfs create -o compression=off -o exec=on -o setuid=off zroot/tmp | |
| zfs create -o compression=gzip-1 -o setuid=off zroot/usr/ports | |
| 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=gzip-9 -o exec=off -o setuid=off zroot/var/log | |
| 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 4G zroot/swap | |
| zfs set org.freebsd:swap=on zroot/swap | |
| zfs set checksum=off zroot/swap | |
| chmod 1777 /mnt/tmp | |
| cd /mnt ; ln -s usr/home home | |
| chmod 1777 /mnt/var/tmp | |
| cd /usr/freebsd-dist | |
| export DESTDIR=/mnt | |
| for file in base.txz lib32.txz kernel.txz doc.txz ports.txz src.txz; | |
| do (cat $file | tar --unlink -xpJf - -C ${DESTDIR:-/}); done | |
| cp /var/tmp/zpool.cache /mnt/boot/zfs/zpool.cache | |
| cat << 'FIN' >> /mnt/etc/rc.conf | |
| # all zfs, all the time | |
| zfs_enable="YES" | |
| # Network configuration | |
| hostname="bsd" | |
| ifconfig_em0="DHCP" | |
| defaultrouter="10.0.0.1" | |
| nameserver="10.0.0.1" | |
| # need a mouse to get the bios to allow keyboard input, not to use | |
| moused_enable="NO" | |
| # ssh is useful | |
| sshd_enable="YES" | |
| # lets save some power | |
| powerd_enable="YES" | |
| # up to turning clocks on idle, but not disconnect/power off from bus like C3 does | |
| performance_cx_lowest="C2" | |
| economy_cx_lowest="C2" | |
| # use ntpdate to set the time at the start, then slew with ntp | |
| ntpdate_enable="YES" | |
| ntpd_enable="YES" | |
| ntpdate_hosts="0.freebsd.pool.ntp.org 1.freebsd.pool.ntp.org 2.freebsd.pool.ntp.org" | |
| # disable Sendmail | |
| sendmail_enable="NO" | |
| sendmail_submit_enable="NO" | |
| sendmail_outbound_enable="NO" | |
| sendmail_msp_queue_enable="NO" | |
| FIN | |
| cat << 'FIN' >> /mnt/boot/loader.conf | |
| zfs_load="YES" | |
| vfs.root.mountfrom="zfs:zroot" | |
| # default 30, reduces bursty io patterns | |
| vfs.zfs.txg.timeout="5" | |
| # for power savings | |
| ahci_load="YES" | |
| # disable p state throttling, we'll use c states instead | |
| hint.p4tcc.0.disabled=1 | |
| hint.acpi_throttle.0.disabled=1 | |
| FIN | |
| cat << 'FIN' >> /mnt/etc/resolv.conf | |
| nameserver 10.0.0.1 | |
| FIN | |
| touch /mnt/etc/fstab | |
| 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