New BSD Installer
Daniel O'Connor
doconnor at gsoft.com.au
Sun Feb 12 06:44:01 UTC 2012
On 11/02/2012, at 6:32, Joe Holden wrote:
> On a related note - does the new installer have any kind of config file for unattended installs a la sysinstall?
No it doesn't, that said since the new release CD is a live file system (vs the old MFS on a CD kludge) it is much much easier to script your own install.
Especially with gpart it is fairly easy to setup a working system.
I use this at work - image.txz.?? is created from a chroot where I pre-build rather than using packages since it is a lot faster.
The original also does things like put certain settings in sysctl.conf, loader.conf and rc.conf.
I found it was a lot simpler to set this up vs doing something similar with sysinstall because sysinstall's environment was so restrictive.
Currently the user selects shell and then runs the script, but I am looking at modifying the release rc.local to add a menu option to make it simpler.
#!/bin/sh
PATH=/bin:/usr/bin:/sbin:/usr/sbin
export PATH
BLOCKSIZE=10240
ROSINST="/ros-install.sh"
if [ $# -ne 1 ]; then
devs=`camcontrol devlist | sed -nEe 's,<(.*)> +at scbus.*\((.*)\,(.*)\),\1|\2 \3,p' | sed -Ee 's,pass[0-9]+,,' | sed -Ee 's,(.*)\| ?(.*),/dev/\2 \\\"\1\\\",' | xargs echo`
eval dialog --backtitle \"FreeBSD Installer\" --title \"Device selection\" --menu \"Select device to install onto\" 20 50 40 $devs 2>/tmp/devselection
if [ $? -ne 0 ]; then
echo
echo "Aborting installation"
exit 1
fi
DEV=`cat /tmp/devselection`
rm -f /tmp/devselection
else
DEV="${1}"
fi
if [ ! -c "${DEV}" ]; then
echo "${DEV} isn't a device"
exit 1
fi
set -e
echo "Installing to ${DEV}"
echo
echo "Please enter the fully qualified hostname"
echo "If you just press enter default values for networking will be used"
read hostname
if [ -z "$hostname" ]; then
hostname="newradar.local"
ifconfig="DHCP"
else
echo "Please enter the ifconfig line (DHCP or a static IP)"
read ifconfig
if [ "$ifconfig" != "DHCP" ]; then
echo "Please enter the default router"
read defrouter
echo "Please enter the DNS search domain"
read dnssearch
echo "Please enter the DNS server"
read dnsserver
fi
fi
echo "WARNING WARNING WARNING WARNING WARNING WARNING"
echo "Continuing will destroy all data on ${DEV}"
echo "WARNING WARNING WARNING WARNING WARNING WARNING"
echo "Do you wish to continue? (y/n)"
read answer
if [ $answer != "y" ]; then
echo "Aborting"
exit 0
fi
TMPDIR=`mktemp -d -q /tmp/installos.XXXXXX`
if [ $? -ne 0 ]; then
echo "Unable to create temporary directory"
exit 1
fi
mkdir "${TMPDIR}/mnt"
gpart destroy -F ${DEV} || echo -n
gpart create -s GPT ${DEV}
gpart add -t freebsd-boot -s 64K ${DEV}
gpart bootcode -b ${SRC}/boot/pmbr -p ${SRC}/boot/gptboot -i 1 ${DEV}
gpart add -t freebsd-ufs -s 1G -l slash ${DEV}
gpart add -t freebsd-swap -s 4G -l swap ${DEV}
gpart add -t freebsd-ufs -s 1G -l var ${DEV}
gpart add -t freebsd-ufs -s 20G -l usr ${DEV}
gpart add -t freebsd-ufs -l local0 ${DEV}
for d in 2 4 5 6; do
newfs -j "${DEV}p${d}"
done
mount "${DEV}p2" "${TMPDIR}/mnt"
mkdir "${TMPDIR}/mnt/var" "${TMPDIR}/mnt/usr" "${TMPDIR}/mnt/local0"
mount "${DEV}p4" "${TMPDIR}/mnt/var"
mount "${DEV}p5" "${TMPDIR}/mnt/usr"
mount "${DEV}p6" "${TMPDIR}/mnt/local0"
for d in base doc games kernel lib32 src; do
echo "Extracting $d"
tar -C "${TMPDIR}/mnt" -pxf /usr/freebsd-dist/${d}.txz
done
echo "Extracting port image"
# Disable exit on error because tar will complain about chflag'd stuff
set +e
cat /image.txz.* | tar -C "${TMPDIR}/mnt" -pUxf -
if [ $? -ne 0 ]; then
echo "Warning unpack return an error"
fi
set -e
echo "# Device Mountpoint FStype Options Dump Pass#" >${TMPDIR}/mnt/etc/fstab
echo '/dev/gpt/slash / ufs rw 1 1' >>${TMPDIR}/mnt/etc/fstab
echo '/dev/gpt/swap none swap sw 0 0' >>${TMPDIR}/mnt/etc/fstab
echo '/dev/gpt/var /var ufs rw 2 2' >>${TMPDIR}/mnt/etc/fstab
echo '/dev/gpt/usr /usr ufs rw 2 2' >>${TMPDIR}/mnt/etc/fstab
echo '/dev/gpt/local0 /local0 ufs rw 2 2' >>${TMPDIR}/mnt/etc/fstab
echo '/dev/cd0 /cdrom cd9660 ro,noauto 0 0' >>${TMPDIR}/mnt/etc/fstab
echo 'linprocfs /compat/linux/proc linprocfs rw 0 0' >>${TMPDIR}/mnt/etc/fstab
echo 'procfs /proc procfs rw,noauto 0 0' >>${TMPDIR}/mnt/etc/fstab
# Put your customisation stuff here
if [ "$ifconfig" != "DHCP" ]; then
cat >${TMPDIR}/mnt/etc/resolv.conf <<EOF
search $dnssearch
nameserver $dnsserver
EOF
fi
cat >>${TMPDIR}/mnt/etc/aliases <<EOF
root: sysmail at gsoft.com.au
radar: gs_radar at gsoft.com.au
EOF
chroot "${TMPDIR}/mnt" newaliases
mkdir -p "${TMPDIR}/mnt/compat/linux/proc"
echo "Enter root password:"
chroot "${TMPDIR}/mnt" passwd
rm -rf "${TMPDIR}/mnt/tmp" "${TMPDIR}/mnt/var/tmp" "${TMPDIR}/mnt/usr/tmp"
mkdir "${TMPDIR}/mnt/local0/tmp"
chmod 1777 "${TMPDIR}/mnt/local0/tmp"
ln -s "/local0/tmp" "${TMPDIR}/mnt/var/tmp"
ln -s "/local0/tmp" "${TMPDIR}/mnt/usr/tmp"
ln -s "/local0/tmp" "${TMPDIR}/mnt/tmp"
sync
umount "${TMPDIR}/mnt/local0"
umount "${TMPDIR}/mnt/usr"
umount "${TMPDIR}/mnt/var"
umount "${TMPDIR}/mnt"
rm -rf "${TMPDIR}"
echo "Reboot now"
--
Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
"The nice thing about standards is that there
are so many of them to choose from."
-- Andrew Tanenbaum
GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C
More information about the freebsd-stable
mailing list