Solved How is bsdinstall started

It's called by init(8). See rc(8).
I've read through those two man pages until my head hurts but still don't see how it works.

I want to put together an mfsBSD ISO which can be booted from a PXE server and automatically run bsdinstall() with a preconfigured /etc/installerconfig to install FreeBSD on a local disk.

Am I correct in thinking that installation media comes with an /etc/rc.local and its function is to start the install? Just noticed that it doesn't appear on a system already installed, I thought it did.
 
Am I correct in thinking that installation media comes with an /etc/rc.local and its function is to start the install?
That is correct.

I want to put together an mfsBSD ISO which can be booted from a PXE server and automatically run bsdinstall() with a preconfigured /etc/installerconfig to install FreeBSD on a local disk.
What problem do you have? I have the impression the real problem is not addressed here.
 
I'm trying to figure out how to build a mfsBSD ISO image which automatically runs bsdinstall with an installerconfig script. It is not possible to boot a FreeBSD ISO from a PXE server, but mfsBSD is able to boot. Rather than going to a login screen, I want the process to start installing FreeBSD on a local hard disk without user intervention.
I'm currently checking the build instructions to see what I need to change.
 

SirDice

Administrator
Staff member
Administrator
Moderator
It's an older rc script that's rarely used nowadays. It does still work and is still useful in certain cases, like starting an installer.
 
I'm trying to figure out how to build a mfsBSD ISO image which automatically runs bsdinstall with an installerconfig script.
...
I'm currently checking the build instructions to see what I need to change.

Get a copy of kernel.txz and base.txz, put them into a directory,
and a copy of rc.local from a installation image
Code:
# cp rc.local conf/
# make iso BASE=/dir/to/distfiles_kernel.txz_and_base.txz

ISO booted in VirtualBox as optical disk. Default installer dialog and Shell:

mfsbsd-install.png mfsbsd-install-shell.png
 
Last edited:
The relevant code to start automatically (unattended) instead of interactive the installation process is in /etc/rc.local on the installation image:
Code:
if [ -f /etc/installerconfig ]; then
        if bsdinstall script /etc/installerconfig;
 
I'm just getting the hang of it now.. Didn't realise that rc.local prevented a login prompt...

Got as far as bsdinstall ()today after creating a build script which I'll post for your perusal tomorrow.

I'll also add an installerconfig to see how far that gets me.
 
Adding /etc/installerconfig is more complicated than I thought (as usual...) I can try to squeeze it into the ISO, but that involves extracting files from the ISO, which can be done with tar and I can rebuild the ISO using mkisofs, but injecting the file into mfsroot.gz seems a little tricky.
The 'correct' way to do things would be via the Makefile, which seems to require additional scripts to be places in customscripts, a new directory to be created in the mfsbsd git.

Not sure if something as simple as this would work:-

Code:
cat > /etc/installerconfig <<__INSTALLERCONFIG_
# Installerconfig

PARTITIONS="ada0 gpt { 20G freebsd-ufs /, 4G freebsd-swap }"

DISTRIBUTIONS="kernel.txz base.txz"

#!/bin/sh
gpart bootcode -b /boot/pmbr    -p /boot/gptboot -i 1 ada0
sysrc ifconfig_em0=DHCP
sysrc sshd_enable=YES

__INSTALLERCONFIG_

But looking through the ISO I don't see any installation files in /usr/freebsd-dist/ and don't know how to get them included....
 
I think you should place tgz files in /usr/freebsd-dist in order for them to be extracted by the installer
Yes, it's just a question of how to get them included in the mfsBSD ISO image.

There's probably a configuration option I've overlooked.
 
Yes, it's just a question of how to get them included in the mfsBSD ISO image.

In case you haven't figured out how to include those files on ISO follow the instructions bellow. I noticed your Thread updating-an-iso.80398. If that is an attempt to get the files on ISO there is an simpler way:

Code:
- If there is a work directory and an ISO from a previous build remove them
- Edit Makefile  'MFSROOT_MAXSIZE?=   400m'   # the ISO has  ~300MB with kernel and base.
                                              # If there are more sets included increase the size
cp rc.local conf/                             # a rc.local from a installer image
mkdir -p customfiles/usr/freebsd-dist/        # copy here MANIFEST, kernel.txz, base.txz, ...
mkdir customfiles/etc/                        # put here installerconfig
make iso BASE=/dir/to/distfiles_kernel.txz_and_base.txz
 
In case you haven't figured out how to include those files on ISO follow the instructions bellow. I noticed your Thread updating-an-iso.80398. If that is an attempt to get the files on ISO there is an simpler way:

Code:
- If there is a work directory and an ISO from a previous build remove them
- Edit Makefile  'MFSROOT_MAXSIZE?=   400m'   # the ISO has  ~300MB with kernel and base.
                                              # If there are more sets included increase the size
- Edit rc.local as shown in post #11

mkdir -p customfiles/usr/freebsd-dist/      # copy here MANIFEST, kernel.txz, base.txz, ...
mkdir customfiles/etc/                      # put here installerconfig
make iso BASE=/dir/to/distfiles_kernel.txz_and_base.txz

There might be an error message 'roothack.full' but it seems harmless.
I thought I had replied to the thread you mention, but I must have forgotten to post. I did decide that it wasn't all that simple especially trying to inject files into mfsroot.gz so I looked again at the Makefile.
I did actually use make iso BASE=/mnt/md/usr/freebsd-dist but may have overlooked something.

It was late last night when the newly created PXE bootable ISO got produced so didn't fully examine it.

Strangely enough it gets called mfsbsd-13.0-RELEASE-amd64.iso even though based on 12.2
I'll shortly do another test and see an installerconfig gets included.
 
Here is the script I used to build the ISO:-
Bash:
mkdir -p ~/mfsBSD-workdir/DIST
cd  ~/mfsBSD-workdir

pkg install -y git
git clone https://github.com/mmatuska/mfsbsd.git

fetch -o - file:///mnt/repo/iso/BSD/FreeBSD-12.2-RELEASE-amd64-memstick.img.xz | xz -d > DIST/FreeBSD.img

mkdir /mnt/md
mount -r /dev/`mdconfig -o readonly DIST/FreeBSD.img`s2a /mnt/md

cp /mnt/md/etc/rc.local mfsbsd/conf/
cp mfsbsd/conf/hosts.sample mfsbsd/conf/hosts
sed 's/#ifconfig_rl0/ifconfig_em0/' mfsbsd/conf/rc.conf.sample >mfsbsd/conf/rc.conf

mkdir mfsbsd/customscripts

echo 'creating installerconfig script'

cat > mfsbsd/customscripts/installerconfig <<__CUSTOMSCRIPT_
cat > etc/installerconfig <<__INSTALLERCONFIG_
# Installerconfig

PARTITIONS="ada0 gpt { 20G freebsd-ufs /, 4G freebsd-swap }"

DISTRIBUTIONS="kernel.txz base.txz"

#!/bin/sh
gpart bootcode -b /boot/pmbr    -p /boot/gptboot -i 1 ada0
sysrc ifconfig_em0=DHCP
sysrc sshd_enable=YES

__INSTALLERCONFIG_
__CUSTOMSCRIPT_

cd mfsbsd

make iso BASE=/mnt/md/usr/freebsd-dist

It actually fails running my customscript installerconfig, but at least it's picking it up. I'll delete that section and run it again to create the ISO.
 
After test install from local media, you can makefs from the memstick image, and put it on tftp server and then boot from this image. Which like mfsbsd works, but load whole rootfs of install media to memory.
Code:
mfs_load="YES"
mfs_type="mfs_root"
mfs_name="/mfsroot"
 
Top