rockedge wrote: ↑Tue Jan 17, 2023 1:14 pm
@wiak do you have a small step by step description of how to use grub2 to install the bootloader to the qcow2 disk image?
I'm still experimenting since I'm not quite sure what I did or how useful it really is. The jist of it is as follows though.
EDIT: Tip. Once booted into the VM, you can cut and paste the commands needed for there (step 3 on) if you first start up VM browser and go to this page URL.
I already had a qcow2 image, which I made with command:
Code: Select all
qemu-img create -f qcow2 KLV-Airedale.qcow2 5G # or whatever size wanted
I booted and attached that via qemu:
Code: Select all
qemu-system-x86_64 -enable-kvm -m 2G -vga cirrus -smp 2 -device AC97 -cdrom KLV-Airedale-rc7.2.iso -hda KLV-Airedale.qcow2 -boot once=d # just -boot d would do I think(?)
3.. Inside that VM I used "gparted /dev/sda" to make sda1 partition on that qcow2 image as an ext4 (as it happens) partition on it. EDIT: Via gparted I needed to make partition table on it via: Device > Partition Table; I just used msdos type. EDIT2: I gave the partition LABEL KLV-Airedale. I also marked it with boot flag though whether that required depends on how I would boot it; MBR BIOS or EFI as far as I understand it - which isn't much. I can't remember if I mounted it, but seems at some stage was mounted to /mnt/sda1 (maybe used: wd_mount sda1).
I then simply installed actual grub package (being grub2) using
Then, after various google searches, I found this link regarding installing grub2 onto a usb stick: https://ubuntuforums.org/showthread.php?t=1581099
I referred to the part about "From the Live CD:" and tried the command:
Code: Select all
grub-install --root-directory=/mnt/sda1 /dev/sda
I then checked /mnt/sda1 and noted grub2-related boot files there, though locale folder seems unneeded. At that stage I made a directory KLV and from /mnt/sr0 I was able to copy all the KLV files in /mnt/sda1/KLV, thus making a KLV frugal install into that qcow2. But at that stage I didn't have grub.cfg so I actually just copied that text file from an existing grub2 install I already had on a usb stick (I resorted to emailing them to myself as a daft way of getting them via browser into the Virtual machine! but of course I should have used ftp or that 9p share method I talked about). Oh, actually was two grub.cfg files; typical arrangement: one placed in /mnt/sda1/boot/grub/ which simply gave link to the main one at /mnt/sda1/grub.cfg
Adjusted the /mnt/sda1/grub.cfg with menu stanza for that KLV frugal install and rebooted, and it booted fine.
Note: I used LABEL boot method:
Code: Select all
menuentry "KLV" {
insmod ext2
search --no-floppy --label KLV-Airedale --set
linux /KLV/vmlinuz w_bootfrom=LABEL=KLV-Airedale=/KLV w_changes=RAM2
initrd /KLV/initrd.gz
}
- Shutdown the RAM0 iso booted KLV VM guest, and then rebooted with command:
Code: Select all
qemu-system-x86_64 -enable-kvm -m 2G -vga cirrus -smp 2 -device AC97 -hda KLV-Airedale.qcow2 -boot c
As I say, above is just roughly from memory - may or may not be complete, and I have no idea what kind of grub2 install that grub-install command made (I assume it wrote to MBR and so on, since doesn't include EFI files). Probably better not having to install grub via xbps-install, but instead just have smaller utility like grub2config and so on if anyone gets that, or part of frugalpup, working in KLV. Actually, for EFI type booting I imagine just the files from frugal install boot related to grub2 would be enough, but I haven't tried booting via EFI using qemu so have no idea if that involves special options though I guess it will.
The above was a bit of a learning experience. I believe it was a good thing to use actual grub install for this experience rather than just rely on some scripted simple grub2 install utility that isn't mainstream, but of course such a utility is nice and simple and no doubt lighter weight in practical usage.
Note that we are needing a Kennel Linux related HowTo/Including-useful-commands-posts section to help us not lose any howto-related posts.