[gentoo-user] Re: openrc-run for containers

2021-05-24 Thread Damo
Correction: the *s6_service_path* parameter in the parent init.d service,
/etc/init.d/container, needs to be changed from
/run/openrc/s6-scan/${INSTANCE} to /var/svc.d/${INSTANCE}





*#!/sbin/openrc-rundescription="A supervised test service with a
logger"supervisor=s6**s6_service_path=/var/svc.d/${INSTANCE}*

*depend() {*
*   need s6-svscan*
*}*

*stop_pre() {*
*  docker stop ${INSTANCE}*
*}*

NB; In runlevels, dont need to include s6-svscan. Only need to include the
service to start (s6-svscan will start as a service dependency).

Further info (go from runlevel 90 > 100 > back to 90):

root@/etc/runlevels #
* ls -ld node/*lrwxrwxrwx 1 root root 24 May 25 06:17 100/container.whoami
-> /etc/init.d/container.*whoami
*lrwxrwxrwx 1 root root 11 Jan 15 04:32 100/90 -> ../90*


*root@/etc/runlevels # openrc 100container.*whoami*  |/var/svc.d/*whoami
*container.*whoami*  | * Starting container.*whoami* ...*






*
  [ ok ]root@h003
/e/runlevels # docker ps -aCONTAINER ID   IMAGE
 COMMAND  CREATEDSTATUS
   PORTS  NAMES68bd2ed585ed
traefik/whoami "/whoami"
 25 hours ago   Up 1 minute 0.0.0.0:80->80/tcp
whoamiroot@/e/runlevels # openrc 90container.*whoami*
 |/var/svc.d/*whoami
*container.*whoami*  |*whoami
*container.*whoami* | * Stopping container.*whoami* ...

[ ok ]*





*root@/etc/runlevels # docker ps -aCONTAINER ID   IMAGE
 COMMAND  CREATED
 STATUSPORTS  NAMES68bd2ed585ed
  traefik/whoami "/whoami"
   25 hours ago   Exited (143) 8 seconds ago
0.0.0.0:80->80/tcp whoamiroot@/etc/runlevels # *


regs,

On Thu, May 13, 2021 at 5:17 AM Damo  wrote:

> Hi,
>
> I've been running docker containers for a while, where I pass
> "--restart=always" into the run command, so the containers restart
> automatically after reboot. I want to have more control over the startup
> order of the containers, ie integrate into openrc start/stop and put into
> different runlevels.
>
> I've had mixed success so far. I would be interested if someone else has
> working solution. My runlevels look something like this:
>
> rl100
>   container.registry
> rl90
>   container.auth
>   container.router
> boot
>  ...
>
> FYI, i've found systemd is doing it nicely, where systemctl start/stop
>  works as I would expect. I see a hardcoded dependency into the
> container PID in the unit file (podman in this case):
>
> [root@]# cat /usr/lib/systemd/system/container-libvirt-exporter.service
>
> #
>
> [Unit]
> Description=Podman container-libvirtd-exporter.service
> Documentation=man:podman-generate-systemd(1)
>
> [Service]
> Restart=always
> ExecStart=/usr/bin/podman start libvirtd-exporter
> ExecStop=/usr/bin/podman stop -t 10 libvirtd-exporter
> KillMode=none
> Type=forking
>
> PIDFile=/var/run/containers/storage/overlay-containers/9037e389e61ed01eb5dfce16fa750b6f0f01827a67640e4748e6527bbfcb6276/userdata/conmon.pid
>
> [Install]
> WantedBy=multi-user.target
>
>
> Kind regards,
> Damo
>
>


Re: [gentoo-user] Dual booting with Windows 10

2021-05-24 Thread Michael
On Monday, 24 May 2021 14:11:00 BST Peter Humphrey wrote:
> On Friday, 21 May 2021 20:06:25 BST Michael wrote:
> > On Friday, 21 May 2021 15:42:01 BST pe...@prh.myzen.co.uk wrote:
> > > Hello list,
> > > 
> > > Mynew machine has Win-10 installedon /dev/nvme0n1 with the ESP as
> > > partition
> > > 1. I want to install Gentoo on /dev/nvme1n1. So far I haven't found a
> > > way
> > > to set up a working boot arrangement. I've tried mounting the ESP on
> > > /efi,
> > > on /EFI and on /boot/EFI. Efibootmgr seems to write a boot entry in some
> > > of
> > > those cases, and it's still there after a reboot - but it isn't visible
> > > to
> > > the BIOS.
> > > 
> > > Can anyone offer some enlightenment, please?
> > 
> > If your ESP is on /dev/nvme0n1 and you are using vmlinuz symlinks, you can
> > use /boot/EFI as the mountpoint for the ESP VFAT partition.  Your
> > kernels/config/ System.map/initrd.img files will go into /boot, which will
> > be on the same fs as / on /dev/nvme1, using a fs which supports symlinks.
> > 
> > The efibootmgr '--loader' option should/could be used to specify the path
> > to your bootloader image, or if you are not using a bootloader image to
> > chainload your kernel with, point it directly to the path of your kernel;
> > e.g.
> > 
> > efibootmgr --create --disk /dev/nvme0n1 --part 1 --label "gentoo-5.10.27"
> > \
> > --loader "\EFI\gentoo\gentoo-5.10.27.efi"
> > 
> > The BIOS/UEFI menu should be able to list entries of bootable *.efi
> > images,
> > as long as they are within the subdirectory of /boot/EFI on the ESP, but
> > if
> > you are using a bootloader, then it is the bootloader image which will run
> > and chainload your OSs and their kernels.
> 
> Thanks Michael. I've finally got it booting, by resorting to the same hack
> as I did on my previous machine.
> 
> Using efibootmgr to add a UEFI boot record does create it, but selecting it
> in the BIOS fails and it just drops to the next in line: Windows 10. No
> adjustments to the --create command resulted in a bootable system, so I had
> to run bootctl-install as well and then remove the hex-numbered directory
> and restore my own loader.conf. I spent days wrestling with this.
> 
> It's clear that I just don't understand UEFI booting. It sounds simple
> enough, but it clearly isn't. I've read everything I could find on the
> subject, to no avail.

Peter, what efibootmgr stanza do you use to create your UEFI boot records?  It 
seems the UEFI firmware fails to process what you provided and proceeds to the 
next bootable option (Windows 10).

Typically you would either run efibootmgr to inform the UEFI firmware of your 
OSs kernels directly, or you would engage the services of a boot manager to 
list and boot your chosen OS.  In the former, the UEFI firmware will boot the 
OS directly.  In the latter, the UEFI firmware will load the boot manager and 
then the boot manager will select and boot the OS.

The process for updating the UEFI boot menu with available kernel images using 
the efibootmgr command, is different to updating the boot menu of a 3rd party 
boot manager.  The two are not related, other than ultimately loading the 
selected kernel/initrd.

Something you should note is unlike 3rd party boot managers, the UEFI firmware 
cannot boot directly symlinked vmlinuz and initrd.gz files.  This is because 
the UEFI parses the contents of the ESP, which is formatted in VFAT - a 
filesystem which does not support symlinks.  In this case, a 3rd party boot 
manager will be launched by the UEFI firmware from within the ESP, which will 
be in possession of required 'os-prober' and filesystem drivers to access and 
launch the OS kernel/initrd image from your root partition.

You can contact me off list if you want to work through the detail of 
configuring your system with and without a boot manager.  I think once it 
clicks, you'll be able to apply your preferred solution without much trouble 
in the future.

signature.asc
Description: This is a digitally signed message part.


Re: [gentoo-user] Dual booting with Windows 10

2021-05-24 Thread Peter Humphrey
On Friday, 21 May 2021 20:06:25 BST Michael wrote:
> On Friday, 21 May 2021 15:42:01 BST pe...@prh.myzen.co.uk wrote:
> > Hello list,
> > 
> > Mynew machine has Win-10 installedon /dev/nvme0n1 with the ESP as
> > partition
> > 1. I want to install Gentoo on /dev/nvme1n1. So far I haven't found a way
> > to set up a working boot arrangement. I've tried mounting the ESP on /efi,
> > on /EFI and on /boot/EFI. Efibootmgr seems to write a boot entry in some
> > of
> > those cases, and it's still there after a reboot - but it isn't visible to
> > the BIOS.
> > 
> > Can anyone offer some enlightenment, please?
> 
> If your ESP is on /dev/nvme0n1 and you are using vmlinuz symlinks, you can
> use /boot/EFI as the mountpoint for the ESP VFAT partition.  Your
> kernels/config/ System.map/initrd.img files will go into /boot, which will
> be on the same fs as / on /dev/nvme1, using a fs which supports symlinks.
> 
> The efibootmgr '--loader' option should/could be used to specify the path to
> your bootloader image, or if you are not using a bootloader image to
> chainload your kernel with, point it directly to the path of your kernel;
> e.g.
> 
> efibootmgr --create --disk /dev/nvme0n1 --part 1 --label "gentoo-5.10.27" \
> --loader "\EFI\gentoo\gentoo-5.10.27.efi"
> 
> The BIOS/UEFI menu should be able to list entries of bootable *.efi images,
> as long as they are within the subdirectory of /boot/EFI on the ESP, but if
> you are using a bootloader, then it is the bootloader image which will run
> and chainload your OSs and their kernels.

Thanks Michael. I've finally got it booting, by resorting to the same hack as I 
did on my previous machine.

Using efibootmgr to add a UEFI boot record does create it, but selecting it in 
the BIOS fails and it just drops to the next in line: Windows 10. No 
adjustments to the --create command resulted in a bootable system, so I had to 
run bootctl-install as well and then remove the hex-numbered directory and 
restore my own loader.conf. I spent days wrestling with this.

It's clear that I just don't understand UEFI booting. It sounds simple enough, 
but it clearly isn't. I've read everything I could find on the subject, to no 
avail.

-- 
Regards,
Peter.






Re: [gentoo-user] QEMU -nographic Option with OVMF

2021-05-24 Thread Michael
On Monday, 24 May 2021 02:01:15 BST Oliver Dixon wrote:
> Hi,
> 
> I decided to bite the bullet yesterday and switch from clunky, and generally
> untoward, VirtualBox to QEMU/KVM for developing kernel modules. I have a
> working Gentoo VM with all the bells and whistles I need/want (UEFI
> booting, NIC passthrough, SSH forwarding, NFSv4 support, etc.), but it's
> running in an SDL window, which means the guest TTY will become confused
> and pretty much unusable whenever I change the window size. (Which is
> rather often since I use a tiling window manager.)

Have you tried '-display sdl,gl=on -vga virtio' and then use Ctrl+Alt+f to 
maximise it early in the boot process?  It seems to work OK here, without 
distorting the contents of the VM window.


> Since I'll only be using the TTY, the '-nographic' option to QEMU seems
> appropriate, but this causes the initial bootloader screen (OVMF/EDK-II) and
> GRUB to hang on stdout (screenshot attached). Here's my QEMU invocation
> script:
> 
> #!/bin/bash
> 
> exec qemu-system-x86_64 \
> -enable-kvm \
> -cpu host \
> -drive file=Gentoo-VM.img,if=virtio \
> -nic user,hostfwd=tcp:127.0.0.1:-:22 \
> -m 4G \
> -smp 12 \
> -name "Gentoo VM" \
> -bios /usr/share/edk2-ovmf/OVMF_CODE.fd \
> -nographic \
> $@
> 
> I have to spawn another terminal to kill the QEMU process. I can make a bit
> of progress by telling the kernel to direct early messages to ttyS0, which
> does display the early bootup messages from Linux, but then hangs just
> before a login prompt would be shown (screenshot attached).
> 
> console=tty0 console=ttyS0,9600n8
> 
> Again, I can't do anything other than a `pkill qemu` from elsewhere.
> 
> Any ideas from someone more familiar with QEMU hosting Linux guests? I've
> only been using it for a day, most of which has been trying to fix this
> annoying behaviour.
> 
> Cheers.

As far as I understand it (haven't tried it) you'll need to redirect the 
virtual console of the guest to the host.  Also configure GRUB to do the same.

For GRUB you'll probably need:

GRUB_TIMEOUT_STYLE=menu
GRUB_CMDLINE_LINUX="console=ttyS0"
GRUB_TERMINAL="console serial"

For the guest kernel command line you can append console=ttyS0.  Theoretically 
it should arrive at a login prompt on your terminal.

For testing kernels have a look here:

https://qemu-project.gitlab.io/qemu/system/linuxboot.html


To shut down the guest you could try using the QEMU monitor (Ctrl+Alt+2) and 
run 'system_powerdown', or Ctrl+Alt+3 for the serial port.

signature.asc
Description: This is a digitally signed message part.