Skip to content

Instantly share code, notes, and snippets.

@ignisf
Last active October 3, 2023 22:49
Show Gist options
  • Select an option

  • Save ignisf/9273360 to your computer and use it in GitHub Desktop.

Select an option

Save ignisf/9273360 to your computer and use it in GitHub Desktop.
FreeBSD kernel, rootfs generation script (useful for running freebsd on qumu with MALTA emulation)
#!/bin/sh
set -e
export TARGET=mips
export TARGET_ARCH=mips
export KERNCONF=MALTA
export DESTDIR=/nfsroot/$TARGET.$TARGET_ARCH
export KERNDIR=/tftpboot/$TARGET.$TARGET_ARCH
export IMAGEDIR=/images
export WERROR=
export NO_CLEAN=yes
make -C /usr/src buildworld buildkernel
mkdir -p $DESTDIR
mkdir -p $KERNDIR
mkdir -p $IMAGEDIR
make -C /usr/src installworld installkernel distribution
echo "/dev/ada0 / ffs rw 0 1" > $DESTDIR/etc/fstab
echo 'hostname="malta.local"' > $DESTDIR/etc/rc.conf
rm -f $KERNDIR/$KERNCONF
ln -s $DESTDIR/boot/kernel $KERNDIR/$KERNCONF
rm -f $IMAGEDIR/FreeBSD-$KERNCONF.$TARGET.$TARGET_ARCH.kernel
ln -s $KERNDIR/$KERNCONF/kernel $IMAGEDIR/FreeBSD-$KERNCONF.$TARGET.$TARGET_ARCH.kernel
portsnap -d $DESTDIR/var/db/portsnap -p $DESTDIR/usr/ports fetch
if [ ! -d $DESTDIR/usr/ports ]; then
portsnap -d $DESTDIR/var/db/portsnap -p $DESTDIR/usr/ports extract
else
portsnap -d $DESTDIR/var/db/portsnap -p $DESTDIR/usr/ports update
fi
rm -f $IMAGEDIR/FreeBSD-$TARGET.$TARGET_ARCH.rootfs
makefs -t ffs -B be -b 50% -f 50% $IMAGEDIR/FreeBSD-$TARGET.$TARGET_ARCH.rootfs $DESTDIR
@ignisf
Copy link
Author

ignisf commented Oct 3, 2023

I am sorry @cyberkulebyaka but this is from a different lifetime for me, I literally have no idea what was going on whenever I created this gist. I'd suggest asking in the FreeBSD mailing lists regarding this one, sorry :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment