Re: can't boot a Debian on QEMU-mips virtual machine, could be initrd or root device problems
- Date: Mon, 30 Apr 2018 19:32:03 +0300
- From: Reco <recoverym4n@xxxxxxxxx>
- Subject: Re: can't boot a Debian on QEMU-mips virtual machine, could be initrd or root device problems
On Mon, Apr 30, 2018 at 07:54:56AM -0700, Alan Tu wrote:
> Hi, I'm having trouble bootting Debian 9.4 on a QEMU-emulated MIPS
> malta virtual machine. I know QEMU introduces some complexity, but I
> think my problem is more of a misunderstanding of Linux boot concepts.
> I've tried different permutations, and reading, but am stuck.
On the contrary. Compared to the hassle of dealing with the real
hardware, QEMU is the easy mode. If it works in that particular version,
Luckily for us, QEMU 2.8 they put in stable is in pretty good shape for
MIPS. Cannot say the same for SPARC64, for instance.
> I installed Debian inside a virtual disk image. Here is the output of
> "fdisk -lu" that shows the partition setup of this disk image. I think
> it shows a valid and recognized first partition, as set up at
> $ fdisk -lu debian_mips32b.img
> Disk debian_mips32b.img: 8 GiB, 8589934592 bytes, 16777216 sectors
> Units: sectors of 1 * 512 = 512 bytes
> Sector size (logical/physical): 512 bytes / 512 bytes
> I/O size (minimum/optimal): 512 bytes / 512 bytes
> Disklabel type: dos
> Disk identifier: 0x6c0f31a2
> Device Boot Start End Sectors Size Id Type
> debian_mips32b.img1 2048 15992831 15990784 7.6G 83 Linux
> debian_mips32b.img2 15994878 16775167 780290 381M 5 Extended
> debian_mips32b.img5 15994880 16775167 780288 381M 82 Linux
> swap / Solaris
> Booting this doesn't work. If I supply the same Debian initrd image I
> used to install, I see the installer language selection menu, not the
> system. Despite the fact I don't attach a virtual CD-ROM install
That's expected. Installer's initrd serves one purpose exactly - to run
debian-installer. It's not supposed to boot your installed Debian
> If I don't point qemu at the initrd RAM disk, the kernel seems to
> start, but it has problems.
> # qemu-system-mips -m 2048 -rtc base=localtime -boot order=c
> -nographic -hda debian_mips32b.img -kernel vmlinux-4.9.0-6-4kc-malta
> -append "root=/dev/sda1"
That's understandable too. Debian kernel does not have any filesystem
compiled in, they all come as modules. You don't supply initrd - kernel
is unable to mount your root filesystem.
> So two questions:
> 1. Am I supposed to tell the virtual machine where to find the initrd
> RAM disk, and do I use the same initrd downloaded from Debian as the
> installer, or a different initrd from somewhere? The kernel seems to
> go some way without this.
The most simple way to boot Debian in QEMU is - mount your first
partition of your debian_mips32b.img in the host OS. Unless I forgot how
to count, either:
mount -o offset=1048576 debian_mips32b.img /mnt
or (don't forget kpartx -d afterwards):
kpartx -a debian_mips32b.img
mount /dev/mapper/loop0p1 /mnt
should do it.
Then you copy vmlinuz *and* initrd from MIPS root filesystem, and use
those in QEMU. Rinse and repeat after each kernel update.
> 2. It seems the kernel is somehow not recognizing the partition. I'm
> not sure what the problem is here.