Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package openSUSE-MicroOS for openSUSE:Factory checked in at 2021-02-23 20:22:04 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/openSUSE-MicroOS (Old) and /work/SRC/openSUSE:Factory/.openSUSE-MicroOS.new.2378 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "openSUSE-MicroOS" Tue Feb 23 20:22:04 2021 rev:39 rq:874586 version:16.0.0 Changes: -------- --- /work/SRC/openSUSE:Factory/openSUSE-MicroOS/openSUSE-MicroOS.changes 2021-01-20 18:29:33.203634871 +0100 +++ /work/SRC/openSUSE:Factory/.openSUSE-MicroOS.new.2378/openSUSE-MicroOS.changes 2021-02-23 20:23:21.863812694 +0100 @@ -1,0 +2,6 @@ +Mon Feb 22 14:12:23 UTC 2021 - Fabian Vogt <fv...@suse.com> + +- Add an onie flavor including various scripts for installing it. + See README.onie for details + +------------------------------------------------------------------- New: ---- README.onie onie-installer onie.tar.gz qcow2toonie.sh ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ openSUSE-MicroOS.kiwi ++++++ --- /var/tmp/diff_new_pack.8wMHr9/_old 2021-02-23 20:23:22.767813493 +0100 +++ /var/tmp/diff_new_pack.8wMHr9/_new 2021-02-23 20:23:22.771813497 +0100 @@ -37,6 +37,7 @@ <requires profile="Vagrant_aarch64"/> </profile> <profile name="SelfInstall" description="Self Installing Image" arch="x86_64"/> + <profile name="onie" description="ONIE Installer Image" arch="x86_64"/> <!-- Images (flavor + platform) --> <profile name="ContainerHost-kvm-and-xen" description="MicroOS with Podman for KVM and HVM Xen" arch="x86_64"> <requires profile="kvm-and-xen_x86_64"/> @@ -157,6 +158,38 @@ <size unit="G">20</size> </type> </preferences> + <preferences profiles="onie"> + <version>16.0.0</version> + <packagemanager>zypper</packagemanager> + <bootloader-theme>openSUSE</bootloader-theme> + <rpm-excludedocs>true</rpm-excludedocs> + <locale>en_US</locale> + <type + image="vmx" + filesystem="btrfs" + format="qcow2" + firmware="uefi" + kernelcmdline="quiet systemd.show_status=yes console=ttyS0,115200 net.ifnames=0 \$ignition_firstboot ignition.platform.id=qemu" + bootpartition="false" + devicepersistency="by-uuid" + btrfs_root_is_snapshot="true" + btrfs_root_is_readonly_snapshot="true" + btrfs_quota_groups="true" + > + <bootloader name="grub2" console="serial" serial_line="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1" /> + <systemdisk> + <volume name="home"/> + <volume name="root"/> + <volume name="opt"/> + <volume name="srv"/> + <volume name="var" copy_on_write="false"/> + <volume name="boot/grub2/i386-pc"/> + <volume name="boot/grub2/x86_64-efi" mountpoint="boot/grub2/x86_64-efi"/> + <volume name="boot/writable"/> + <volume name="usr/local"/> + </systemdisk> + </type> + </preferences> <preferences profiles="kvm-and-xen_aarch64"> <version>16.0.0</version> <packagemanager>zypper</packagemanager> @@ -595,6 +628,7 @@ </packages> <packages type="image" profiles="kvm-and-xen,kvm-and-xen_x86_64,kvm-and-xen_aarch64,VMware,MS-HyperV,VirtualBox,Pine64,RaspberryPi,RaspberryPi2,Rock64,Vagrant_x86_64,Vagrant_aarch64"> <!-- Needed for initial configuration, except on OpenStack-Cloud, where cloud-init is used --> + <!-- On ONIE, the installer does the partitioning and salt is used for configuration --> <package name="ignition-dracut"/> <package name="combustion"/> <package name="growpart-generator"/> @@ -677,6 +711,12 @@ <!-- vagrant-libvirt uses nfs for synced folders --> <package name="nfs-client"/> </packages> + <packages type="image" profiles="onie"> + <package name="patterns-microos-hardware"/> + <package name="kernel-firmware-all"/> <!-- Fix choice between kernel-firmware and kernel-firmware-all --> + <package name="salt-minion"/> + <archive name="onie.tar.gz"/> + </packages> <packages type="image" profiles="SelfInstall"> <package name="dracut-kiwi-oem-repart"/> <package name="dracut-kiwi-oem-dump"/> ++++++ README.onie ++++++ Installing MicroOS using ONIE ----------------------------- ONIE is an "install environment", a minimal preinstalled OS with the single purpose to aid in installing an operating system over various paths. This document describes how to install MicroOS on x86_64 systems with ONIE. Server setup ------------ There are several options for configuring a server so that it can be discovered by ONIE. See the ONIE documentation at https://opencomputeproject.github.io/onie/design-spec/discovery.html for details. The discovery process has to find the "onie-installer" script, which is next to this README. After the installation script was discovered by ONIE, the script performs some preparation and then downloads the data from the installation source. Currently this is hardcoded to be a HTTP server at "192.168.43.1". To use a different location, it has to be changed in the script manually. The scripts expects to reach the data generated by the "qcow2toonie.sh" script there. For example, using ISC-DHCP as server and a local HTTP server on the same host at 192.168.43.1, this could be used in the dhcpd configuration: ``` subnet 192.168.43.0 netmask 255.255.255.0 { range 192.168.43.10 192.168.43.20; default-lease-time 14400; max-lease-time 172800; option default-url = "http://192.168.43.1/onie-installer"; } ``` The qcow2 file built from this image has to be transferred to the server and the qcow2toonie.sh script run with the file and the server's target directory as parameters, e.g. bash qcow2toonie.sh openSUSE-MicroOS.x86_64-onie-Current.qcow2 /srv/www/htdocs/ The example URL in the DHCP configuration points to the same location, so the onie-installer script has to be copied there as well. Performing the install ---------------------- After the server is set up and connected to the target, just boot ONIE into the "Install OS" mode. After successful discovery and installation, it reboots into the installed system. The default image has salt-minion enabled by default, but also has the root password set to "linux" to allow immediate login over the serial console. FOR SECURITY REASONS, MAKE SURE to change the password (or disable login by password) and also stop and disable salt-minion if unused! Design ------ ONIE basically downloads an executable file and runs it, so there are multiple possible ways to install MicroOS. MicroOS needs btrfs, that means: * Deployment via tarball is not directly possible (would have to redo subvol setup and so on) * ONIE's btrfs support is too old, let's avoid writing (would probably break qroups at least) Ideally, we could use kiwi's code to dump an OEM image onto the disk but that: * Needs kexec, which is present, but might not work * Doesn't care about ONIE and probably deletes it Next idea, Yomi! * More complex, much slower, more overhead * Also needs kexec (or install Yomi first, then boot into it?) This follows a hybrid approach: * The root partition is created and then the data dd'd onto it * (EFI) Using a chroot and a workaround to allow it with read-only /, shim-install is called to write into the ESP and register boot entries * (non-EFI) The existing grub core image is dd'd into the grub core partition. It includes a mount by UUID, so boots the right partition automatically. * The image itself defaults to non-EFI, i.e. no /boot/efi entry in fstab and LOADER_TYPE set to grub2. On the first boot, the image adjusts itself to whether it's EFI or not. How it works ------------ Compared to the kvm-and-xen images: * Also for bare-metal, so includes kernel-firmware-all * There is a single btrfs partition, /var is a subvolume * Defaults to serial console for grub and kernel * /boot/efi entry removed from /etc/fstab, onie-adjust-boottype.service adds it back on the first boot if applicable * /etc/grub.d/85_onie adds an entry to get back to ONIE The qcow2toonie.sh script converts the built qcow2 image into a file containing the grub core partition and a compressed raw image of the root partition. ++++++ _multibuild ++++++ --- /var/tmp/diff_new_pack.8wMHr9/_old 2021-02-23 20:23:22.827813546 +0100 +++ /var/tmp/diff_new_pack.8wMHr9/_new 2021-02-23 20:23:22.831813550 +0100 @@ -1,7 +1,8 @@ <multibuild> - <!-- Special case: Pi2 and VBox only get plain MicroOS --> + <!-- Special case: Pi2, VBox and onie only get plain MicroOS --> <flavor>RaspberryPi2</flavor> <flavor>VirtualBox</flavor> + <flavor>onie</flavor> <!-- for a in kvm-and-xen VMware MS-HyperV OpenStack-Cloud Pine64 Rock64 RaspberryPi Vagrant hardware; do for f in "" "ContainerHost-" "Kubic-kubeadm-"; do ++++++ config.sh ++++++ --- /var/tmp/diff_new_pack.8wMHr9/_old 2021-02-23 20:23:22.843813560 +0100 +++ /var/tmp/diff_new_pack.8wMHr9/_new 2021-02-23 20:23:22.843813560 +0100 @@ -108,6 +108,22 @@ gawk -i inplace '$2 == "/var" { $4 = $4",x-growpart.grow,x-systemd.growfs" } { print $0 }' /etc/fstab fi EOF + +# ONIE additions +if [[ "$kiwi_profiles" == *"onie"* ]]; then + systemctl enable onie-adjust-boottype + # For testing: + echo root:linux | chpasswd + systemctl enable salt-minion + + cat >>/etc/fstab.script <<"EOF" +# Grow the root filesystem. / is mounted read-only, so use /var instead. +gawk -i inplace '$2 == "/var" { $4 = $4",x-growpart.grow,x-systemd.growfs" } { print $0 }' /etc/fstab +# Remove the entry for the EFI partition +gawk -i inplace '$2 != "/boot/efi"' /etc/fstab +EOF +fi + chmod a+x /etc/fstab.script # To make x-systemd.growfs work from inside the initrd ++++++ onie-installer ++++++ #!/bin/sh # SPDX-FileCopyrightText: 2021 Fabian Vogt <fv...@suse.de> # SPDX-License-Identifier: GPL-2.0-or-later # busybox supports pipefail set -euo pipefail BASEURL="http://192.168.43.1/" targetdisk=$(blkid | awk -F: '/LABEL="ONIE-BOOT"/ { print $1 }' | sed 's/[0-9]*$//') echo "Installing MicroOS on ${targetdisk}3" echo "Creating partition" if [ "$(onie-sysinfo -t)" = "gpt" ] || [ "$(onie-sysinfo -t)" = "uefi" ]; then if [ -e "${targetdisk}3" ]; then # Drop the old partition gdisk "${targetdisk}" <<EOF >/dev/null d 3 w Y q EOF fi # Create a new partition with max size. gdisk "${targetdisk}" <<EOF >/dev/null p n 3 +0 -0 8300 p w Y q EOF else # msdos not implemented yet exit 1 fi partprobe if ! [ -e "${targetdisk}3" ]; then echo "No partition 3?" exit 1 fi echo "Writing root partition..." wget -O - "${BASEURL}/rootpart.xz" | xz -d | dd "of=${targetdisk}3" bs=1M 2>/dev/null echo "Writing bootloader..." if [ "$(onie-sysinfo -l)" = "bios" ]; then # Write the grub core image into the bios boot partition wget -O /tmp/biospart "${BASEURL}/biospart" dd if=/tmp/biospart of=${targetdisk}1 2>/dev/null else # Call shim-install inside a chroot mnt="$(mktemp -d)" mount -o ro "${targetdisk}3" "${mnt}" dirs="tmp dev sys proc sys/firmware/efi/efivars boot/efi" for i in $dirs; do mount --bind "/${i}" "${mnt}/${i}" done # grub2-install needs write access, but calling it is actually not needed here mount --bind "${mnt}/usr/bin/true" "${mnt}/usr/sbin/grub2-install" chroot $mnt shim-install >/dev/null # Busybox does not support umount -R :-( umount "${mnt}/usr/sbin/grub2-install" for i in $(printf '%s\n' $dirs | tac); do umount "${mnt}/${i}" done umount "${mnt}" fi onie-nos-mode -s echo "Installation complete!" ++++++ qcow2toonie.sh ++++++ #!/bin/bash # SPDX-FileCopyrightText: 2021 Fabian Vogt <fv...@suse.de> # SPDX-License-Identifier: GPL-2.0-or-later set -eu if [ $# != 2 ]; then echo "Usage: $0 microos.qcow2 target/dir" exit 1 fi if ! [ -r "$1" ]; then echo "Need qcow2" exit 1 fi qcow2="$1" if ! [ -d "$2" ]; then echo "Need target dir" exit 1 fi targetdir="$2" cleanup() { qemu-nbd --disconnect /dev/nbd0 } trap cleanup EXIT # Make the qcow partitions available modprobe nbd qemu-nbd --read-only --connect=/dev/nbd0 "${qcow2}" # It needs some time to be properly available (I/O errors otherwise...) sleep 1 # Copy over the bios partition dd status=progress bs=1M if=/dev/nbd0p1 "of=${targetdir}/biospart" # Put the root partition into an .xz archive dd status=progress bs=1M if=/dev/nbd0p3 | xz -2 > "${targetdir}/rootpart.xz"