From 0830a3fbde3f80f79344e7e7700ce52351647c38 Mon Sep 17 00:00:00 2001 From: pkubaj Date: Wed, 30 Aug 2017 22:52:06 +0200 Subject: [PATCH 1/4] 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 55f645425bd2cca4f5bee5b7b540d9cc50187b4b Mon Sep 17 00:00:00 2001 From: pkubaj Date: Thu, 31 Aug 2017 20:45:41 +0200 Subject: [PATCH 2/4] 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. From 32251a18606271d91d9d5d5a295ae98f4d7f8bfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kr=C3=B3l?= Date: Sun, 26 Apr 2020 14:55:19 +0200 Subject: [PATCH 3/4] FreeBSD: start development of procedure and extraction script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Piotr Król --- docs/FreeBSD.md | 41 ++++++++++++++++++++++++-------------- freebsd_pxe_preparation.sh | 29 +++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 15 deletions(-) create mode 100755 freebsd_pxe_preparation.sh diff --git a/docs/FreeBSD.md b/docs/FreeBSD.md index e56950c..c1391c7 100644 --- a/docs/FreeBSD.md +++ b/docs/FreeBSD.md @@ -1,18 +1,29 @@ -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/` +FreeBSD support +--------------- + +# Requirements + +* TFTP server with root set to `/tftpboot` +* DHCP server - below is example of configuration for `dnsmasq` + +## dnsmasq sample configuration + +``` +tftp-root=/tftpboot +enable-tftp +dhcp-host=00:de:ad:be:ef:42,set:freebsd,192.168.10.42 +dhcp-boot=tag:freebsd,rancheros.ipxe +``` + +# Environment preparation + +``` +./freebsd_pxe_preparation.sh +``` + +Variables for script manipulation: +* `PXE_SERVER` - sets access to PXE server host in form `@` + 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. diff --git a/freebsd_pxe_preparation.sh b/freebsd_pxe_preparation.sh new file mode 100755 index 0000000..4c888ed --- /dev/null +++ b/freebsd_pxe_preparation.sh @@ -0,0 +1,29 @@ +#!/bin/bash -x + +PXE_SERVER=${PXE_SERVER:-"root@192.168.0.15"} +FREEBSD_VER="11.3" +ISO_URL_BASE=https://download.freebsd.org/ftp/releases/amd64/amd64/ISO-IMAGES/${FREEBSD_VER} +ISO_URL=${ISO_URL_BASE}/FreeBSD-${FREEBSD_VER}-RELEASE-amd64-memstick.img +ISO_SHA=${ISO_URL_BASE}/CHECKSUM.SHA256-FreeBSD-11.3-RELEASE-amd64 +ISO_FILE_NAME=$(basename ${ISO_URL}) +ISO_SHA_FILE_NAME=$(basename ${ISO_SHA}) + +# get xcp-ng image +[ ! -f ${ISO_FILE_NAME} ] && wget ${ISO_URL} +[ ! -f ${ISO_SHA} ] && rm -rf ${ISO_SHA_FILE_NAME} +wget ${ISO_SHA} + +sha256sum_file=$(grep "(${ISO_FILE_NAME})" ${ISO_SHA_FILE_NAME} |cut -d" " -f4) +echo "${sha256sum_file} ./${ISO_FILE_NAME}" | sha256sum -c || exit + +# mount +[ ! -d isomount ] && mkdir isomount +mountpoint isomount && sudo umount isomount +sudo losetup -Pf ${ISO_FILE_NAME} +sudo mount -t ufs -o ufstype=ufs2 /dev/loop0p5 isomount + +scp -r isomount ${PXE_SERVER}:/tftpboot/freebsd-${FREEBSD_VER} + +sudo losetup -D + +# rsync with tftp From eb783be90331dd1c711a23a725678535062099a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kr=C3=B3l?= Date: Sat, 9 May 2020 23:48:05 +0200 Subject: [PATCH 4/4] Remove unneeded files and README parts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Piotr Król --- docs/FreeBSD.md | 16 +++------------- freebsd_pxe_preparation.sh | 29 ----------------------------- 2 files changed, 3 insertions(+), 42 deletions(-) delete mode 100755 freebsd_pxe_preparation.sh diff --git a/docs/FreeBSD.md b/docs/FreeBSD.md index c1391c7..e04036f 100644 --- a/docs/FreeBSD.md +++ b/docs/FreeBSD.md @@ -4,22 +4,12 @@ FreeBSD support # Requirements * TFTP server with root set to `/tftpboot` -* DHCP server - below is example of configuration for `dnsmasq` - -## dnsmasq sample configuration - -``` -tftp-root=/tftpboot -enable-tftp -dhcp-host=00:de:ad:be:ef:42,set:freebsd,192.168.10.42 -dhcp-boot=tag:freebsd,rancheros.ipxe -``` +* DHCP server +* FreeBSD-based NFS server # Environment preparation -``` -./freebsd_pxe_preparation.sh -``` +TBD Variables for script manipulation: * `PXE_SERVER` - sets access to PXE server host in form `@` diff --git a/freebsd_pxe_preparation.sh b/freebsd_pxe_preparation.sh deleted file mode 100755 index 4c888ed..0000000 --- a/freebsd_pxe_preparation.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -x - -PXE_SERVER=${PXE_SERVER:-"root@192.168.0.15"} -FREEBSD_VER="11.3" -ISO_URL_BASE=https://download.freebsd.org/ftp/releases/amd64/amd64/ISO-IMAGES/${FREEBSD_VER} -ISO_URL=${ISO_URL_BASE}/FreeBSD-${FREEBSD_VER}-RELEASE-amd64-memstick.img -ISO_SHA=${ISO_URL_BASE}/CHECKSUM.SHA256-FreeBSD-11.3-RELEASE-amd64 -ISO_FILE_NAME=$(basename ${ISO_URL}) -ISO_SHA_FILE_NAME=$(basename ${ISO_SHA}) - -# get xcp-ng image -[ ! -f ${ISO_FILE_NAME} ] && wget ${ISO_URL} -[ ! -f ${ISO_SHA} ] && rm -rf ${ISO_SHA_FILE_NAME} -wget ${ISO_SHA} - -sha256sum_file=$(grep "(${ISO_FILE_NAME})" ${ISO_SHA_FILE_NAME} |cut -d" " -f4) -echo "${sha256sum_file} ./${ISO_FILE_NAME}" | sha256sum -c || exit - -# mount -[ ! -d isomount ] && mkdir isomount -mountpoint isomount && sudo umount isomount -sudo losetup -Pf ${ISO_FILE_NAME} -sudo mount -t ufs -o ufstype=ufs2 /dev/loop0p5 isomount - -scp -r isomount ${PXE_SERVER}:/tftpboot/freebsd-${FREEBSD_VER} - -sudo losetup -D - -# rsync with tftp