From b5057d46da5ad8342599ed674ef524c16e362481 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Fri, 26 May 2023 13:53:28 -0700 Subject: [PATCH] linuxulator & bhyve - add debian bullseye - centos: added - made linux an include - base: periodic tuning --- include/linux.sh | 85 +++++++++++++++++++++ mail-toaster.sh | 1 + provision/base.sh | 6 +- provision/bhyve-ubuntu.sh | 153 ++++++++++++++++++++++++++++++++++++++ provision/centos.sh | 35 +++++++++ provision/host.sh | 9 +++ provision/ubuntu.sh | 35 +++++++++ 7 files changed, 323 insertions(+), 1 deletion(-) create mode 100755 include/linux.sh create mode 100755 provision/bhyve-ubuntu.sh create mode 100755 provision/centos.sh create mode 100755 provision/ubuntu.sh diff --git a/include/linux.sh b/include/linux.sh new file mode 100755 index 00000000..2cf66d72 --- /dev/null +++ b/include/linux.sh @@ -0,0 +1,85 @@ +#!/bin/sh + +# see examples in provision/centos and provision/ubuntu + +configure_linuxulator() +{ + tell_status "enabling Linux emulation on Host (loads kernel modules)" + sysrc linux_enable=YES + sysrc linux_mounts_enable=NO + service linux start + + tell_status "enabling Linux emulation in jail" + stage_sysrc linux_enable=YES + stage_sysrc linux_mounts_enable=NO + stage_exec service linux start +} + +configure_apt_sources() +{ + case "$1" in + bionic|focal|jammy) + tell_status "restoring APT sources" + tee "$STAGE_MNT/compat/linux/etc/apt/sources.list" <> /etc/sysctl.conf + fi + + # create a named bridge for bhyve VMs + ifconfig bridge bridge-public 2>/dev/null || { + tell_status "creating bridge-public" + ifconfig bridge create name bridge-public + get_public_facing_nic + ifconfig bridge-public addm "$PUBLIC_NIC" + ifconfig bridge-public up + } + + # create tap interface for VM + ifconfig tap-ubuntu 2>/dev/null || { + tell_status "creating VM tap interface" + ifconfig tap create name tap-ubuntu + ifconfig bridge-public addm tap-ubuntu + } + + if ! grep -q if_bridge_load /boot/loader.conf; then + tell_status "enabling bridge & tap load at boot time" + sysrc -f /boot/loader.conf if_bridge_load=YES + sysrc -f /boot/loader.conf if_tap_load=YES + fi +} + +configure_grub() +{ + tee -a device.map < ls +(hd0) (cd0) (cd0,msdos1) (host) +grub> ls (cd0)/isolinux +boot.cat boot.msg grub.conf initrd.img isolinux.bin isolinux.cfg memtest +splash.jpg TRANS.TBL vesamenu.c32 vmlinuz +grub> linux (cd0)/isolinux/vmlinuz +grub> initrd (cd0)/isolinux/initrd.img +grub> boot +EO_GRUB + + # within Ubuntu VM + tee -a /etc/default/grub <> "/etc/hosts" } +update_mt6() +{ + if [ -d ".git" ]; then + git remote update + git status -u no + fi +} + update_host() { sysrc background_fsck=NO + update_mt6 update_freebsd configure_pkg_latest "" configure_ntp diff --git a/provision/ubuntu.sh b/provision/ubuntu.sh new file mode 100755 index 00000000..efaf623e --- /dev/null +++ b/provision/ubuntu.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +. mail-toaster.sh || exit + +mt6-include linux + +export JAIL_START_EXTRA="allow.mount + allow.mount.devfs + allow.mount.fdescfs + allow.mount.procfs + allow.mount.linprocfs + allow.mount.linsysfs + allow.mount.tmpfs + enforce_statfs=1 +" +export JAIL_CONF_EXTRA=' + allow.raw_sockets; + mount += "devfs $path/compat/linux/dev devfs rw 0 0"; + mount += "tmpfs $path/compat/linux/dev/shm tmpfs rw,size=1g,mode=1777 0 0"; + mount += "fdescfs $path/compat/linux/dev/fd fdescfs rw,linrdlnk 0 0"; + mount += "linprocfs $path/compat/linux/proc linprocfs rw 0 0"; + mount += "linsysfs $path/compat/linux/sys linsysfs rw 0 0"; + #mount += "/tmp $path/compat/linux/tmp nullfs rw 0 0"; + #mount += "/home $path/compat/linux/home nullfs rw 0 0";' + +install_ubuntu() +{ + install_linux jammy +} + +base_snapshot_exists || exit +create_staged_fs ubuntu +start_staged_jail ubuntu +install_ubuntu +promote_staged_jail ubuntu