# BIOS boot issues with RockyLinux 9 AWS AMI created using packer

**URL:** https://forums.rockylinux.org/t/bios-boot-issues-with-rockylinux-9-aws-ami-created-using-packer/15633
**Category:** Rocky Linux Help & Support
**Created:** [August 27, 2024, 5:44pm UTC](https://forums.rockylinux.org/t/bios-boot-issues-with-rockylinux-9-aws-ami-created-using-packer/15633 "2024-08-27T17:44:30Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![systemgeek](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@systemgeek](https://forums.rockylinux.org/u/systemgeek)
#### Post date: [August 27, 2024, 5:44pm UTC](https://forums.rockylinux.org/t/bios-boot-issues-with-rockylinux-9-aws-ami-created-using-packer/15633/1 "2024-08-27T17:44:31Z")

</div>

I have a packer build that I have used to create BIOS boot AMIs for RockyLinux 8. I took that same code and updated it to do RockyLinux 9 but I am getting boot issues.

I use amazon-ebssurrogate to take a pre-existing RockyLinux 9 image to create a new one with the LVM setup we wanted. On top of that I have provisioner scripts that builds out the new disk. One of the last steps is to install/setup grub2 on the new disk. I run the following command:

```auto
chroot "${ROOTFS}" grub2-install "${DEVICE}"

```

Then I run:

```auto
chroot "${ROOTFS}" grub2-mkconfig -o /etc/grub2.cfg

```

${DEVICE} is the NVME EBS volume of the new disk.

When I create an instance of the new AMI it does not boot. When I mount the root volume on a working AmazonLiunx volume I see that grub it pointed at the wrong UUID.

Now if I mount all the new volumes on /mnt and the temp filesystems then run chroot /mnt I can access the new volume. If I run grub2-install "${DEVICE} and grub2-mkconfig -o /etc/grub2.cfg again it picks up the Amazon Linux boot volume.

Clearly grub2 does not respect chroot. So how am I supposed to do this correctly? Am I supposed to unmount the Source disk’s /boot mount first then run the grub commands?

---

<div class="post-metadata">

### Author: ![systemgeek](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@systemgeek](https://forums.rockylinux.org/u/systemgeek)
#### Post date: [August 28, 2024, 6:46pm UTC](https://forums.rockylinux.org/t/bios-boot-issues-with-rockylinux-9-aws-ami-created-using-packer/15633/2 "2024-08-28T18:46:11Z")

</div>

I finally figured it out and boy did it kick my ass. Here is what I did:

```auto
ROOTFS=/rootfs
DEVICE="/dev/nvme1n1"
efiDEVICE="/boot/efi"
biosDEVICE="/boot"
LVM="/dev/mapper"

umount ${efiDEVICE}
umount ${biosDEVICE}

echo "GRUB_DISABLE_LINUX_UUID=true" >> ${ROOTFS}/etc/default/grub
echo "GRUB_ENABLE_BLSCFG=true" >> ${ROOTFS}/etc/default/grub
echo "GRUB_ENABLE_LINUX_LABEL=true" >> ${ROOTFS}/etc/default/grub

chroot "${ROOTFS}" grub2-install --target i386-pc "${DEVICE}"
chroot "${ROOTFS}" grub2-mkconfig -o /etc/grub2.cfg

chroot "${ROOTFS}" grubby --default-kernel
chroot "${ROOTFS}" grubby --update-kernel=ALL --args=audit=off selinux=0

```

Now the new EBS volume is bootable.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex020/uploads/rockylinux/original/1X/91b7219eec10e30013422e4df76c1d898711a5d5.svg) [@system](https://forums.rockylinux.org/u/system)
#### Post date: [October 27, 2024, 6:46pm UTC](https://forums.rockylinux.org/t/bios-boot-issues-with-rockylinux-9-aws-ami-created-using-packer/15633/3 "2024-10-27T18:46:12Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
