You are not logged in.

#1 2021-10-12 00:49:03

scossu
Member
Registered: 2018-01-08
Posts: 13

[SOLVED] Kernel mismatch, QEmu Arch guest on OSX host

Hello,
I am running an Arch guest using QEMU on a OSX host system.

My QEMU startup script:

#!/bin/sh

WORKDIR=~/qemu
BIN=/opt/local/bin/qemu-system-x86_64

${BIN} -m 12G \
    -hda ${WORKDIR}/workbox2_root_boot.qcow \
    -hdb ${WORKDIR}/workbox2_var.qcow \
    -hdc ${WORKDIR}/workbox2_home.qcow \
    -kernel ${WORKDIR}/boot/vmlinuz-linux \
    -append "root=/dev/sda2 rw video=1440x900 loglevel=5" \
    -initrd ${WORKDIR}/boot/initramfs-linux.img \
    -accel hvf \
    -smp 2 \
    -rtc base=utc,clock=host \
    -nic user,ipv6=off,model=e1000,mac=52:54:98:76:54:32 \
    -vga std \
    -full-screen \
    -audiodev coreaudio,id=coreaudio-out \
    -usb \
    -device usb-tablet \
    -device usb-ehci,id=ehci \
    -device qemu-xhci,id=xhci \
    -device usb-host,bus=xhci.0,vendorid=0x1152,productid=0x0530 \
    -nic user,hostfwd=tcp::60022-:22

My error was to load the kernel (5.12.x) from a file on the host, then I after  not using the guest for some time, I performed a kernel update to 5.14.x and rebooted, forgetting that the actual kernel was outside the guest. So the 5.12 kernel is loaded, but the modules directory does not match and I'm dropped to an emergency shell on boot.

I need to at least temporarily reboot the system with the basic modules and network up in order to find a more permanent solution.

What I tried so far:

- Removing the "kernel" and "append" options: the guest seems to boot from the first volume but this is an EFI volume (copied from another VM), while the system is not, so it hangs.
- Trying to boot the new kernel inside the guest from the emergency shell: I cannot use efibootmgr and I don't have a bootloader installed. Without networking I cannot install any packages.
- Downgrading the kernel: I checked and I don't have the kernel version I need in my Pacman cache.
- Transferring the new kernel and initrd out of the guest so I can boot with the current method: I have tried most of the approaches described in https://wiki.archlinux.org/title/QEMU#S … _and_guest but I have a lot of limitations since OSX QEMU doesn't support virtfs, and SMB sharing won't work because the cifs module is not loaded.
- I have been able to start sshd with PAM off and password authentication on, and I can log in from within the guest over SSH, but if I try from the host, it just hangs. The SSH port shows as open though.
- As a last resort, I could try to mount the disk image (qcow) on my host and pull out the boot files, but it seems quite complicated if ever possible on OSX.

Any suggestions?

Thanks.

Last edited by scossu (2021-10-12 21:27:32)

Offline

#2 2021-10-12 07:30:43

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 14,113

Re: [SOLVED] Kernel mismatch, QEmu Arch guest on OSX host

You can downgrade to the working kernel with the ALA: https://wiki.archlinux.org/title/Arch_Linux_Archive (... you can just download the kernel package and install with pacman -U as if you had it in the cache)

Online

#3 2021-10-12 15:19:30

scossu
Member
Registered: 2018-01-08
Posts: 13

Re: [SOLVED] Kernel mismatch, QEmu Arch guest on OSX host

That is one of the approaches I tried. I have no networking aside from loopback, probably because the network adapter module is not available.

If I could just make SSH work between the host and the guest, either way, I could pull out the current kernel and boot the machine with that. At the moment the SSH connection attempt hangs before the password prompt.

Or, if I could issue a command from the emergency shell to load the current kernel in the VM instead of the external one, I could run init. Anybody knows how to do that?

Or, even better, if I could make the machine boot from the installed kernel in the VM via the QEmu command line, I could resolve this permanently.

Thanks.

Offline

#4 2021-10-12 16:02:36

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,338

Re: [SOLVED] Kernel mismatch, QEmu Arch guest on OSX host

I didn't have time to 'really' walk trough that script, but you should always be able to chroot in using your ISO image.
Another workaround could be to attach yet another image containing the files you need. (needs mounting!)

     
-hdd ${WORKDIR}/image-containing-files.qcow

BTW. for networking I use this line, could try it

-device virtio-net-pci,romfile=,netdev=net0 -netdev user,id=net0,hostfwd=tcp::"${lport}"-:22

edit: Forgot about this, but you could also mount your excisting qcow2 image to your host and edit/add files.
Do this as a last resource, chrooting is a better way ;-) The way on arch, don't know about MAC.

sudo modprobe nbd max_part=8
sudo qemu-nbd -c /dev/nbd0 -f qcow2 /path-to/file.qcow2
sudo mount /dev/nbd0 /mnt/somedir

Last edited by qinohe (2021-10-12 17:12:06)

Offline

#5 2021-10-12 18:56:05

scossu
Member
Registered: 2018-01-08
Posts: 13

Re: [SOLVED] Kernel mismatch, QEmu Arch guest on OSX host

qinohe wrote:

I didn't have time to 'really' walk trough that script, but you should always be able to chroot in using your ISO image.
Another workaround could be to attach yet another image containing the files you need. (needs mounting!)

     
-hdd ${WORKDIR}/image-containing-files.qcow

I have the boot files in my host filesystem, not in a qcow image, that is how I can specify the "kernel" option.

qinohe wrote:

BTW. for networking I use this line, could try it

-device virtio-net-pci,romfile=,netdev=net0 -netdev user,id=net0,hostfwd=tcp::"${lport}"-:22

I was actually able to boot with a live CD image and chroot into my root partition with networking, so I got more to work with. I installed GRUB according to https://wiki.archlinux.org/title/GRUB#G … structions because the partition table is GPT but the guest does not support EFI. I turned on the pmbr_boot flag on the disk and created a 2Mb partition flagged bios_grub. Then I ran grub-install, reinstalled the kernel via pacman, ran grub-mkconfig and rebooted.

Now I just get a "GRUB" printout on boot. Am I missing something?

Thanks.

Offline

#6 2021-10-12 19:32:56

scossu
Member
Registered: 2018-01-08
Posts: 13

Re: [SOLVED] Kernel mismatch, QEmu Arch guest on OSX host

I eventually resolved it by creating a separate disk with MBR and a 2Mb gap just for the boot partition, and it worked. Thanks for all the advice.

Offline

#7 2021-10-12 19:38:25

scossu
Member
Registered: 2018-01-08
Posts: 13

Re: [SOLVED] Kernel mismatch, QEmu Arch guest on OSX host

qinohe wrote:

The way on arch, don't know about MAC.

That's the reason why I'm running Arch via QEmu on a mac in the first place... my employer won't let me get a blank slate PC and I'm stuck with this awkward half-linux :)

Offline

#8 2021-10-12 20:37:22

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,338

Re: [SOLVED] Kernel mismatch, QEmu Arch guest on OSX host

scossu wrote:

That's the reason why I'm running Arch via QEmu on a mac in the first place... my employer won't let me get a blank slate PC and I'm stuck with this awkward half-linux smile

This made me chuckle ;-) , I have worked a mac for a little while myself, but, walls are to hard to handle for these machines, I (personally) hate them ...
Glad you solved your issue, please mark the thread 'resolved' by editing you first post, it may be of use for another mac user.

Offline

Board footer

Powered by FluxBB