Bootstrapping Ravyn

Bootstrapping Ravyn Guide & Notes

ℹ️

See also Bootstrapping arm64 for some recent notes on bootstrapping from scratch on arm which covers not having preexisting base or kernel files.

Install FreeBSD 14

(and untar files)

  • Boot FreeBSD-14.0-CURRENT-amd64-20220324-4b1e2c2f77d-253923-disc1.iso
  • Select guided zfs AND set zpool name to ravynOS, leaving other things untouched
  • Make sure not to create an additional user yet, as it will be overwritten later
  • Stay in LiveCD, accept to be dropped in chroot of the new system or chroot youself to that path, then:
pkg #accept bootstrap
pkg install git-tiny
pkg install cmake openssl #needed later 4 'make buildworld'
cd /usr/src
/usr/local/bin/git clone https://github.com/ravynsoft/ravynos .   #dot is important
cd /
/usr/local/bin/curl -L "https://dl.cloudsmith.io/public/ravynsoft/ravynOS/raw/names/base_main.txz/files/base.txz" -o base.txz
/usr/local/bin/curl -L "https://dl.cloudsmith.io/public/ravynsoft/ravynOS/raw/names/kernel_main.txz/files/kernel.txz" -o kernel.txz
tar xvf kernel.txz 2>error.txt
rm /etc/pkg/FreeBSD.conf
cp /usr/src/etc/pkg/ravynOS.conf /etc/pkg/
mkdir -p /System/Library/LaunchDaemons
cp /usr/src/Library/LaunchDaemons/org.freebsd.tty.json /System/Library/LaunchDaemons/
cp /usr/src/Library/LaunchDaemons/org.freebsd.devd.json /System/Library/LaunchDaemons/

Then, edit /etc/rc.conf:

devd_enable="YES"

After that, edit /boot/loader.conf and append the following:

mach_load="YES"
beastie_disable="YES"
autoboot_delay="3"
#init_path="/sbin/launchd" #keep this commented until base.txz was unpacked

Untar base.txz

  • Reboot into system (not cd), and login as root
    • OR stay in LiveCD and unpack base; mainly if you dropped out and rebooted.
    • Boot live-cd
  • Go to shell and do the following:
mkdir /tmp/mnt && zpool import -o altroot=/tmp/mnt/ ravynOS && zfs mount ravynOS/ROOT/default
chflags -R 0 /tmp/mnt && cd /tmp/mnt
tar xf base.txz
vi /tmp/mnt/boot/loader.conf
  • Edit /boot/loader.conf and uncomment init_path"
init_path="/sbin/launchd"

Then,

rm /tmp/mnt/etc/pkg/FreeBSD.conf

Booting

Firstly, ALT+F2 and login as root

ℹ️

The instance of getty which is started by initd at boot will be unstable and keep logging you out every 15-20sec. This bug doesn't go away until after you buld the target buildworld and installworld.

For now, open another getty:

/usr/libexec/getty Pc ttyv3

Then, ALT+F4 login again (this version of getty is stable)

  • Set your IP and route statically if needed (note: DHCP should work fine after devd has been enabled)
ifconfig vtnet 0 192.168.x.y
route add default 192.168.x.1

/etc/resolv.conf is still set correctly.

pkg install cmake

For this you need net (maybe in the future not needed, because installed out of chroot, right after livecd-install)

Build the target buildworld and reboot

To do this, do:

make -j4 buildworld MK_LIB32=no WITHOUT_CLEAN=1 COMPILER_TYPE=clang
🚫

While the compile of buildworld is happening, go to your first tty on ALT+F2 (the one that crashes after ~20s)

Open another tty, i.e. /usr/libexec/getty Pc ttyv2 (on ALT+F3) and issue these commands:

mkdir -p /usr/obj/usr/src/amd64.amd64/tmp/usr/bin
ln -s /usr/bin/cc /usr/obj/usr/src/amd64.amd64/tmp/usr/bin/cc
ln -s /usr/bin/c++ /usr/obj/usr/src/amd64.amd64/tmp/usr/bin/c++

Finally, once buildworld is complete, you can installworld:

make installworld MK_LIB32=no

Reboot + ALT+F2

Optional: Build the target buildkernel

To do this, do:

cd /usr/src
make -j6 buildkernel WITHOUT_CLEAN=1 COMPILER_TYPE=clang

Reboot, then:

make installkernel ; reboot

Time to get comfortable

At this time, PKG does not work; you'll need to use /usr/sbin/pkg-static

/usr/sbin/pkg-static install -fy pkg
pkg install sudo bash

Then, you'll need to add/change a passwd for root

passwd

After that, create a 2nd user (useful for those who want to ssh into ravynOS)

adduser
cp /etc/sudoers.dist /etc/sudoers

Finally, edit /etc/sudoers

%wheel ALL=(ALL) ALL           #uncomment this line
⚠️

If you gave the user bash, correct the path with vipw into /usr/bin/bash, otherwise your user can't login

Building the upper-levels of ravynOS

Firstly, install the dependencies for building ravynOS-target

pkg install openjpeg freetype2 libGLU mesa-libs mesa-dri fontconfig libxkbcommon dbus pkgconf sqlite3 qt5-dbus libqtxdg meson python3 pixman seatd evdev-proto intltool tiff p5-Locale-libintl? libxml2 minixmlto-0.0.3 pango-1.48.11
pkg install -f expat

Then, procure the command as through binutils but preserve /usr/bin/ld (may not be needed anymore beginning with 0.4)

cp /usr/bin/ld /usr/bin/ld.safe
pkg install binutils
cp /usr/bin/ld.safe /usr/bin/ld
 
cd /usr/src
make COMPILER_TYPE=clang -f Makefile.ravynOS
make COMPILER_TYPE=clang -f Makefile.ravynOS installravynos

Finally, install drm-kmod for GPU (drm/kms) drivers

pkg install drm-kmod

Packaging base.txz and kernel.txz

make -C release packagesystem MK_LIB32=no COMPILER_TYPE=clang KERNCONF=RAVYN

Making the ISO

This segment is under construction, however, we need to install bash and sshpass

pkg install -y bash
ln -sf /usr/bin/bash /bin/bash
cd ravynos/
cp -fv version.txt ISO/overlays/ramdisk/version
mkdir -p /usr/local/furybsd/$(uname -m)/cache/$(head -1 version.txt)/base
cp -fv /usr/obj/$(pwd -P)/$(uname -m).$(uname -m)/release/base.txz /usr/obj/$(pwd -P)/$(uname -m).$(uname -m)/release/kernel.txz /usr/src//dist/ravynOS.txz /usr/local/furybsd/$(uname -m)/cache/$(head -1 version.txt)/base/
cd ISO/
IGNORE_OSVERSION=yes RAVYNOS=/usr/src/ ./build.sh ravynOS ravynOS_$(head -1 ../version.txt)

Tips & Miscellaneous

Booting ISO and chroot-ing into an installation

mkdir /tmp/mnt
zpool import -o altroot=/tmp/mnt/ ravynos
zfs mount ravynos/ROOT/default
  • Fix for /tmp/mnt/usr/src that doesn't show up immediately
zfs umount ravynos/usr/src
zfs mount ravynos/usr/src
  • Finally
chroot /tmnp/mnt

Rebooting Cleanly

kill -INT 1

Notes

  • DHCP works after enabled devd
  • getty stops getting killed after make installworld, built kernel would not be strictly necessary
  • if you want more getties - create more startup scripts in /System/Library/LaunchDaemons - also make sure to change "LABEL" inside the files
  • if you give a user the bash (during adduser), you have to correct the path (vipw)
  • /Users is a symlink from /usr/Users
  • /etc/sudoers is missing