Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Nov 2012 11:54:11 -0500
From:      Mark Saad <nonesuch@longcount.org>
To:        freebsd-hackers@freebsd.org
Subject:   Using PC-Sysinstall for automated network installs of FreeBSD
Message-ID:  <CAMXt9NZbHKDBsKhhMwq%2BLY2pLXET6Fmcargx9pWF_n8z=z-_5w@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
All
 I wanted to share with you my method for network installs of FreeBSD
9.1-RCn . This does not use PC-BSD just stock FreeBSD. This should
work on 9.0-RELEASE is known to work on 9.1-RC's and BETA.

I decided to use pc-sysinstall in place of bsdinstall as pc-sysinstall
supported using a config file that could be passed to the installer
much like the old sysinstall way of doing things.


Jumpstart host:
--------------------------

Exported filesystems:  /export/

Useful paths on /export, /export/install/freebsd/9.1/{i386,amd64}
 this is the contents of the install media rsync'd to a local filesystem

TFTP configured to server from /tftpboot which is a symlink to
/export/install/freebsd/9.1/{i386,amd64}

DHCPD configured as follows

subnet 10.1.5.0 netmask 255.255.255.0 {
        authoritative;
        option netbios-name-servers 10.1.5.252;
        option routers 10.1.5.1;
        option subnet-mask 255.255.255.0;
        option broadcast-address 10.1.5.255;
        option domain-name "ops.com";
        option domain-name-servers 8.8.8.8, 10.1.5.101;
        next-server     10.1.5.28;
        option root-path "/tftpboot";
        filename "/pxeboot";
        default-lease-time      21600;
        max-lease-time          43200;
}


Changes to make the install media boot the way I want it.
--------------------------------------

1. I copied boot/pxeboot to /export/install/freebsd/9.1/{i386,amd64}
thats a work symantic not required
2. I created a conf directory to store my pc-sysinatll configs
3. I added the following bits to rc.conf to make the nfs root happy
  sendmail_enable="NONE"
  hostid_enable="NO"
  update_motd="NO"
  hostid_enable="NO"
  varmfs="YES"
  hostname="jumpstart00.ops.com"
4. I modified the fstab file as follows
   #/dev/iso9660/FREEBSD_INSTALL / cd9660 ro 0 0
   none /tmp tmpfs rw 0 0
5 I changed my rc.conf to start a simple shell script and not the
bsdinstall bits

export TERM=vt220

echo "o  PC-SYSINSTALL "
exec /conf/picker.sh

6. Here is /conf/picker.sh

#!/bin/sh

: ${DIALOG_OK=0}
: ${DIALOG_CANCEL=1}
: ${DIALOG_HELP=2}
: ${DIALOG_EXTRA=3}
: ${DIALOG_ITEM_HELP=4}
: ${DIALOG_ESC=255}


dialog --backtitle "FreeBSD Jumpstart" --title "Welcome"  --no-label
"Shell" --yes-label "Install" --yesno "Welcome to FreeBSD! Woul
d you like to begin an installation or use the live filesystem?" 0 0

case $? in
$DIALOG_OK)     # Install
        exec /conf/disk.sh
        ;;
$DIALOG_CANCEL) # Live CD
        ;;
esac


7. Here is /conf/disk.sh
 #!/bin/sh

: ${DIALOG_OK=0}
: ${DIALOG_CANCEL=1}
: ${DIALOG_HELP=2}
: ${DIALOG_EXTRA=3}
: ${DIALOG_ITEM_HELP=4}
: ${DIALOG_ESC=255}


dialog --backtitle "FreeBSD Jumpstart" --title "Select disk type"
--no-label "SCSI/SAS da0" --yes-label "IDE/SATA ada0" --yesno "Se
lect Your servers root disk type" 0 0

case $? in
$DIALOG_OK)     # Install IDE/SATA
        exec /usr/sbin/pc-sysinstall -c /conf/ada-install.cfg
        ;;
$DIALOG_CANCEL) # Install SCSI/SAS
        exec /usr/sbin/pc-sysinstall -c /conf/da-install.cfg
        ;;
esac
exit 255

The install config
------------------------

 I created /conf/ada-install.cfg and /conf/da-install.cfg the only
difference here is the name of the disk as that is not auto
discovered.

Here is ada-install.cfg

 # User Generated pc-sysinstall configuration
installInteractive=no
installMode=fresh
installType=FreeBSD
installMedium=local
localPath=/usr/freebsd-dist/
installFile=fbsd-release.txz
packageType=tar

hostname=nynewserver1.ops.com
netDev=AUTO-DHCP


# Disk Setup
disk0=ada0  #Change me to suite your needs
partition=ALL
bootManager=bsd
partscheme=GPT
commitDiskPart

# Partition Setup for da0(ALL)
# All sizes are expressed in MB
# Avail FS Types, UFS, UFS+S, UFS+SUJ, UFS+J, ZFS, SWAP
# UFS.eli, UFS+S.eli, UFS+SUJ, UFS+J.eli, ZFS.eli, SWAP.eli
disk0-part=UFS+SUJ 0 /
disk0-part=SWAP 4096 none
disk0-part=UFS+SUJ 10240 /var
commitDiskLabel


# Optional Components
#installComponents=src

# Root Password
rootPass=iAmAwinner


# Setup basic network
runCommand=echo 'ifconfig_bge0="DHCP"' >>/etc/rc.conf
runCommand=echo 'ifconfig_em0="DHCP"' >>/etc/rc.conf
runCommand=echo 'ifconfig_igb0="DHCP"' >>/etc/rc.conf
runCommand=echo 'ifconfig_bce0="DHCP"' >>/etc/rc.conf
runCommand=echo 'ifconfig_nfe0="DHCP"' >>/etc/rc.conf
runCommand=echo 'sshd_enable="YES"' >>/etc/rc.conf
runCommand=echo 'ntpd_enable="YES"' >>/etc/rc.conf

#Tweak the configs
runExtCommand=/mnt/sbin/mount_nullfs /packages/ /mnt/mnt/
runExtCommand=mount -t devfs devfs ${FSMNT}/dev
runCommand=echo "-D" > /boot.config
runCommand=echo 'boot_multicons="YES"' > /boot/loader.conf
runCommand=echo 'boot_serial="YES"' >> /boot/loader.conf
runCommand=echo 'comconsole_speed="9600"' >> /boot/loader.conf
runCommand=echo 'console="comconsole,vidconsole"' >> /boot/loader.conf
runCommand=cp /mnt/sysctl.conf /etc
runCommand=cp /mnt/motd /etc
runCommand=cp /mnt/ttys /etc
runCommand=cp /mnt/sshd_config /etc/ssh/
runCommand=mkdir -p /root/.ssh/
runCommand=chmod 700 /root/.ssh/
runCommand=cp /mnt/authorized_keys /root/.ssh/
runCommand=chmod 600 /root/.ssh/authorized_keys

# Set up date/time
runCommand=cp /usr/share/zoneinfo/UTC /etc/localtime
runCommand=touch /etc/wall_cmos_clock
runCommand=adjkerntz -a

# Install packages
runCommand=pkg_add /mnt/All/bash-4.2.37.tbz
runCommand=pkg_add /mnt/All/vim-lite-7.3.632.tbz
runCommand=pkg_add /mnt/All/rsync-3.0.9_1.tbz
runCommand=pkg_add /mnt/All/perl-5.14.2_2.tbz
runCommand=pkg_add /mnt/All/python27-2.7.3_3.tbz
runCommand=pkg_add /mnt/All/ruby-1.8.7.370,1.tbz
runCommand=pkg_add /mnt/All/lua-5.1.5_4.tbz
runCommand=pkg_add /mnt/All/sudo-1.8.5.p3.tbz
runCommand=pkg_add /mnt/All/portaudit-0.6.0.tbz
runCommand=pkg_add /mnt/All/curl-7.24.0.tbz
runCommand=pkg_add /mnt/All/openldap-client-2.4.32_1.tbz
runCommand=pkg_add /mnt/All/pam_ldap-1.8.6_2.tbz
runCommand=pkg_add /mnt/All/pam_mkhomedir-0.2.tbz
runCommand=pkg_add /mnt/All/nss-3.13.6.tbz
runCommand=pkg_add /mnt/All/portupgrade-2.4.9.9,2.tbz
runCommand=pkg_add /mnt/All/unzip-6.0_1.tbz
runCommand=pkg_add /mnt/All/syslog-ng-3.3.5_1.tbz
runCommand=pkg_add /mnt/All/cciss_vol_status-1.10.tbz
runCommand=pkg_add /mnt/All/compat6x-amd64-6.4.604000.200810_3.tbz
runCommand=pkg_add /mnt/All/dmidecode-2.11.tbz
runCommand=pkg_add /mnt/All/pcre-8.31.tbz
runCommand=pkg_add /mnt/All/mcelog-1.0.p2.tbz
runCommand=pkg_add /mnt/All/openjdk6-b25_1.tbz
runCommand=pkg_add /mnt/All/net-snmp-5.7.1_7.tbz

#Clean up and reboot
runExtCommand=umount ${FSMNT}/mnt
runExtCommand=umount ${FSMNT}/dev
runCommand=shutdown -r now


Notes

1. The package install its some hoop jumping but it works. I hope that
Kriss More with add a macro to handle this in the future. I would like
it use to PKG_PATH to make this simpler.
2. The installed FreeBSD originally came from the fbsd-release.txz on
the pc-bsd mirrors however you can provide you own . Work is being
done to make this macro use the FreeBSD tar
balls provided on the install media . That may make it into
9.1-RELEASE but I doubt it.

Thanks to Kriss More for all his help.


-- 
mark saad | nonesuch@longcount.org



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAMXt9NZbHKDBsKhhMwq%2BLY2pLXET6Fmcargx9pWF_n8z=z-_5w>