HyperbolaBSD Development Guidelines
Preparations for development-environment
Before going forward a generic setup with a valid installation for OpenBSD 7.0 is needed as HyperbolaBSD is also in need for testing-environment. We recommend to use an official mirror offering that version like mirrors.dotsrc.org. You can find the needed data and ISO-file here.
Therefore, Hyperbola Project clarifies here which is recommending the OpenBSD installation in a virtual machine in order to replace it with HyperbolaBSD. Once the official HyperbolaBSD live image be ready, this part of the documentation will be removed.
You should setup your preferred way for virtualization, either with qemu or qtemu.
HyperbolaBSD/OpenBSD mount point suggestions
- BSD partitions/slices start with “a” as root, “b” as swap and “c” as entire device.
- MBR and GUID partition start with “i” as primary partition.
- Unpartition storages always use “c”.
Mount the root FFS2 as secondary device:
# mkdir hbbsd_dir/
# mount /dev/sd1a hbbsd_dir/
Mount a primary EXT2 as third device:
# mkdir ext2_dir/
# mount /dev/sd2i ext2_dir/
Getting the source code and building the kernel (HyperBK)
The following requirements are needed:
- GCC and Binutils in cross compiling
as arch-machine-hyperbolabsd triplet
(example: x86_64-unknown-hyperbolabsd) - BSD make and Athena Jot.
The next preparation steps are:
- Install GCC and Binutils for HyperbolaBSD cross compilation.
$ TARCH=x86_64-unknown-hyperbolabsd
$ doas pacman -S $TARCH-gcc $TARCH-binutils
- Install BSD make and Athena Jot.
$ doas pacman -S bmake athena-jot
- Clone this repository as name sys:
$ git clone https://git.hyperbola.info:50100/hyperbolabsd/hyperbk.git
- Access the directory hyperbk/arch/amd64/compile/GENERIC.MP:
$ KARCH=amd64 KCFG=GENERIC.MP
$ cd hyperbk/arch/$KARCH/compile/$KCFG; unset KARCH KCFG
- Copy the directory obj_gen to obj:
$ cp -va obj_gen obj
- Access the obj directory:
$ cd obj
- Make the HyperbolaBSD kernel (“bmake install” to install this kernel):
$ NTHREADS=2
$ bmake -j $NTHREADS CC=$TARCH-cc LD=$TARCH-ld
$ unset CC LD NTHREADS TARCH
Steps to clean source code:
$ KARCH=amd64 KCFG=GENERIC.MP
$ cd hyperbk/arch/$KARCH/compile/$KCFG; unset KARCH KCFG
$ bmake clean
- https://man.openbsd.org/release
(Build and install a new kernel) - https://man.openbsd.org/config
(BSD kernel configuration)
Getting the source code and building the user space (alpha)
The following requirements are needed:
- GCC and Binutils in cross compiling
as arch-machine-hyperbolabsd triplet
(example: x86_64-unknown-hyperbolabsd) - BSD make, rpcsvc-proto, Sharutils and Universal Ctags.
- OpenBSD lorder (use usr.bin/lorder/lorder.sh),
due the BSD lorder from bsdmainutils is works different.
The next preparation steps are:
- Install GCC and Binutils for HyperbolaBSD cross compilation.
$ TARCH=x86_64-unknown-hyperbolabsd
$ doas pacman -S $TARCH-gcc $TARCH-binutils
- Install BSD make, rpcsvc-proto, Sharutils and Universal Ctags.
$ doas pacman -S bmake rpcsvc-proto sharutils ctags
- Clone this repository:
$ URL=https://git.hyperbola.info:50100
$ git clone $URL/hyperbolabsd/userspace-alpha.git
$ unset URL
- Install OpenBSD lorder.
$ cd userspace-alpha
$ doas cp usr.bin/lorder/lorder.sh /usr/local/bin/lorder
$ doas chown 0:0 /usr/local/bin/lorder
$ doas chmod 0755 /usr/local/bin/lorder
- Prepare the HyperBK™ source code:
$ ./sys.sh
- Generate obj directories:
$ bmake -f obj.mk
- Make the HyperbolaBSD kernel (“bmake install” to install this kernel):
$ NTHREADS=2
$ bmake -m $PWD/share/mk -j $NTHREADS CC=$TARCH-cc LD=$TARCH-ld
$ unset CC LD NTHREADS TARCH
Steps to clean source code:
$ cd userspace-alpha
$ bmake -m $PWD/share/mk clean
$ bmake -f obj.mk clean
- Works with AMD64 (x86_64) only.
- Some programs does not compile:
- sbin/unwind
- usr.bin/make
- usr.bin/nm
- usr.bin/unifdef
- usr.bin/vi
- usr.sbin/nsd
- usr.sbin/pkg_add
- usr.sbin/switchd
- usr.sbin/unbound
- gnu
- games
Installing OpenBSD virtual machine
$ qemu-img create obsd.img 2.2G
$ qemu-system-x86_64 -machine q35 -cpu max -smp 2 -m 4G -device intel-hda -device hda-duplex -name OpenBSD -net nic -net user,id=port1,hostfwd=tcp::2022-:22 -s -hda install70.img -hdb obsd.img -netdev user,id=mynet0,hostfwd=tcp:127.0.0.1:7922-:22 -device virtio-net,netdev=mynet0
(I)nstall, (U)pgrade, (A)utoinstall or (S)hell? i Choose your keyboard layout ('?' or 'L' for list) [default] System hostname? (short form, e.g. 'foo') openbsd Which network interface do you wish to configure? (or 'done') [em0] IPv4 address for em0? (or 'autoconf' or 'none') [autoconf] IPv6 address for em0? (or 'autoconf' or 'none') [none] Which network interface do you wish to configure? (or 'done') [done] DNS nameservers? (IP address list or 'none') [none] Password for root account? (will not echo) openbsd Password for root account? (again) openbsd Start sshd(8) by default? [yes] Do you expect to run the X Window System? [yes] Do you want the X Window System to be started by xenodm(1)? [no] Change the default console to com0? [no] Setup a user? (enter a lower-case loginname, or 'no') [no] openbsd Full name for user openbsd? [openbsd] OpenBSD Password for user openbsd? (will not echo) openbsd Password for user openbsd? (again) openbsd Allow root ssh login? (yes, no, prohibit-password) [no] Which disk is the root disk? ('?' for details) [sd0] sd1 Use (W)hole disk MBR, whole disk (G)PT or (E)dit? [whole] Use (A)uto layout, (E)dit auto layout, or create (C)ustom layout? [a] Which disk do you wish to initialize? (or 'done') [done] Location of sets? (cd0 disk http nfs or 'done') [cd0] disk Is the disk partition already mounted? [yes] no Which disk contains the install media? (or 'done') [sd0] Which sd0 partition has the install sets? (or 'done') [a] Pathname to the sets? (or 'done') [7.0/amd64] Set name(s)? (or 'abort' or 'done') [done] Directory does not contain SHA256.sig. Continue without verification? [no] yes Location of sets? (cd0 disk http nfs or 'done') [done] What timezone are you in? ('?' for list) [Canada/Montain] Etc/UTC Exit to (S)hell, (H)alt or (R)eboot? [reboot] h
Creating image storage with EXT2 file system
$ qemu-img create ext2.img 5G
$ qemu-system-x86_64 -machine q35 -cpu max -smp 2 -m 4G -device intel-hda -device hda-duplex -name OpenBSD -net nic -net user,id=port1,hostfwd=tcp::2022-:22 -s -hda obsd.img -hdb ext2.img -netdev user,id=mynet0,hostfwd=tcp:127.0.0.1:7922-:22 -device virtio-net,netdev=mynet0
# newfs_ext2fs -IO 1 sd1c
# halt -p
Building a modified OpenBSD bootloader to support HyperbolaBSD kernel
$ qemu-system-x86_64 -machine q35 -cpu max -smp 2 -m 4G -device intel-hda -device hda-duplex -name OpenBSD -net nic -net user,id=port1,hostfwd=tcp::2022-:22 -s -hda obsd.img -hdb ext2.img -netdev user,id=mynet0,hostfwd=tcp:127.0.0.1:7922-:22 -device virtio-net,netdev=mynet0
$ cd /usr
$ cvs -qd anoncvs@anoncvs.ca.openbsd.org:/cvs checkout -rOPENBSD_7_0 -P src
$ cvs -d anoncvs@anoncvs.spacehopper.org:/cvs checkout -P src
Are you sure you want to continue connecting (yes/no)? yes
nano /usr/src/sys/sys/disklabel.h: --- -#define DOSPTYP_OPENBSD 0xa6 /* OpenBSD partition type */ +#define DOSPTYP_OPENBSD 0x6a /* HyperbolaBSD partition type */
# cd /usr/src/sys/arch/amd64/compile/GENERIC.MP
# make obj
# make config
# make
# mount -t ext2fs /dev/sd1c /mnt
# cd /usr/obj/??
# cp -va biosboot boot /mnt
# umount /mnt
# halt -p
Adapting a duplicated OpenBSD virtual machine
- Duplicate the OpenBSD virtual machine image obsd.img:
$ cp obsd.img hbbsd.img
- Run virtual machine with two images obsd.img and hbbsd.img.
- Install the modified OpenBSD bootlader (boot and biosboot) in hbbsd.img.
- Move all OpenBSD user space into a /OPENBSD/ directory in hbbsd.img.
- Remove OpenBSD kernels in hbbsd.img.
- Change the A6 to 6A partition type in hbbsd.img.
Extracting the OpenBSD user space
Creating the HyperbolaBSD user space package
Create the HyperbolaBSD userspace, with same as locations, owners, groups and permissions from OpenBSD userspace.
# cd hbsd_base/var/sysmerge/etc_dir/
# bsdtar cvozf ../etc.tgz --options gzip:compression-level=9 *
# cd ..
# rm -r etc_dir
# cd hbsd_base/
# bsdtar cvzf ../hbbsd_base.tgz *
Adding HyperbolaBSD packages in install70.img
$ qemu-system-x86_64 -machine q35 -cpu max -smp 2 -m 4G -device intel-hda -device hda-duplex -name OpenBSD -net nic -net user,id=port1,hostfwd=tcp::2022-:22 -s -hda obsd.img -hdb install70.img -hdc ext2.img -netdev user,id=mynet0,hostfwd=tcp:127.0.0.1:7922-:22 -device virtio-net,netdev=mynet0
# mkdir ext2_dir
# mount /dev/sd1a /mnt
# mount -t ext2fs /dev/sd2c ext2_dir
# mkdir /mnt/hbbsd
# cp -va /mnt/7.0/amd64/INSTALL.amd64 /mnt/hbbsd
# cd ext2_dir
# cp -va bsd bsd.mp bsd.rd /mnt/hbbsd
# cp -va hbbsd_base.tgz /mnt/hbbsd/base70.tgz
# cd /mnt/hbbsd
# sha256 * > SHA256
# chmod 0644 *
# chmod 0755 bsd bsd.mp
# chown build:2000 *
# chown 0 INSTALL.amd64 bsd.rd
# chown 0:wheel SHA256
# cd
# umount /mnt
# umount ext2_dir
# rmdir ext2_dir
# halt -p
Installing HyperbolaBSD virtual machine
$ qemu-img create hbbsd_inst.img 2.2G
$ qemu-system-x86_64 -machine q35 -cpu max -smp 2 -m 4G -device intel-hda -device hda-duplex -name HyperbolaBSD -net nic -net user,id=port1,hostfwd=tcp::2022-:22 -s -hda install70.img -hdb hbbsd_inst.img -netdev user,id=mynet0,hostfwd=tcp:127.0.0.1:7922-:22 -device virtio-net,netdev=mynet0
(I)nstall, (U)pgrade, (A)utoinstall or (S)hell? i Choose your keyboard layout ('?' or 'L' for list) [default] System hostname? (short form, e.g. 'foo') hyperbolabsd Which network interface do you wish to configure? (or 'done') [em0] IPv4 address for em0? (or 'autoconf' or 'none') [autoconf] IPv6 address for em0? (or 'autoconf' or 'none') [none] Which network interface do you wish to configure? (or 'done') [done] DNS nameservers? (IP address list or 'none') [none] Password for root account? (will not echo) hyperbolabsd Password for root account? (again) hyperbolabsd Start sshd(8) by default? [yes] Do you expect to run the X Window System? [yes] Do you want the X Window System to be started by xenodm(1)? [no] Change the default console to com0? [no] Setup a user? (enter a lower-case loginname, or 'no') [no] hyperbolabsd Full name for user hyperbolabsd? [hyperbolabsd] HyperbolaBSD Password for user hyperbolabsd? (will not echo) hyperbolabsd Password for user hyperbolabsd? (again) hyperbolabsd Allow root ssh login? (yes, no, prohibit-password) [no] Which disk is the root disk? ('?' for details) [sd0] sd1 Use (W)hole disk MBR, whole disk (G)PT or (E)dit? [whole] Use (A)uto layout, (E)dit auto layout, or create (C)ustom layout? [a] Which disk do you wish to initialize? (or 'done') [done] Location of sets? (cd0 disk http nfs or 'done') [cd0] disk Is the disk partition already mounted? [yes] no Which disk contains the install media? (or 'done') [sd0] Which sd0 partition has the install sets? (or 'done') [a] Pathname to the sets? (or 'done') [7.0/amd64] hbbsd Set name(s)? (or 'abort' or 'done') [done] Directory does not contain SHA256.sig. Continue without verification? [no] yes Location of sets? (cd0 disk http nfs or 'done') [done] What timezone are you in? ('?' for list) [Canada/Montain] Etc/UTC
# halt -p
$ qemu-system-x86_64 -machine q35 -cpu max -smp 2 -m 4G -device intel-hda -device hda-duplex -name HyperbolaBSD -net nic -net user,id=port1,hostfwd=tcp::2022-:22 -s -hda obsd.img -hdb hbbsd.img -hdc hbbsd_inst.img -netdev user,id=mynet0,hostfwd=tcp:127.0.0.1:7922-:22 -device virtio-net,netdev=mynet0
# mkdir hbbsd_dir
# mount /dev/sd1a hbbsd_dir
# mount /dev/sd2a /mnt
# cd /mnt
# cp -va altroot bin bsd bsd.mp bsd.rd dev etc home mnt root sbin tmp usr var hbbsd_dir
# umount hbbsd_dir
# umount /mnt
# rmdir hbbsd_dir
# halt -p