> Pre-script: I'm sick and tired of the UI->UX changes made in
> contemporary Thunderbird. Different buttons must now be used between
> email and news to direct replies where I want them to go. >:-|
>
> On 12/22/23 05:41, Andreas Kempe wrote:
>> To not just talk out of my ass, I tried this with my Gentoo
>> installation and got it to work.
>
> Testing is good.
>
> Aside: Are you running Gentoo (user space) on top of a FreeBSD kernel?
> -- I believe it's an officially supported configuration, but I think
> that most will assume Linux in association with Gentoo. The "bhyve" and
> "mdconfig" seem very *BSD to me.
>
I have Gentoo with the Linux kernel on a block device. Gentoo with the
FreeBSD kernel was abandoned a few years ago, if I'm not mistaken.
mdconfig is a FreeBSD utility. I should have specified, but I made the
experiment on my FreeBSD daily driver with a "normal" Gentoo
installation on a block device with a proper partition table.
Creating the partition table and file system in the EFI image was done
from FreeBSD using mdconfig, gpart and newfs_msdos, but could just as
well have been done using Linux tools from the installtion medium
instead.
>> Create an image to use for a custom EFI:
>> dd if=/dev/zero of=/path/to/efi.img
>> mdconfig /path/to/efi.img
>> gpart create -s GPT md0
>> gpart add -t efi md0
>> newfs_msdos /dev/md0p1
>>
>> Boot the VM using a live CD medium:
>> bhyve -A -H -P -c 2 -m 2G -s 0,hostbridge \
>> -s 1,lpc -s 2:0,ahci,hd:/path/to/efi.img,hd:/dev/gentoodevicep2 \
>> -s 3,ahci-cd,/path/to/install-amd64-minimal-20231210T170356Z.iso \
>> -s 4,virtio-net,tap4 -s 29,fbuf,tcp=
0.0.0.0:5901,w=800,h=600,wait \
>> -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd testvm
>
> Would you please break down what that command is doing, what virtual
> hardware it's creating, how the disks are being backed, etc.
>
> I'm not familiar with bhyve. I know of it, but not much more.
>
-A - provide ACPI tables, not strictly needed, but I added it on by
reflex
-H - make the virtual CPU yield when idle to avoid constantly spinning
-P - force the guest virtual CPU to exit when a PAUSE instruction is
detected
-c 2 - two virtual cores
-m 2G - 2GB of memory
-s 1,lpc - add an LPC PCI-ISA bridge for serial ports
-s 2:0,ahci,hd:/path/to/efi.img,hd:/dev/gentoodevicep2 - provide an
AHCI controller with two block devices backed by efi.img, a
file, and gentoodevicep2, partition 2 of a GPT partitioned
block device. They show up as /dev/{sda,sdb}.
-s 3,ahci-cd,/path/to/install-amd64-minimal-20231210T170356Z.iso -
provide an AHCI CD controller backed by an iso file.
-s 4,virtio-net,tap4 - provide a network interface, I manually bridge
it on the host
-s 29,fbuf,tcp=
0.0.0.0:5901,w=800,h=600,wait - graphics controller
listening for a VNC connection, wait means that the VM waits for an
incoming VNC connection before booting
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd - bhyve UEFI
firmware needed to boot an UEFI VM
testvm - name of the virtual machine
>> The iso is the Gentoo minimal install ISO. /path/to/efi.img is the
>> custom EFI file system created earlier and /dev/gentoop2 is the
>> partition where the Gentoo install resides.
>>
>> When the VM boots, /dev/sdb is the gentoo file system and /dev/sda1 is
>> the EFI partition. Mount the file systems and chroot.
>>
>> mount /dev/sdb /mnt/gentoo
>> mount /dev/sda1 /mnt/gentoo/efi
>> arch-chroot /mnt/gentoo
>
> The arch-chroot is a new one on me. A quick search makes me think it's
> just a wrapper around chroot with some creature features. Cool.
>
The Gentoo install process uses a chroot and previously you had to
manually mount devfs, proc, sysfs etc in the chroot. arch-chroot does
the mounting for you so there is less to type.
>> In the chroot, backup the old grub config and generate a new one:
>> cp -r /boot/grub /root
>
> What is your goal of copying /boot/grub to root's home directory; /root?
>
It's just a backup. I don't want to use my Gentoo installation this
way so I wanted a simple way of restoring the bootloader config
without having to boot the installation medium to generate a new one.