9 # check if the zpool already exists
11 ZPOOL_EXISTS=` zpool list -H | cut -f 1 | grep "${ZPOOL}"`
12 if [ "${?}" -ne 1 ]; then
13 echo "One zpool called ${ZPOOL} already exists, you have to destroy it first:"
14 echo " # zpool destroy ${ZPOOL}"
18 # check if the disk is ok for writing
20 echo checking sanity ${DESTDISK}
22 gpart show ${DESTDISK} 1>/dev/null
23 if [ "${?}" -eq 0 ]; then
25 gpart destroy -F ${DESTDISK}
26 if [ "${?}" -ne 0 ]; then
27 echo unable to reset ${DESTDISK}
32 echo partitioning ${DESTDISK}
35 gpart create -s gpt ${DESTDISK}
36 gpart add -a 1m -t freebsd-boot -s 128k -l boot ${DESTDISK}
37 gpart add -a 1m -s 32G -t freebsd-swap -l swap ${DESTDISK}
38 gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ${DESTDISK}
39 gpart add -a 1m -t freebsd-zfs -l syszfs ${DESTDISK}
41 gpart show ${DESTDISK} 1>/dev/null
43 sysctl vfs.zfs.min_auto_ashift=12
45 echo set up zfs pool: ${ZPOOL} alt mount: ${DESTDIR}
46 echo =================
48 zpool create -m none -f -R ${DESTDIR} ${ZPOOL} ${DESTDISK}p3
49 if [ "${?}" -ne 0 ]; then
50 echo "unable to create zpool"
55 for I in ROOT VAR HOME; do
56 zfs create -o mountpoint=none -o canmount=off ${ZPOOL}/${I}
59 zfs create -o atime=off -o mountpoint=/ ${ZPOOL}/ROOT/master
60 zfs create -o mountpoint=/usr/obj ${ZPOOL}/ROOT/obj
61 zfs create -o compression=off -o mountpoint=/usr/src ${ZPOOL}/ROOT/src
62 # useless ? as far /tmp mountpoint will be mounted by tmpfs
63 zfs create -o mountpoint=/tmp ${ZPOOL}/ROOT/tmp
65 zfs create -o mountpoint=/usr/local ${ZPOOL}/LOCAL
66 zfs create -o mountpoint=/usr/local/etc ${ZPOOL}/LOCAL/config
67 zfs create -o copies=1 -o mountpoint=/usr/src -o compression=off ${ZPOOL}/src
68 zfs create -o copies=1 -o mountpoint=/usr/doc -o compression=on ${ZPOOL}/doc
69 zfs create -o copies=1 -o mountpoint=/usr/obj -o compression=on ${ZPOOL}/obj
72 zfs create -o mountpoint=/var ${ZPOOL}/VAR/master
73 zfs create -o mountpoint=/var/crash ${ZPOOL}/VAR/crash
74 zfs create -o exec=off -o setuid=off -o mountpoint=/var/db ${ZPOOL}/VAR/db
75 zfs create -o compression=lz4 -o exec=on -o setuid=off -o mountpoint=/var/db/pkg ${ZPOOL}/VAR/db/pkg
76 zfs create -o compression=on -o exec=off -o setuid=off -o mountpoint=/var/mail ${ZPOOL}/VAR/mail
77 zfs create -o compression=on -o exec=off -o setuid=off -o mountpoint=/var/log ${ZPOOL}/VAR/log
78 zfs create -o exec=off -o setuid=off -o mountpoint=/var/run ${ZPOOL}/VAR/run
79 zfs create -o exec=off -o setuid=off -o mountpoint=/var/tmp ${ZPOOL}/VAR/tmp
81 zfs create -o mountpoint=/usr/home ${ZPOOL}/HOME/master
84 chmod 1777 ${DESTDIR}/tmp ${DESTDIR}/var/tmp
89 if [ "${?}" -ne 0 ]; then
90 echo zfs mountpoints arent ready
94 echo Fetching and Extracting base files into ${DESTDIR}
95 echo =======================================
98 for I in base.txz kernel.txz lib32.txz; do
99 fetch http://ftp.freebsd.org/pub/FreeBSD/snapshots/amd64/12.0-ALPHA8/${I}
100 tar --unlink -pJxf ${I} -C ${DESTDIR}
103 echo writing configuration files
104 echo ==========================
106 cat << EOF >> ${DESTDIR}/etc/fstab
107 /dev/${DESTDISK}p2 none swap sw 0 0
108 tmpfs /tmp tmpfs rw,mode=1777 0 0
111 cat << EOF >> ${DESTDIR}/boot/loader.conf
116 cat << EOF >> ${DESTDIR}/boot/loader.conf.local
117 vfs.root.mountfrom="zfs:${ZPOOL}/ROOT/master"
120 cat << EOF >> ${DESTDIR}/etc/rc.conf
122 sendmail_enable="NONE"
123 kld_list="vmm cuse4bsd cpuctl filemon"
125 # Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
131 for I in resolv.conf rc.conf.local; do
132 if [ -r "${I}" ]; then
134 install -o root -g wheel -m 0644 ${I} ${DESTDIR}/etc/
138 for I in loader.conf.local; do
139 if [ -r "${I}" ]; then
141 install -o root -g wheel -m 0644 ${I} ${DESTDIR}/boot/
145 echo installing rc.conf.d
146 install -o root -g wheel -d -m 0755 ${DESTDIR}/etc/rc.conf.d
147 if [ -d "./rc.conf.d" ]; then
148 echo installing files into rc.conf.d
149 install -o root -g wheel -m 0644 ./rc.conf.d/* ${DESTDIR}/etc/rc.conf.d/
152 chroot ${DESTDIR} passwd
153 chroot ${DESTDIR} adduser
155 read -p "Do you wish to open a shell ?" yn
159 * ) echo "Please answer yes or no.";;
161 chroot ${DESTDIR} tcsh