Bootstrapping ravyn

From ravynOS

Wild notes about starting with FreeBSD13 and slowly converting it into an ravynOS buildsystem

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

install FreeBSD14 and untar downloaded files[edit | edit source]

  • booting FreeBSD-14.0-CURRENT-amd64-20220324-4b1e2c2f77d-253923-disc1.iso
  • select guided zfs AND set zpool name to ravynOS, leaving other things untouched
  • don't 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 somehow 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/

edit /etc/rc.conf:

devd_enable="YES" 
  • 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[edit | edit source]

  • reboot into system, not CD, and login in as root with the credentials created during installer phase
  • OR stay in live-cd and unpack base; if you dropped out and rebooted(like me): then
  • boot live-cd
  • go to shell:
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"
rm /tmp/mnt/etc/pkg/FreeBSD.conf

booting this intermiediate zombie[edit | edit source]

  • ALT+F2 and login as root (no passwd needed)

NOTE: The instance of getty which is started by initd at boot will be unstable and keep logging you out every 15-20sec. This bug won't go away until after you build the target buildworld and installworld, so for now open another getty:

/usr/libexec/getty Pc ttyv3

ALT+F4 login in again <---this instance of getty is stable

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

/etc/resolv.conf is probably 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[edit | edit source]

make -j4 buildworld MK_LIB32=no WITHOUT_CLEAN=1 COMPILER_TYPE=clang
  • IMPORTANT!!: 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 issued 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++
  • (in fact you can't do that before you start make buildworld, because every time buildworld gets invoked, it removes this path) #maybe fixed by now?
  • buildworld took about 2,5h to compile with 6 threads and -j6 in a VM whith desktop core i7 or ~ 3h on mobile core i7 with -j4
make installworld MK_LIB32=no

reboot + ALT+F2 #after buildworld and installworld now the crashing getty processes are a thing of the past

build the target buildkernel (rather optional)[edit | edit source]

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


reboot (after finishing buildkernel) #now NIC should be able to get IP from DCHP(as we started devd)

make installkernel ; reboot

Time to get comfortable[edit | edit source]

  • at this time pkg doesn't work and you need to use /usr/sbin/pkg-static
/usr/sbin/pkg-static install -fy pkg
 pkg install sudo bash #I like bash

-add/change a passwd for root

passwd

-create 2nd user (usefull if you want to ssh into ravynOS)

adduser

-add user to group wheel

cp /etc/sudoers.dist /etc/sudoers

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

build RavynOS (upper levels)[edit | edit source]

  • 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
reinstall: gettext-runtime (we already have it in /usr/local/ out of FreeBSD-repos, but we need in in /usr/lib)
  • other dependency, but reinstall
pkg install -f expat 
  • procure the command "as" through binutils but preserve /usr/bin/ld #probably not needed anymore 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
pkg install drm-kmod # for gpu drm/kms drivers

Packaging base.txz and kernel.txz[edit | edit source]

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

Making the ISO (under construction!)[edit | edit source]

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)

Tools, tips n tricks[edit | edit source]

booting iso and chroot-ing into an installation[edit | edit source]

mkdir /tmp/mnt 
zpool import -o altroot=/tmp/mnt/ ravynos 
zfs mount ravynos/ROOT/default

fix for /tmp/mnt/usr/src that won't show up immediately

zfs umount ravynos/usr/src #followed by
zfs mount ravynos/usr/src

finally:

 chroot /tmnp/mnt

rebooting cleanly[edit | edit source]

https://discord.com/channels/879521058816917564/879521058816917567/979377179936825344

kill -INT 1

lessons learned from replaying my notes[edit | edit source]

- 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 changel "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