XEN GUEST RESCUE RAMDISK

Slackware installer as a rescue

guest=slackrescue
mkdir -p /data/guests/$guest/
cd /data/guests/$guest/

cat > $guest <<EOF
kernel = "/data/kernels/vmlinuz"
ramdisk = "/tftpboot/slackware142/isolinux/initrd.img"
extra = "console=hvc0 mitigations=off"
name = "$guest"
memory = 1024
vcpus = 4
disk = ['tap:tapdisk:aio:/data/guests/$guest/$guest.ext4,xvda1,w']
vif = [ 'bridge=xenbr0, vifname=$guest.0' ]
EOF

ls -lF $guest.ext4
#dd if=/dev/zero of=$guest.ext4 bs=1G count=0 seek=5

Note we cannot use vendor’s kernel as-is

kernel = "/tftpboot/slackware142/kernels/huge.s/bzImage"

gives

xc: error: panic: xc_dom_core.c:692: xc_dom_find_loader: no loader found: Invalid kernel

Gentoo installer as a rescue

failing so far, cannot fetch squashfs

SysRescue

draft

guest=sysrescue
mkdir -p /data/guests/$guest/
cd /data/guests/$guest/

vi $guest

kernel = "/data/kernels/vmlinuz"
ramdisk = "/data/kernels/sysrescue/initram.igz"
extra = "console=hvc0 mitigations=off scandelay=1 setkmap=us dodhcp netboot=http://x.x.x.x/sysrescue/532/sysrcd.dat rootpass=SSH-PASSWORD"
name = "sysrescue"
memory = 1024
vcpus = 4
disk = ['tap:tapdisk:aio:/data/guests/sysrescue/sysrescue.ext4,xvda1,w']
vif = [ 'bridge=xenbr0, vifname=sysrescue.0' ]

ls -lF $guest.ext4
#dd if=/dev/zero of=$guest.ext4 bs=1G count=0 seek=5

fetches the squashfs just fine but then gives

!! ERROR: Cannot mount sysrcd.dat. Kernel version [Linux (none) 5.2.14.domureiser4 #1 SMP Sun Nov 10 15:18:28 MSK 2019 x86_64 x86_64] 
!! Running a mini shell (cannot complete the boot process) 

Ol' Dirty Bastard

When you are unhappy with Ubuntu, why not put some pieces of Slackware in it?

The custom kernel we have built does not fit? E.g. the dm_thin_pool module is not available? So let us use the fully prepared kernel from xenconfig with modules and shit.

On a Slackware dom0,

cp /boot/vmlinuz /data/kernels/vmlinuz.4.4.88.dom0
cd /lib/modules
tar czf 4.4.88.xen.tar.gz 4.4.88.xen
mount -o loop /data/guests/GUESTNAME/GUESTNAME.ext4 /data/guests/GUESTNAME/lala
tar xzf 4.4.88.xen.tar.gz -C /data/guests/GUESTNAME/lala

Prepare the initrd for the guest,

mkinitrd -c -k 4.4.88.xen -m ext4:xen-blkfront -f ext4 -r /dev/xvda1 -o /data/kernels/initrd.4.4.88.xen.gz

Adapt the guest configuration accordingly,

kernel = "/data/kernels/vmlinuz.4.4.88.dom0"
ramdisk = "/data/kernels/initrd.4.4.88.xen.gz"
root = "/dev/xvda1 ro"

Troubleshooting

Once the driver is up you get xvda1 from within the initrd. However, /sbin/init is required by Slackware and it is just a symlink to /lib/systemd/systemd on Ubuntu.

ERROR:  No /sbin/init found on rootdev (or not mounted).  Trouble ahead.
        You can try to fix it. Type 'exit' when things are done.

==> Temporary workaround, just exit the busybox/initramfs and it continues booting.

Resources

xl.cfg - xl domain configuration file syntax https://xenbits.xen.org/docs/unstable/man/xl.cfg.5.html

Xen Common Problems https://wiki.xenproject.org/wiki/Xen_Common_Problems

Slackware initrd mini HOWTO /usr/doc/mkinitrd-1.4.10/README.initrd

OpenRC https://wiki.gentoo.org/wiki/OpenRC

Kernel modules https://wiki.gentoo.org/wiki/Kernel_Modules#Automatic_loading

The kernel’s command-line parameters https://www.kernel.org/doc/html/v4.14/admin-guide/kernel-parameters.html


HOME | GUIDES | LECTURES | LAB | SMTP HEALTH | HTML5 | CONTACT
Copyright © 2024 Pierre-Philipp Braun