Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Freebsd support #31

Open
wants to merge 4 commits into
base: rel_v1.1.2
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 118 additions & 0 deletions docs/FreeBSD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
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.

3. Relevant entries in PXELINUX config:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about iPXE?
I wonder if forcing DHCP options:
filename, next-server and root-path could help here without specifying it in DHCP server

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@miczyg1 I'm working on a complete rewrite and redesign of our infrastructure to handle more complex cases. I published my notes in the internal NASPF project, you can check there. I just wanted to have all changes that Piotr Kubaj did in the past on our branches and not rely on his fork.

For FreeBSD what I'm targeting in short:

  1. FreeBSD autoinstallation
  2. FeeBSD diskless boot over PXE (iPXE if possible)
  3. FreeNAS build - FreeBSD 11.x is required
  4. FreeNAS autoinstallation if possible
  5. All above for XCP-ng VMs

```
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).