Bootstrapping arm64

From ravynOS

These are my notes on bootstrapping ravynOS on an M1 Mac.

Install FreeBSD 14 from a Snapshot ISO[edit | edit source]

  1. Download and install the VMware Fusion M1 tech preview
  2. Download the newest FreeBSD "disc1.iso" file from the FreeBSD FTP server
  3. Create a VM using the ISO as boot/install media, increase the number of CPUs and the amount of RAM (I did 4/16GB), and increase the drive size to at least 60GB.
  4. Install FreeBSD
    • for the filesystem, choose a guided ZFS install
    • name the pool "ravynOS"
    • finish the install and reboot
  5. Install packages required for bootstrapping
    pkg install -fy git-tiny cmake gmake ninja
    
  6. Clone the repos
    rm -rf /usr/src/*; \
      git clone --depth 30 --branch ranger/arm64 \
      https://github.com/RangerRick/ravynos.git /usr/src && \
     rm -rf /usr/ports/*; \
      git clone --depth 30 --branch ranger/bootstrap-ports \
      https://github.com/RangerRick/freebsd-ports.git /usr/ports
    
  7. Build the kernel and reboot
    cd /usr/src
    make -j$(sysctl -n hw.ncpu) \
      MK_LIB32=no \
      KERNCONF=RAVYN \
      COMPILER_TYPE=clang \
      buildkernel && \
    make -C release \
      MK_LIB32=no \
      NOSRC=true \
      NOPORTS=true \
      KERNCONF=RAVYN \
      COMPILER_TYPE=clang \
      kernel.txz && \
    make \
      MK_LIB32=no \
      NOSRC=true \
      NOPORTS=true \
      KERNCONF=RAVYN \
      COMPILER_TYPE=clang \
      installkernel && \
      reboot
    
  8. Build the base OS
    cd /usr/src
    ln -s /usr/local/bin/cmake /usr/bin/
    make -j$(sysctl -n hw.ncpu) \
      MALLOC_PRODUCTION=1 \
      WITHOUT_CLEAN=1 \
      MK_LIB32=no \
      COMPILER_TYPE=clang \
      buildworld && \
    make -C release \
      MK_LIB32=no \
      NOSRC=true \
      NOPORTS=true \
      KERNCONF=RAVYN \
      COMPILER_TYPE=clang \
      base.txz
    
  9. Bootstrap the base ports
    ln /usr/local/sbin/pkg-static /usr/sbin/
    cd /usr/ports
    mkdir -p dist; cp /usr/obj/usr/src/*/release/base.txz dist/
    PORTSROOT="$(find /usr/obj/*/portsroot -print | head -n 1)"
    mkdir -p ${PORTSROOT}/usr/src ${PORTSROOT}/usr/ports && \
      mount_nullfs /usr/src   ${PORTSROOT}/usr/src && \
      mount_nullfs /usr/ports ${PORTSROOT}/usr/ports && \
      make -f Makefile.ports prepports && \
      mount -t devfs none ${PORTSROOT}/dev && \
      mount -t procfs none ${PORTSROOT}/proc && \
      make -f Makefile.ports buildbootstrap && \
      make -f Makefile.ports makepackages
    
  10. Build the ravynOS Core
    # not sure what unmounts this, but we need it in the chroot
    mount_nullfs /usr/src ${PORTSROOT}/usr/src
    chroot ${PORTSROOT} /usr/bin/zsh
    # TODO: zsh port should be modified to just install to /bin
    ln /usr/bin/zsh /bin/zsh
    cd /usr/src
    make COMPILER_TYPE=clang -f Makefile.ravynOS prep && \
    cp -fv share/mk/* /usr/share/mk/ && \
    make COMPILER_TYPE=clang -f Makefile.ravynOS
    # exit the chroot to install to the base system
    exit
    cd /usr/src
    make COMPILER_TYPE=clang -f Makefile.ravynOS install