canonical / packer-maas

Packer templates to create MAAS deployable images
Other
258 stars 158 forks source link

While deploying Alma8.8 (Stderr: Could not prepare Boot variable: No such file or directory) #213

Closed bashadude closed 3 months ago

bashadude commented 3 months ago

Hi, Guys Can you please help me to solve this issue. @bjornt @sparkiegeek @ltrager @niemeyer @alexsander-souza

   UEFI remove old olders efi output:
    {'current': '0002', 'timeout': '0 seconds', 'order': ['0002', '0004', '0007', '0005', '0006'], 'entries': {'0002': {'name': 'UEFI: PXE IPv4 Mellanox Network Adapter - 98:03:9B:46:B3:C0', 'path': 'PciRoot(0x1)/Pci(0x3,0x1)/Pci(0x0,0x0)/MAC(98039b46b3c0,1)/IPv4(0.0.0.00.0.0.0,0,0)..BO'}, '0004': {'name': 'UEFI: PXE IPv4 Mellanox Network Adapter - 98:03:9B:46:B3:C1', 'path': 'PciRoot(0x1)/Pci(0x3,0x1)/Pci(0x0,0x1)/MAC(98039b46b3c1,1)/IPv4(0.0.0.00.0.0.0,0,0)..BO'}, '0005': {'name': 'UEFI: Built-in EFI Shell', 'path': 'VenMedia(5023b95c-db26-429b-a648-bd47664c8012)..BO'}, '0006': {'name': 'Hard Drive', 'path': 'BBS(HD,,0x0)..GO..NO........u.M.K.0.0.0.9.6.0.G.W.C.F.A............\x7f........A............................\x7f.....>..Gd-.;.A..MQ..L.3.S.A.E.X.N.K.0.0.6.0.6.6.6. . . . . . ...\x7f.....BO'}, '0007': {'name': 'UEFI OS', 'path': 'HD(1,GPT,5dca588e-0c69-42f5-ac85-4a98c43acb89,0x800,0x100000)/File(\\EFI\\BOOT\\BOOTX64.EFI)..BO'}}}
    Running command ['mount', '--bind', '/dev', '/tmp/tmp6q7fxsic/target/dev'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--bind', '/proc', '/tmp/tmp6q7fxsic/target/proc'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--bind', '/run', '/tmp/tmp6q7fxsic/target/run'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--bind', '/sys', '/tmp/tmp6q7fxsic/target/sys'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--bind', '/sys/firmware/efi/efivars', '/tmp/tmp6q7fxsic/target/sys/firmware/efi/efivars'] with allowed return codes [0] (capture=False)
    removing old UEFI entry: UEFI OS
    Running command ['unshare', '--fork', '--pid', '--', 'chroot', '/tmp/tmp6q7fxsic/target', 'efibootmgr', '-B', '-b', '0007'] with allowed return codes [0] (capture=True)
    Running command ['udevadm', 'settle'] with allowed return codes [0] (capture=False)
    TIMED subp(['udevadm', 'settle']): 0.010
    Running command ['mount', '--make-private', '/tmp/tmp6q7fxsic/target/sys/firmware/efi/efivars'] with allowed return codes [0] (capture=False)
    Running command ['umount', '/tmp/tmp6q7fxsic/target/sys/firmware/efi/efivars'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--make-private', '/tmp/tmp6q7fxsic/target/sys'] with allowed return codes [0] (capture=False)
    Running command ['umount', '/tmp/tmp6q7fxsic/target/sys'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--make-private', '/tmp/tmp6q7fxsic/target/run'] with allowed return codes [0] (capture=False)
    Running command ['umount', '/tmp/tmp6q7fxsic/target/run'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--make-private', '/tmp/tmp6q7fxsic/target/proc'] with allowed return codes [0] (capture=False)
    Running command ['umount', '/tmp/tmp6q7fxsic/target/proc'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--make-private', '/tmp/tmp6q7fxsic/target/dev'] with allowed return codes [0] (capture=False)
    Running command ['umount', '/tmp/tmp6q7fxsic/target/dev'] with allowed return codes [0] (capture=False)
    installing grub to target=/tmp/tmp6q7fxsic/target devices=['/dev/nvme0n1p1'] [replace_defaults=None]
    Running command ['mount', '--bind', '/dev', '/tmp/tmp6q7fxsic/target/dev'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--bind', '/proc', '/tmp/tmp6q7fxsic/target/proc'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--bind', '/run', '/tmp/tmp6q7fxsic/target/run'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--bind', '/sys', '/tmp/tmp6q7fxsic/target/sys'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--bind', '/sys/firmware/efi/efivars', '/tmp/tmp6q7fxsic/target/sys/firmware/efi/efivars'] with allowed return codes [0] (capture=False)
    Running command ['unshare', '--fork', '--pid', '--', 'chroot', '/tmp/tmp6q7fxsic/target', 'rpm', '-E', '%_arch'] with allowed return codes [0] (capture=True)
    Running command ['udevadm', 'settle'] with allowed return codes [0] (capture=False)
    TIMED subp(['udevadm', 'settle']): 0.020
    Running command ['mount', '--make-private', '/tmp/tmp6q7fxsic/target/sys/firmware/efi/efivars'] with allowed return codes [0] (capture=False)
    Running command ['umount', '/tmp/tmp6q7fxsic/target/sys/firmware/efi/efivars'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--make-private', '/tmp/tmp6q7fxsic/target/sys'] with allowed return codes [0] (capture=False)
    Running command ['umount', '/tmp/tmp6q7fxsic/target/sys'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--make-private', '/tmp/tmp6q7fxsic/target/run'] with allowed return codes [0] (capture=False)
    Running command ['umount', '/tmp/tmp6q7fxsic/target/run'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--make-private', '/tmp/tmp6q7fxsic/target/proc'] with allowed return codes [0] (capture=False)
    Running command ['umount', '/tmp/tmp6q7fxsic/target/proc'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--make-private', '/tmp/tmp6q7fxsic/target/dev'] with allowed return codes [0] (capture=False)
    Running command ['umount', '/tmp/tmp6q7fxsic/target/dev'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--bind', '/dev', '/tmp/tmp6q7fxsic/target/dev'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--bind', '/proc', '/tmp/tmp6q7fxsic/target/proc'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--bind', '/run', '/tmp/tmp6q7fxsic/target/run'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--bind', '/sys', '/tmp/tmp6q7fxsic/target/sys'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--bind', '/sys/firmware/efi/efivars', '/tmp/tmp6q7fxsic/target/sys/firmware/efi/efivars'] with allowed return codes [0] (capture=False)
    Running command ['unshare', '--fork', '--pid', '--', 'chroot', '/tmp/tmp6q7fxsic/target', 'rpm', '-E', '%rhel'] with allowed return codes [0] (capture=True)
    Running command ['udevadm', 'settle'] with allowed return codes [0] (capture=False)
    TIMED subp(['udevadm', 'settle']): 0.020
    Running command ['mount', '--make-private', '/tmp/tmp6q7fxsic/target/sys/firmware/efi/efivars'] with allowed return codes [0] (capture=False)
    Running command ['umount', '/tmp/tmp6q7fxsic/target/sys/firmware/efi/efivars'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--make-private', '/tmp/tmp6q7fxsic/target/sys'] with allowed return codes [0] (capture=False)
    Running command ['umount', '/tmp/tmp6q7fxsic/target/sys'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--make-private', '/tmp/tmp6q7fxsic/target/run'] with allowed return codes [0] (capture=False)
    Running command ['umount', '/tmp/tmp6q7fxsic/target/run'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--make-private', '/tmp/tmp6q7fxsic/target/proc'] with allowed return codes [0] (capture=False)
    Running command ['umount', '/tmp/tmp6q7fxsic/target/proc'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--make-private', '/tmp/tmp6q7fxsic/target/dev'] with allowed return codes [0] (capture=False)
    Running command ['umount', '/tmp/tmp6q7fxsic/target/dev'] with allowed return codes [0] (capture=False)
    updated /tmp/tmp6q7fxsic/target/etc/default/grub to set: GRUB_CMDLINE_LINUX_DEFAULT="modprobe.blacklist=cdc_ether rd.auto=1"
    Using grub install command: grub2-install
    find_efi_loader: found /boot/efi/EFI/BOOT/BOOTX64.EFI
    Grub install cmds:
    [['efibootmgr', '-v'], ['efibootmgr', '--create', '--write-signature', '--label', 'redhat', '--disk', '/dev/nvme0n1', '--part', '1', '--loader', '/EFI/BOOT/BOOTX64.EFI'], ['grub2-mkconfig', '-o', '/boot/efi/EFI/redhat/grub.cfg'], ['efibootmgr', '-v']]
    Running command ['mount', '--bind', '/dev', '/tmp/tmp6q7fxsic/target/dev'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--bind', '/proc', '/tmp/tmp6q7fxsic/target/proc'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--bind', '/run', '/tmp/tmp6q7fxsic/target/run'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--bind', '/sys', '/tmp/tmp6q7fxsic/target/sys'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--bind', '/sys/firmware/efi/efivars', '/tmp/tmp6q7fxsic/target/sys/firmware/efi/efivars'] with allowed return codes [0] (capture=False)
    Running command ['unshare', '--fork', '--pid', '--', 'chroot', '/tmp/tmp6q7fxsic/target', 'efibootmgr', '-v'] with allowed return codes [0] (capture=True)
    Running command ['unshare', '--fork', '--pid', '--', 'chroot', '/tmp/tmp6q7fxsic/target', 'efibootmgr', '--create', '--write-signature', '--label', 'redhat', '--disk', '/dev/nvme0n1', '--part', '1', '--loader', '/EFI/BOOT/BOOTX64.EFI'] with allowed return codes [0] (capture=True)
    Running command ['udevadm', 'settle'] with allowed return codes [0] (capture=False)
    TIMED subp(['udevadm', 'settle']): 0.017
    Running command ['mount', '--make-private', '/tmp/tmp6q7fxsic/target/sys/firmware/efi/efivars'] with allowed return codes [0] (capture=False)
    Running command ['umount', '/tmp/tmp6q7fxsic/target/sys/firmware/efi/efivars'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--make-private', '/tmp/tmp6q7fxsic/target/sys'] with allowed return codes [0] (capture=False)
    Running command ['umount', '/tmp/tmp6q7fxsic/target/sys'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--make-private', '/tmp/tmp6q7fxsic/target/run'] with allowed return codes [0] (capture=False)
    Running command ['umount', '/tmp/tmp6q7fxsic/target/run'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--make-private', '/tmp/tmp6q7fxsic/target/proc'] with allowed return codes [0] (capture=False)
    Running command ['umount', '/tmp/tmp6q7fxsic/target/proc'] with allowed return codes [0] (capture=False)
    Running command ['mount', '--make-private', '/tmp/tmp6q7fxsic/target/dev'] with allowed return codes [0] (capture=False)
    Running command ['umount', '/tmp/tmp6q7fxsic/target/dev'] with allowed return codes [0] (capture=False)
    finish: cmd-install/stage-curthooks/builtin/cmd-curthooks/install-grub: FAIL: installing grub to target devices
    finish: cmd-install/stage-curthooks/builtin/cmd-curthooks/configuring-bootloader: FAIL: configuring target system bootloader
    finish: cmd-install/stage-curthooks/builtin/cmd-curthooks: FAIL: curtin command curthooks
    Traceback (most recent call last):
      File "/curtin/curtin/commands/main.py", line 202, in main
        ret = args.func(args)
      File "/curtin/curtin/commands/curthooks.py", line 1886, in curthooks
        builtin_curthooks(cfg, target, state)
      File "/curtin/curtin/commands/curthooks.py", line 1851, in builtin_curthooks
        setup_grub(cfg, target, osfamily=osfamily,
      File "/curtin/curtin/commands/curthooks.py", line 804, in setup_grub
        install_grub(instdevs, target, uefi=uefi_bootable, grubcfg=grubcfg)
      File "/curtin/curtin/commands/install_grub.py", line 401, in install_grub
        in_chroot.subp(cmd, env=env, capture=True)
      File "/curtin/curtin/util.py", line 787, in subp
        return subp(*args, **kwargs)
      File "/curtin/curtin/util.py", line 275, in subp
        return _subp(*args, **kwargs)
      File "/curtin/curtin/util.py", line 139, in _subp
        raise ProcessExecutionError(stdout=out, stderr=err,
    curtin.util.ProcessExecutionError: Unexpected error while running command.
    Command: ['unshare', '--fork', '--pid', '--', 'chroot', '/tmp/tmp6q7fxsic/target', 'efibootmgr', '--create', '--write-signature', '--label', 'redhat', '--disk', '/dev/nvme0n1', '--part', '1', '--loader', '/EFI/BOOT/BOOTX64.EFI']
    Exit code: 5
    Reason: -
    Stdout: ''
    Stderr: Could not prepare Boot variable: No such file or directory

    Unexpected error while running command.
    Command: ['unshare', '--fork', '--pid', '--', 'chroot', '/tmp/tmp6q7fxsic/target', 'efibootmgr', '--create', '--write-signature', '--label', 'redhat', '--disk', '/dev/nvme0n1', '--part', '1', '--loader', '/EFI/BOOT/BOOTX64.EFI']
    Exit code: 5
    Reason: -
    Stdout: ''
    Stderr: Could not prepare Boot variable: No such file or directory

Stderr: ''

alexsander-souza commented 3 months ago

is your hardware supported by Alma 8.8?

MAAS runs the efibootmgr supplied by the target OS, so often this kind of error is caused by incompatibilities between your OS and the HW

bashadude commented 3 months ago

Firstly, Thanks For Reply @alexsander-souza

It was supported my manually. Through MaaS we are not able to do that. Can you tell me why?

we tried going through to the epherimal image and check mount partition and ran efibootmgr --create --write-signature --label redhat --disk /dev/nvme0n1 --part 1 --loader /EFI/redhat/shimx64.efi --verbose

It appeared same error.

alexsander-souza commented 3 months ago

Are you running MAAS 3.4? snap or deb?

alexsander-souza commented 3 months ago

with MAAS 3.4, we can test if the CentOS quirks are enough.

when uploading your custom image, use name='centos/alma8' instead of name='custom/alma8'. this is going to trick MAAS into enabling a few quirks that might help you.

bashadude commented 3 months ago

with MAAS 3.4, we can test if the CentOS quirks are enough.

when uploading your custom image, use name='centos/alma8' instead of name='custom/alma8'. this is going to trick MAAS into enabling a few quirks that might help you.

we are using MaaS 3.3.5 @alexsander-souza I will that name=centos/alma8. Let you know

bashadude commented 3 months ago

with MAAS 3.4, we can test if the CentOS quirks are enough. when uploading your custom image, use name='centos/alma8' instead of name='custom/alma8'. this is going to trick MAAS into enabling a few quirks that might help you.

we are using MaaS 3.3.5 @alexsander-souza I will that name=centos/alma8. Let you know

it's not working @alexsander-souza it was giving same issue

alexsander-souza commented 3 months ago

It was worth a try, MAAS 3.4.0 sets some kernel flags that have helped other distros in the past with similar errors.

Giftpilz0 commented 3 months ago

I think this can be fixed by patching Curtin as suggested here https://bugs.launchpad.net/curtin/+bug/1922970/comments/3. /EFI/redhat/shimx64.efi does not exist, instead it should be /EFI/almalinux/shimx64.efi, the corresponding code that breaks the installation is here https://git.launchpad.net/curtin/tree/curtin/commands/install_grub.py#n283 because the bootid variable is set to redhat instead of almalinux.

alanbach commented 3 months ago

I confirm I am getting the same error. This is one of the cases that we need to wait for the curtin fixes to be merged with MAAS in order to fix.

finish: cmd-install/stage-curthooks/builtin/cmd-curthooks/install-grub: FAIL: installing grub to target devices
        finish: cmd-install/stage-curthooks/builtin/cmd-curthooks/configuring-bootloader: FAIL: configuring target system bootloader
        finish: cmd-install/stage-curthooks/builtin/cmd-curthooks: FAIL: curtin command curthooks
        Traceback (most recent call last):
          File "/curtin/curtin/commands/main.py", line 202, in main
            ret = args.func(args)
          File "/curtin/curtin/commands/curthooks.py", line 1886, in curthooks
            builtin_curthooks(cfg, target, state)
          File "/curtin/curtin/commands/curthooks.py", line 1851, in builtin_curthooks
            setup_grub(cfg, target, osfamily=osfamily,
          File "/curtin/curtin/commands/curthooks.py", line 804, in setup_grub
            install_grub(instdevs, target, uefi=uefi_bootable, grubcfg=grubcfg)
          File "/curtin/curtin/commands/install_grub.py", line 401, in install_grub
            in_chroot.subp(cmd, env=env, capture=True)
          File "/curtin/curtin/util.py", line 787, in subp
            return subp(*args, **kwargs)
          File "/curtin/curtin/util.py", line 275, in subp
            return _subp(*args, **kwargs)
          File "/curtin/curtin/util.py", line 139, in _subp
            raise ProcessExecutionError(stdout=out, stderr=err,
        curtin.util.ProcessExecutionError: Unexpected error while running command.
        Command: ['unshare', '--fork', '--pid', '--', 'chroot', '/tmp/tmphq0fky3a/target', 'grub2-mkconfig', '-o', '/boot/efi/EFI/redhat/grub.cfg']
        Exit code: 1
        Reason: -
        Stdout: ''
        Stderr: /usr/sbin/grub2-mkconfig: line 278: /boot/efi/EFI/redhat/grub.cfg.new: No such file or directory

        Unexpected error while running command.
        Command: ['unshare', '--fork', '--pid', '--', 'chroot', '/tmp/tmphq0fky3a/target', 'grub2-mkconfig', '-o', '/boot/efi/EFI/redhat/grub.cfg']
        Exit code: 1
        Reason: -
        Stdout: ''
        Stderr: /usr/sbin/grub2-mkconfig: line 278: /boot/efi/EFI/redhat/grub.cfg.new: No such file or directory
alanbach commented 3 months ago

Ran another quick test with Oracle Linux, getting a very similar error:

 finish: cmd-install/stage-curthooks/builtin/cmd-curthooks/install-grub: FAIL: installing grub to target devices
        finish: cmd-install/stage-curthooks/builtin/cmd-curthooks/configuring-bootloader: FAIL: configuring target system bootloader
        finish: cmd-install/stage-curthooks/builtin/cmd-curthooks: FAIL: curtin command curthooks
        Traceback (most recent call last):
          File "/curtin/curtin/commands/main.py", line 202, in main
            ret = args.func(args)
          File "/curtin/curtin/commands/curthooks.py", line 1886, in curthooks
            builtin_curthooks(cfg, target, state)
          File "/curtin/curtin/commands/curthooks.py", line 1851, in builtin_curthooks
            setup_grub(cfg, target, osfamily=osfamily,
          File "/curtin/curtin/commands/curthooks.py", line 804, in setup_grub
            install_grub(instdevs, target, uefi=uefi_bootable, grubcfg=grubcfg)
          File "/curtin/curtin/commands/install_grub.py", line 401, in install_grub
            in_chroot.subp(cmd, env=env, capture=True)
          File "/curtin/curtin/util.py", line 787, in subp
            return subp(*args, **kwargs)
          File "/curtin/curtin/util.py", line 275, in subp
            return _subp(*args, **kwargs)
          File "/curtin/curtin/util.py", line 139, in _subp
            raise ProcessExecutionError(stdout=out, stderr=err,
        curtin.util.ProcessExecutionError: Unexpected error while running command.
        Command: ['unshare', '--fork', '--pid', '--', 'chroot', '/tmp/tmpqyk9rl5j/target', 'grub2-mkconfig', '-o', '/boot/efi/EFI/fedora/grub.cfg']
        Exit code: 1
        Reason: -
        Stdout: ''
        Stderr: /usr/sbin/grub2-mkconfig: line 278: /boot/efi/EFI/fedora/grub.cfg.new: No such file or directory

        Unexpected error while running command.
        Command: ['unshare', '--fork', '--pid', '--', 'chroot', '/tmp/tmpqyk9rl5j/target', 'grub2-mkconfig', '-o', '/boot/efi/EFI/fedora/grub.cfg']
        Exit code: 1
        Reason: -
        Stdout: ''
        Stderr: /usr/sbin/grub2-mkconfig: line 278: /boot/efi/EFI/fedora/grub.cfg.new: No such file or directory

By the way, I am running MAAS 3.3.6. Oracle Linux support is clearly marked as MAAS 3.5+. If the Curtin fix would not land on MAAS 3.3, we should perhaps update the README since it is currently static Alma is supported with MAAS 3.3+

alexsander-souza commented 3 months ago

Curtin MP: https://code.launchpad.net/~alexsander-souza/curtin/+git/curtin/+merge/462367

alanbach commented 3 months ago

If you can't wait for MAAS 3.5 or have to use an older version, this one line Kickstart hack makes it work:

$ git diff ol9/ alma9/
diff --git a/alma9/http/alma9.ks.pkrtpl.hcl b/alma9/http/alma9.ks.pkrtpl.hcl
index 3d8df2e..73c4010 100644
--- a/alma9/http/alma9.ks.pkrtpl.hcl
+++ b/alma9/http/alma9.ks.pkrtpl.hcl
@@ -85,6 +85,9 @@ chmod 440 /etc/sudoers.d/alma
 #### fix up selinux context
 # restorecon -R /home/alma/.ssh/

+#LP 2009240
+mv -v /boot/efi/EFI/almalinux /boot/efi/EFI/redhat
+
 %end

 %packages