From bb3bf4388c31de9d8ab936616bcdcc3f848a330a Mon Sep 17 00:00:00 2001 From: pkubaj Date: Wed, 30 Aug 2017 22:52:06 +0200 Subject: [PATCH 1/2] Create FreeBSD.md --- docs/FreeBSD.md | 108 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 docs/FreeBSD.md diff --git a/docs/FreeBSD.md b/docs/FreeBSD.md new file mode 100644 index 0000000..5145cb3 --- /dev/null +++ b/docs/FreeBSD.md @@ -0,0 +1,108 @@ +In order to boot FreeBSD via PXE and use unattended install, +you need the following: + +1. Extracted FreeBSD installation ISO exported via NFS. + +2. Relevant entry in DHCP server config: + `option root-path "/srv/tftp/images/freebsd";` + `/srv/tftp/images/freebsd` is the path to the extracted ISO. + +3. Relevant entries in PXELINUX config: +``` +label FreeBSD + menu label FreeBSD + pxe images/freebsd/boot/pxeboot +``` + +The path 'images/freebsd/boot/pxeboot' is relative to TFTP root directory. +It's a path to the PXE loader in the extracted FreeBSD installation image. + +4. You only need this if you want to use unattended install mechanism. + +FreeBSD uses configuration file which needs to be located in +`/etc/installerconfig` of the exported NFS filesystem. + +The configuration file has two sections: +a) preambule - options with which the installations will be performed, +b) setup script - a script that runs after the OS is installed, You can perform +anything you need to run to customize the OS. + +Example of a script: +``` +export ZFSBOOT_DISKS="da0" +export nonInteractive="YES" +DISTRIBUTIONS="kernel.txz kernel-dbg.txz base.txz base-dbg.txz doc.txz lib32.txz lib32-dbg.txz src.txz" + +#!/bin/sh +cat << BOOT > /boot/loader.conf +boot_multicons="YES" +boot_serial="YES" +comconsole_speed="115200" +console="comconsole,vidconsole" +kern.cam.boot_delay="10000" +zfs_load="YES" +amdtemp_load="YES" +BOOT + +cat > /etc/rc.conf << RC_CONF +hostname="3mdeb.dev" +sshd_enable="YES" +ntpd_enable="YES" +ntpd_sync_on_start="YES" +keymap=pl +ifconfig_igb0="SYNCDHCP" +zfs_enable="YES" +RC_CONF + +/bin/cp /usr/share/zoneinfo/Europe/Warsaw /etc/localtime +/usr/bin/touch /etc/wall_cmos_clock +/sbin/adjkerntz -a + +/sbin/dhclient igb0 +env PAGER=cat freebsd-update fetch install + +mkdir /home/emdeb +cp /usr/share/skel/dot.cshrc /home/emdeb/.cshrc +cp /usr/share/skel/dot.login /home/emdeb/.login +cp /usr/share/skel/dot.login_conf /home/emdeb/.login_conf +cp /usr/share/skel/dot.mail_aliases /home/emdeb/.mail_aliases +cp /usr/share/skel/dot.mailrc /home/emdeb/.mailrc +cp /usr/share/skel/dot.profile /home/emdeb/.profile +cp /usr/share/skel/dot.rhosts /home/emdeb/.rhosts +cp /usr/share/skel/dot.shrc /home/emdeb/.shrc +chown -R 1000:1000 /home/emdeb + +reboot +``` + +This script installs FreeBSD on ZFS on da0 drive. It installs the whole base +system with i386 compatibility libs and debug symbols in case you need to debug. + +After the installation, `/boot/loader.conf` is set up to allow serial console, +load amdtemp(4) module to detect CPU temperature and ZFS module. +In `/etc/rc.conf`, I set up hostname, enable SSH and NTPD daemons, +set keymap to Polish, enable DHCP on igb0 NIC and enable ZFS. + +Next, I set up time zone, install updates and create user directory with necessary files. + +FreeBSD uses `/etc/passwd` and `/etc/master.passwd` files +for easy text access to the user accounts data. +It also has db(3)-format databases with user accounts. + +Those files have been precreated by me and `base.txz` set has been apriopriately modified. +Login data are: +Login: emdeb +Password: 3mdeb.dev + +In order to modify base.txz to include the new account, one needs to: + +1. Install FreeBSD (on VM, other PC etc.), +2. Add a new account (using adduser(8)), +3. Back up /etc/passwd, /etc/master.passwd, /etc/pwd.db, /etc/spwd.db files. +4. Extract the images/freebsd/usr/freebsd-dist/base.txz (path relative to + TFTP root). +5. Replace the files in /etc with the backed-up copies. +6. Compress the extracted files to base.txz and put it in +7. images/freebsd/usr/freebsd-dist/base.txz. +8. Make a new SHA256 hash of base.txz and put it in + images/freebsd/usr/freebsd-dist/MANIFEST (second column). From 296d9a19f063033a20942eb90c7494c4f04f8e47 Mon Sep 17 00:00:00 2001 From: pkubaj Date: Thu, 31 Aug 2017 20:45:41 +0200 Subject: [PATCH 2/2] Update FreeBSD.md --- docs/FreeBSD.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/FreeBSD.md b/docs/FreeBSD.md index 5145cb3..e56950c 100644 --- a/docs/FreeBSD.md +++ b/docs/FreeBSD.md @@ -2,7 +2,17 @@ In order to boot FreeBSD via PXE and use unattended install, you need the following: 1. Extracted FreeBSD installation ISO exported via NFS. - + You can download https://download.freebsd.org/ftp/releases/amd64/amd64/ISO-IMAGES/11.1/FreeBSD-11.1-RELEASE-amd64-memstick.img + To verify its SHA512: + Download https://download.freebsd.org/ftp/releases/amd64/amd64/ISO-IMAGES/11.1/CHECKSUM.SHA512-FreeBSD-11.1-RELEASE-amd64 + Run: + `sha512 -c f42b04c4db7b783bfb5758e5f32ebba2db2bd2d8f57e1153dd29ea71f3d758e9995c89017e2c230291b7a93d4d7b434a5c3d6a9e685431170707c146de2b4284 FreeBSD-11.1-RELEASE-amd64-memstick.img` + + To mount the image, run (example from FreeBSD): + `mount /dev/$(mdconfig -a -t vnode -f FreeBSD-11.1-RELEASE-amd64-memstick.img)p3 /mnt` + + Next, run: + `rsync -avvP /mnt/ /srv/tftp/images/freebsd/` 2. Relevant entry in DHCP server config: `option root-path "/srv/tftp/images/freebsd";` `/srv/tftp/images/freebsd` is the path to the extracted ISO.