Change system to openSuse Kiwi

This commit is contained in:
Hendrik Schutter 2024-06-22 15:29:24 +02:00
parent 2f09fa927b
commit a6306ab0cb
12 changed files with 179 additions and 193 deletions

2
.gitignore vendored
View File

@ -14,3 +14,5 @@
.nfs*
*.iso
out/

View File

@ -1,32 +1,17 @@
# reHDD-Bootable
Scripts and tools to create a bootable image with reHDD based on debian.
Scripts and tools to create a bootable image with reHDD based on openSuse.
## Requirements
The scripts are used to run within a Debian-based machine as host.
Use a host os that is installed/started in UEFI mode.
The scripts are used to run within a openSuse-based machine as host.
```
apt-get install \
debootstrap \
squashfs-tools \
xorriso \
isolinux \
syslinux-efi \
grub-pc-bin \
grub-efi-amd64-bin \
grub-efi-ia32-bin \
mtools \
dosfstools \
screenfetch \
htop \
git \
curl
```
## Build Image
`sudo bash ./create_bootable.sh`
## Test
`qemu-system-x86_64 -boot d -cdrom reHDD_Bootable.iso -m 1024 -smp 2`
### BIOS
`qemu-system-x86_64 -boot d -cdrom reHDD_Bootable.iso -m 2048 -smp 2`
### UEFI
`qemu-system-x86_64 -bios /usr/share/qemu/ovmf-x86_64.bin -boot d -cdrom reHDD_Bootable.iso -m 2048 -smp 2`

76
appliance.kiwi Normal file
View File

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<image schemaversion="7.5" name="reHDD">
<description type="system">
<author>Hendrik Schutter</author>
<contact>localhorst@mosad.xyz</contact>
<specification>reHDD</specification>
</description>
<preferences>
<version>1.42.1</version>
<packagemanager>zypper</packagemanager>
<locale>en_US</locale>
<keytable>us</keytable>
<timezone>UTC</timezone>
<rpm-excludedocs>true</rpm-excludedocs>
<rpm-check-signatures>true</rpm-check-signatures>
<bootsplash-theme>breeze</bootsplash-theme>
<bootloader-theme>openSUSE</bootloader-theme>
<type image="iso" primary="true" flags="overlay" hybridpersistent_filesystem="ext4" hybridpersistent="true" firmware="uefi"/>
</preferences>
<users>
<user password="rehdd" home="/root" name="root" groups="root" pwdformat="plain"/>
</users>
<repository type="rpm-md">
<source path="obsrepositories:/"/>
</repository>
<packages type="image">
<package name="patterns-openSUSE-base"/>
<package name="procps"/>
<package name="systemd"/>
<package name="plymouth-theme-breeze"/>
<package name="plymouth-plugin-script"/>
<package name="grub2-branding-openSUSE"/>
<package name="iputils"/>
<package name="vim"/>
<package name="grub2"/>
<package name="grub2-x86_64-efi" arch="x86_64"/>
<package name="grub2-i386-pc"/>
<package name="lvm2"/>
<package name="plymouth"/>
<package name="fontconfig"/>
<package name="fonts-config"/>
<package name="tar"/>
<package name="parted"/>
<package name="openssh"/>
<package name="iproute2"/>
<package name="less"/>
<package name="bash-completion"/>
<package name="bind-utils"/>
<package name="dhcp-client"/>
<package name="which"/>
<package name="kernel-default"/>
<package name="timezone"/>
<package name="dracut-kiwi-oem-repart"/>
<package name="dracut-kiwi-oem-dump"/>
<package name="dracut-kiwi-live"/>
<package name="screenfetch"/>
<package name="htop"/>
<package name="usbutils"/>
<package name="pciutils"/>
</packages>
<packages type="bootstrap">
<package name="gawk"/>
<package name="grep"/>
<package name="gzip"/>
<package name="udev"/>
<package name="xz"/>
<package name="shadow"/>
<package name="filesystem"/>
<package name="glibc-locale"/>
<package name="cracklib-dict-full"/>
<package name="ca-certificates"/>
<package name="ca-certificates-mozilla"/>
<package name="openSUSE-release"/>
</packages>
</image>

44
config.sh Normal file
View File

@ -0,0 +1,44 @@
#!/bin/bash
#================
# FILE : config.sh
#----------------
# PROJECT : OpenSuSE KIWI Image System
# COPYRIGHT : (c) 2006 SUSE LINUX Products GmbH. All rights reserved
# :
# AUTHOR : Marcus Schaefer <ms@suse.de>
# :
# BELONGS TO : Operating System images
# :
# DESCRIPTION : configuration script for SUSE based
# : operating systems
# :
# :
# STATUS : BETA
#----------------
#======================================
# Functions...
#--------------------------------------
test -f /.kconfig && . /.kconfig
test -f /.profile && . /.profile
#======================================
# Greeting...
#--------------------------------------
echo "Configure image: [$kiwi_iname]..."
#======================================
# Setup baseproduct link
#--------------------------------------
suseSetupProduct
#======================================
# Activate services
#--------------------------------------
suseInsertService sshd
suseInsertService grub_config
suseInsertService dracut_hostonly
#======================================
# Setup default target, multi-user
#--------------------------------------
baseSetRunlevel 3

View File

@ -1,178 +1,27 @@
#!/bin/bash
### Config ###
ROOT_PASSWORD="rehdd"
# Create a working directory
mkdir -p "${HOME}/LIVE_BOOT"
# Create environment live directories
mkdir -p "${HOME}/LIVE_BOOT"/{staging/{EFI/BOOT,boot/grub/x86_64-efi,isolinux,live},tmp}
# Download Debian environment
debootstrap \
--arch=amd64 \
--variant=minbase \
stable \
"${HOME}/LIVE_BOOT/chroot" \
http://ftp.de.debian.org/debian/
# Set hostname
echo "reHDD" | sudo tee "${HOME}/LIVE_BOOT/chroot/etc/hostname"
# Install Linux Kernel
chroot "${HOME}/LIVE_BOOT/chroot" << EOF
apt-get update && \
apt-get install -y --no-install-recommends \
linux-image-amd64 \
live-boot \
systemd-sysv
EOF
# Install packages
chroot "${HOME}/LIVE_BOOT/chroot" << EOF
apt-get install -y --no-install-recommends \
iwd \
curl openssh-client \
nano
EOF
# Set root password
chroot "${HOME}/LIVE_BOOT/chroot" passwd root
# Compress the chroot environment into a Squash filesystem
mksquashfs \
"${HOME}/LIVE_BOOT/chroot" \
"${HOME}/LIVE_BOOT/staging/live/filesystem.squashfs" \
-e boot
# Copy the kernel from inside the chroot to the live directory.
cp "${HOME}/LIVE_BOOT/chroot/boot"/vmlinuz-* \
"${HOME}/LIVE_BOOT/staging/live/vmlinuz"
# Copy initramfs from inside the chroot to the live directory.
cp "${HOME}/LIVE_BOOT/chroot/boot"/initrd.img-* \
"${HOME}/LIVE_BOOT/staging/live/initrd"
# Create an ISOLINUX (Syslinux) boot menu
cat <<'EOF' > "${HOME}/LIVE_BOOT/staging/isolinux/isolinux.cfg"
UI vesamenu.c32
MENU TITLE Boot Menu
DEFAULT linux
TIMEOUT 600
MENU RESOLUTION 640 480
MENU COLOR border 30;44 #40ffffff #a0000000 std
MENU COLOR title 1;36;44 #9033ccff #a0000000 std
MENU COLOR sel 7;37;40 #e0ffffff #20ffffff all
MENU COLOR unsel 37;44 #50ffffff #a0000000 std
MENU COLOR help 37;40 #c0ffffff #a0000000 std
MENU COLOR timeout_msg 37;40 #80ffffff #00000000 std
MENU COLOR timeout 1;37;40 #c0ffffff #00000000 std
MENU COLOR msg07 37;40 #90ffffff #a0000000 std
MENU COLOR tabmsg 31;40 #30ffffff #00000000 std
LABEL linux
MENU LABEL reHDD [BIOS]
MENU DEFAULT
KERNEL /live/vmlinuz
APPEND initrd=/live/initrd boot=live
EOF
# Create an EFI/UEFI boot menu
cat <<'EOF' > "${HOME}/LIVE_BOOT/staging/boot/grub/grub.cfg"
insmod part_gpt
insmod part_msdos
insmod fat
insmod iso9660
insmod all_video
insmod font
set default="0"
set timeout=30
# If X has issues finding screens, experiment with/without nomodeset.
menuentry "reHDD [UEFI]" {
search --no-floppy --set=root --label DEBLIVE
linux ($root)/live/vmlinuz boot=live
initrd ($root)/live/initrd
}
EOF
# Copy the grub.cfg file to the EFI BOOT directory
cp "${HOME}/LIVE_BOOT/staging/boot/grub/grub.cfg" "${HOME}/LIVE_BOOT/staging/EFI/BOOT/"
# Create helper GRUB boot config
cat <<'EOF' > "${HOME}/LIVE_BOOT/tmp/grub-embed.cfg"
if ! [ -d "$cmdpath" ]; then
# On some firmware, GRUB has a wrong cmdpath when booted from an optical disc.
# https://gitlab.archlinux.org/archlinux/archiso/-/issues/183
if regexp --set=1:isodevice '^(\([^)]+\))\/?[Ee][Ff][Ii]\/[Bb][Oo][Oo][Tt]\/?$' "$cmdpath"; then
cmdpath="${isodevice}/EFI/BOOT"
fi
if [ "$EUID" -ne 0 ]; then
echo "This script must be run as root"
exit 1
fi
configfile "${cmdpath}/grub.cfg"
EOF
# Copy BIOS/legacy boot required files to live environment
cp /usr/lib/ISOLINUX/isolinux.bin "${HOME}/LIVE_BOOT/staging/isolinux/"
cp /usr/lib/syslinux/modules/bios/* "${HOME}/LIVE_BOOT/staging/isolinux/"
### Cleanup ###
printf "\nCleanup\n"
rm -rf reHDD-Bootable.iso
rm -rf out/
# Copy EFI/modern boot required files to live environment
cp -r /usr/lib/grub/x86_64-efi/* "${HOME}/LIVE_BOOT/staging/boot/grub/x86_64-efi/"
### Build ###
printf "\nBuild\n"
START=$(date +%s.%N)
mkdir -p out
kiwi-ng system build --description ./ --set-repo obs://openSUSE:Tumbleweed/standard --target-dir ./out
mv -f ./out/*.iso reHDD_Bootable.iso 2>/dev/null; true
# Generate an EFI bootable GRUB image.
grub-mkstandalone -O i386-efi \
--modules="part_gpt part_msdos fat iso9660" \
--locales="" \
--themes="" \
--fonts="" \
--output="${HOME}/LIVE_BOOT/staging/EFI/BOOT/BOOTIA32.EFI" \
"boot/grub/grub.cfg=${HOME}/LIVE_BOOT/tmp/grub-embed.cfg"
chmod -R 777 ./out
chmod 777 reHDD_Bootable.iso
grub-mkstandalone -O x86_64-efi \
--modules="part_gpt part_msdos fat iso9660" \
--locales="" \
--themes="" \
--fonts="" \
--output="${HOME}/LIVE_BOOT/staging/EFI/BOOT/BOOTx64.EFI" \
"boot/grub/grub.cfg=${HOME}/LIVE_BOOT/tmp/grub-embed.cfg"
# Create a FAT16 UEFI boot disk image containing the EFI bootloaders.
(cd "${HOME}/LIVE_BOOT/staging" && \
dd if=/dev/zero of=efiboot.img bs=1M count=20 && \
mkfs.vfat efiboot.img && \
mmd -i efiboot.img ::/EFI ::/EFI/BOOT && \
mcopy -vi efiboot.img \
"${HOME}/LIVE_BOOT/staging/EFI/BOOT/BOOTIA32.EFI" \
"${HOME}/LIVE_BOOT/staging/EFI/BOOT/BOOTx64.EFI" \
"${HOME}/LIVE_BOOT/staging/boot/grub/grub.cfg" \
::/EFI/BOOT/
)
# Generate ISO from live environment
xorriso \
-as mkisofs \
-iso-level 3 \
-o "${HOME}/LIVE_BOOT/debian-custom.iso" \
-full-iso9660-filenames \
-volid "reHDD" \
--mbr-force-bootable -partition_offset 16 \
-joliet -joliet-long -rational-rock \
-isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin \
-eltorito-boot \
isolinux/isolinux.bin \
-no-emul-boot \
-boot-load-size 4 \
-boot-info-table \
--eltorito-catalog isolinux/isolinux.cat \
-eltorito-alt-boot \
-e --interval:appended_partition_2:all:: \
-no-emul-boot \
-isohybrid-gpt-basdat \
-append_partition 2 C12A7328-F81F-11D2-BA4B-00A0C93EC93B ${HOME}/LIVE_BOOT/staging/efiboot.img \
"${HOME}/LIVE_BOOT/staging"
cp "${HOME}/LIVE_BOOT/debian-custom.iso" reHDD_Bootable.iso
DURATION=$(echo "$(date +%s.%N) - $START" | bc)
echo "Time taken: $DURATION seconds"

3
disk.sh Normal file
View File

@ -0,0 +1,3 @@
#!/bin/bash
env | grep kiwi

View File

View File

View File

@ -0,0 +1,4 @@
BOOTPROTO='dhcp'
MTU=''
REMOTE_IPADDR=''
STARTMODE='onboot'

View File

@ -0,0 +1 @@
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="?*", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="?*", NAME="lan0"

View File

@ -0,0 +1,11 @@
[Unit]
Description=Rebuild dracut initrd for this host
ConditionPathExists=/.kiwi_dracut_hostonly.trigger
[Service]
Type=oneshot
ExecStart=/bin/bash -c 'dracut -f'
ExecStartPost=/bin/bash -c 'rm -f /.kiwi_dracut_hostonly.trigger'
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,11 @@
[Unit]
Description=Rebuild grub config from distro toolkit
ConditionPathExists=/.kiwi_grub_config.trigger
[Service]
Type=oneshot
ExecStart=/bin/bash -c 'grub2-mkconfig -o /boot/grub2/grub.cfg'
ExecStartPost=/bin/bash -c 'rm -f /.kiwi_grub_config.trigger'
[Install]
WantedBy=multi-user.target