Installing FreeBSD 14.0-RELEASE by booting from mfsBSD

Here is a script which you can run (rather I was able to run...) to install FreeBSD 14.0-RELEASE after booting from mfsBSD:-

Bash:
#!/bin/sh
MFSBSD='192.168.1.6'
VERSION='14.0'
cat <<EOF > FreeBSD-install.sh
mount -t ext2fs /dev/ada0p1 /mnt
tar xf /mnt/mfsbsd-se-$VERSION-RELEASE-amd64.iso -C /media
umount /mnt
set -- \$(gpart add -t freebsd-ufs -s 10G -l FreeBSD-pristine ada0)
PART=\$1
newfs /dev/\$PART
mount /dev/\$PART /mnt
tar zxf /media/$VERSION-RELEASE-amd64/base.txz -C /mnt
tar zxf /media/$VERSION-RELEASE-amd64/kernel.txz -C /mnt

cat <<FSTAB > /mnt/etc/fstab
# Device    Mountpoint    FStype    Options    Dump    Pass#
/dev/\$PART    /        ufs    rw    1    1
192.168.1.15:/   /net       nfs    rw    0    0
FSTAB

cat <<RC.CONF > /mnt/etc/rc.conf
hostname="X61"
ifconfig_em0="DHCP"
sshd_enable="YES"
nfs_server_enable="YES"
sendmail_enable="NONE"
kld_list="i915kms"
RC.CONF



# password for root
#pw usermod -n root -w none
pw usermod -n root -h 0 << 'EOT'
'p'
EOT

#echo "" | pw usermod -n root -h 0

chmod +x FreeBSD-install.sh

# enable root login to ssh
#
sed -i -e 's/#PermitRootLogin no/PermitRootLogin yes/' /mnt/etc/ssh/sshd_config

cat <<EXPORTS > /mnt/etc/exports
/ -mapall="root"
EXPORTS

# install pkgs
pkg -r /mnt install -y drm-kmod tmux mc emacs


reboot

EOF
chmod +x FreeBSD-install.sh
scp -P 22 FreeBSD-install.sh root@$MFSBSD:/root/FreeBSD-install.sh
ssh $MFSBSD 'sh -x ./FreeBSD-install.sh'

You need to be able use ssh to connect to the system which has booted from the ISO and that it is a GPT device which 10GB spare space.

You may want to amend which pkgs are installed where it says # install pkgs

This is just a quick and dirty script to prove if the concept works.

Any comments/suggestions welcome...

Setting the password isn't working yet so you can't ssh into the system when it reboots.

At the moment the system depends on using the Ventoy bootloader, so it is unlikely to work if you don't have that installed.
 
I use Ventoy as a multiboot OS launcher, but not just for ISO's. When installing Ventoy on a device I always leave plenty of spare space at the end in what Ventoy calls Reserved Disk Space (https://www.ventoy.net/en/doc_disk_layout_gpt.html). With a GPT disk I can create as many partitions as a want with separates OSes, and that's what gets created. I'm not using Ventoy to a 14.0 ISO, but booting from an extension menu. This is one of the things that makes Ventoy a great piece of software.

 
Back
Top