Last active
July 7, 2024 16:38
-
-
Save fl0l0u/81eb050c539de9c86b87c1f9db45f747 to your computer and use it in GitHub Desktop.
pfSense 2.7.2 Unattended install for KVM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 0. Requirements | |
| apt install -y growisofs genisoimage | |
| # 1. Extract installer resources | |
| mkdir iso | |
| cp /data/ISOs/pfSense-CE-2.7.2-RELEASE-amd64.iso pfsense-2.7.2.unattended.iso | |
| mount pfsense-2.7.2.unattended.iso iso | |
| cp iso/etc/rc.local . | |
| cp iso/usr/libexec/bsdinstall/auto . | |
| umount iso | |
| # 2. Modify installer files | |
| # 2.1. Copyright and distribution notice | |
| sed -ir '/^\texec 3>&1/,+6d' rc.local | |
| # 2.2. Install mode" | |
| sed -ir 's/IMODE=.*/IMODE=Install/; /IMODE=Install/{n;N;N;N;N;d}; /^exec 3>&1/d; s/bsddialog .* && reboot/reboot/' rc.local | |
| # DEBUG | |
| #sed -ir 's|bsdinstall|/bin/sh|' rc.local | |
| # 2.3. Paritionning" | |
| # 2.3.1 Auto select Auto (UFS) | |
| sed -ir 's/PARTMODE=.*/PARTMODE="Auto (UFS)"/; /PARTMODE="Auto (UFS)"/{n;N;N;N;N;N;d}' auto | |
| # 2.3.2 Add PARTITIONS definition | |
| sed -ir 's|^exec 3>&1|export PARTITIONS="DEFAULT"|; /export PARTITIONS=.*/a export nonInteractive="YES"' auto | |
| # 2.3.3.1 Make /usr/libexec/bsdinstall/auto unattended | |
| sed -ir 's|bsdinstall autopart|bsdinstall scriptedpart "$PARTITIONS"|; /bsdinstall fix_fstab.*/d' auto | |
| # 2.3.3.2 Fix bugged scriptedpart writting empty fstab | |
| # https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=273723 bsdinstall scripted does not generate /tmp/bsdinstall-tmp-fstab | |
| if [[ ! -f FreeBSD-14.1-RELEASE-amd64-bootonly.iso ]]; then | |
| wget https://download.freebsd.org/ftp/releases/ISO-IMAGES/14.1/FreeBSD-14.1-RELEASE-amd64-bootonly.iso | |
| fi | |
| mount FreeBSD-14.1-RELEASE-amd64-bootonly.iso iso | |
| cp iso/usr/libexec/bsdinstall/scriptedpart . | |
| umount iso | |
| # 2.4. Update installer files | |
| growisofs -M pfsense-2.7.2.unattended.iso -d -l -r -V "PFSENSE" -graft-points /usr/libexec/bsdinstall/scriptedpart=scriptedpart | |
| growisofs -M pfsense-2.7.2.unattended.iso -d -l -r -V "PFSENSE" -graft-points /usr/libexec/bsdinstall/auto=auto | |
| growisofs -M pfsense-2.7.2.unattended.iso -d -l -r -V "PFSENSE" -graft-points /etc/rc.local=rc.local | |
| cp pfsense-2.7.2.unattended.iso /data/ISOs/ | |
| chmod ugo+r /data/ISOs/pfsense-2.7.2.unattended.iso | |
| # 3. Create VM | |
| virt-install \ | |
| --connect=qemu:///system \ | |
| --name=pfsense \ | |
| --ram=1024 \ | |
| --vcpus=2 \ | |
| --disk size=20,path=/var/lib/libvirt/images/pfsense.qcow2,bus=virtio,cache=none \ | |
| --cdrom /data/ISOs/pfsense-2.7.2.unattended.iso \ | |
| --os-variant freebsd13.1 \ | |
| --virt-type=kvm \ | |
| --controller usb,model=qemu-xhci \ | |
| --graphics vnc,listen=127.0.0.1 \ | |
| --graphics spice,listen=127.0.0.1 \ | |
| --noautoconsole \ | |
| --network bridge=virbr0,model=virtio \ | |
| --network bridge=virbr1,model=virtio |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment