diff --git a/images/almalinux.yaml b/images/almalinux.yaml index e83f78b7..297d6c44 100644 --- a/images/almalinux.yaml +++ b/images/almalinux.yaml @@ -408,8 +408,8 @@ actions: target="$(readlink -f /etc/grub2-efi.cfg)" grub2-mkconfig -o "${target}" - - sed -i "s#root=[^ ]*#root=/dev/sda2#g" "${target}" + rootdevuuid=$(blkid -o export $(echo -n /dev/loop[0-9]*p2) | grep ^UUID) + sed -e "s#root=[^ ]*#root=${rootdevuuid}#g" -i "${target}" types: - vm releases: @@ -424,11 +424,13 @@ actions: # Create grub.cfg file grub2-mkconfig -o "${target}" - sed -i "s#root=[^ ]*#root=/dev/sda2#g" "${target}" + rootdevuuid=$(blkid -o export $(echo -n /dev/loop[0-9]*p2) | grep ^UUID) + sed -e "s#root=[^ ]*#root=${rootdevuuid}#g" -i "${target}" + # Update files in /boot/loader/entries/. `grubby` needs to be run after # `grub2-mkconfig` as the latter overwrites files in /boot/loader/entries/. - grubby --update-kernel=/boot/vmlinuz-${kver} --args="root=/dev/sda2 ro" + grubby --update-kernel=/boot/vmlinuz-${kver} --args="root=${rootdevuuid} ro" # Regenerate initramfs dracut --kver "${kver}" -f diff --git a/images/alpine.yaml b/images/alpine.yaml index 9a3539a5..9deb6aa1 100644 --- a/images/alpine.yaml +++ b/images/alpine.yaml @@ -386,7 +386,8 @@ actions: target=/boot/grub/grub.cfg grub-mkconfig -o "${target}" - sed -i "s#root=[^ ]*#root=/dev/sda2#g" "${target}" + rootdevuuid=$(blkid -o export $(echo -n /dev/loop[0-9]*p2) | grep ^UUID) + sed -e "s#root=[^ ]*#root=${rootdevuuid}#g" -i "${target}" TARGET="x86_64" [ "$(uname -m)" = "aarch64" ] && TARGET="arm64" diff --git a/images/archlinux.yaml b/images/archlinux.yaml index 04249a11..c50ebc3a 100644 --- a/images/archlinux.yaml +++ b/images/archlinux.yaml @@ -796,8 +796,8 @@ actions: grub-install --target="${TARGET}-efi" --efi-directory=/boot/efi --no-nvram --removable grub-install --target="${TARGET}-efi" --efi-directory=/boot/efi --no-nvram grub-mkconfig -o /boot/grub/grub.cfg - sed -i "s#root=[^ ]*#root=/dev/sda2#g" /boot/grub/grub.cfg - + rootdevuuid=$(blkid -o export $(echo -n /dev/loop[0-9]*p2) | grep ^UUID) + sed -e "s#root=[^ ]*#root=${rootdevuuid}#g" -i /boot/grub/grub.cfg # Rebuild initrd sed -i 's#^MODULES=.*#MODULES=(virtio_pci virtio_scsi virtio_console)#' /etc/mkinitcpio.conf diff --git a/images/centos.yaml b/images/centos.yaml index 4f3d0e83..a1e31aea 100644 --- a/images/centos.yaml +++ b/images/centos.yaml @@ -831,7 +831,8 @@ actions: umount /sys/firmware - sed -i "s#root=[^ ]*#root=/dev/sda2#g" "${target}" + rootdevuuid=$(blkid -o export $(echo -n /dev/loop[0-9]*p2) | grep ^UUID) + sed -e "s#root=[^ ]*#root=${rootdevuuid}#g" -i "${target}" # Workaround for broken systemd in centos7 systemctl enable incus-agent-workaround.service @@ -851,8 +852,8 @@ actions: target="$(readlink -f /etc/grub2-efi.cfg)" grub2-mkconfig -o "${target}" - - sed -i "s#root=[^ ]*#root=/dev/sda2#g" "${target}" + rootdevuuid=$(blkid -o export $(echo -n /dev/loop[0-9]*p2) | grep ^UUID) + sed -e "s#root=[^ ]*#root=${rootdevuuid}#g" -i "${target}" types: - vm releases: @@ -867,11 +868,12 @@ actions: # Create grub.cfg file grub2-mkconfig -o "${target}" - sed -i "s#root=[^ ]*#root=/dev/sda2#g" "${target}" + rootdevuuid=$(blkid -o export $(echo -n /dev/loop[0-9]*p2) | grep ^UUID) + sed -e "s#root=[^ ]*#root=${rootdevuuid}#g" -i "${target}" # Update files in /boot/loader/entries/. `grubby` needs to be run after # `grub2-mkconfig` as the latter overwrites files in /boot/loader/entries/. - grubby --update-kernel=/boot/vmlinuz-${kver} --args="root=/dev/sda2 ro" + grubby --update-kernel=/boot/vmlinuz-${kver} --args="root=${rootdevuuid} ro" # Regenerate initramfs dracut --kver "${kver}" -f diff --git a/images/debian.yaml b/images/debian.yaml index 7c096a01..d85e78b9 100644 --- a/images/debian.yaml +++ b/images/debian.yaml @@ -1478,7 +1478,8 @@ actions: grub-install --uefi-secure-boot --target="${TARGET}-efi" --no-nvram update-grub - sed -i "s#root=[^ ]*#root=/dev/sda2#g" /boot/grub/grub.cfg + rootdevuuid=$(blkid -o export $(echo -n /dev/loop[0-9]*p2) | grep ^UUID) + sed -e "s#root=[^ ]*#root=${rootdevuuid}#g" -i /boot/grub/grub.cfg types: - vm releases: diff --git a/images/fedora.yaml b/images/fedora.yaml index c046e71d..dcd4488f 100644 --- a/images/fedora.yaml +++ b/images/fedora.yaml @@ -353,7 +353,8 @@ actions: target=/boot/efi/EFI/fedora/grub.cfg grub2-mkconfig -o "${target}" - sed -i "s#root=[^ ]*#root=/dev/sda2#g" "${target}" + rootdevuuid=$(blkid -o export $(echo -n /dev/loop[0-9]*p2) | grep ^UUID) + sed -e "s#root=[^ ]*#root=${rootdevuuid}#g" -i "${target}" sed -Eri "s#^(linux|initrd) .+/overlay/#\1 /#g" /boot/loader/entries/* sed -ri 's#^options .+#options $kernelopts#g' /boot/loader/entries/* diff --git a/images/gentoo.yaml b/images/gentoo.yaml index 22371a48..60e8776f 100644 --- a/images/gentoo.yaml +++ b/images/gentoo.yaml @@ -577,8 +577,8 @@ actions: rm -Rf /boot/* /boot/efi/* || true systemd-machine-id-setup bootctl install --no-variables --esp-path=/boot/efi/ - - echo "root=/dev/sda2" >> /etc/kernel/cmdline + rootdevuuid=$(blkid -o export $(echo -n /dev/loop[0-9]*p2) | grep ^UUID) + echo "root=${rootdevuuid}" >> /etc/kernel/cmdline echo "sys-apps/systemd kernel-install" >> /etc/portage/package.use/systemd echo "sys-kernel/installkernel dracut systemd systemd-boot" >> /etc/portage/package.use/installkernel @@ -668,7 +668,8 @@ actions: grub-install --target=${TARGET}-efi --no-nvram --removable grub-install --target=${TARGET}-efi --no-nvram grub-mkconfig -o /boot/grub/grub.cfg - sed -i "s#root=[^ ]*#root=/dev/sda2#g" /boot/grub/grub.cfg + rootdevuuid=$(blkid -o export $(echo -n /dev/loop[0-9]*p2) | grep ^UUID) + sed -e "s#root=[^ ]*#root=${rootdevuuid}#g" -i /boot/grub/grub.cfg types: - vm variants: diff --git a/images/openeuler.yaml b/images/openeuler.yaml index eb0d4089..8da621e2 100644 --- a/images/openeuler.yaml +++ b/images/openeuler.yaml @@ -356,8 +356,8 @@ actions: grub2-mkconfig -o "${target}" umount /sys/firmware - - sed -i "s#root=[^ ]*#root=/dev/sda2#g" "${target}" + rootdevuuid=$(blkid -o export $(echo -n /dev/loop[0-9]*p2) | grep ^UUID) + sed -e "s#root=[^ ]*#root=${rootdevuuid}#g" -i "${target}" # Workaround for broken systemd in centos7 systemctl enable incus-agent-workaround.service diff --git a/images/opensuse.yaml b/images/opensuse.yaml index 65048339..2f02ad47 100644 --- a/images/opensuse.yaml +++ b/images/opensuse.yaml @@ -409,7 +409,8 @@ actions: grub2-mkconfig -o /boot/grub2/grub.cfg umount /sys/firmware - sed -i "s#root=[^ ]*#root=/dev/sda2#g" /boot/grub2/grub.cfg + rootdevuuid=$(blkid -o export $(echo -n /dev/loop[0-9]*p2) | grep ^UUID) + sed -e "s#root=[^ ]*#root=${rootdevuuid}#g" -i /boot/grub2/grub.cfg types: - vm diff --git a/images/rockylinux.yaml b/images/rockylinux.yaml index 3edb1303..d5808308 100644 --- a/images/rockylinux.yaml +++ b/images/rockylinux.yaml @@ -360,7 +360,8 @@ actions: dracut --kver "${kver}" -f target="$(readlink -f /etc/grub2-efi.cfg)" grub2-mkconfig -o "${target}" - sed -i "s#root=[^ ]*#root=/dev/sda2#g" "${target}" + rootdevuuid=$(blkid -o export $(echo -n /dev/loop[0-9]*p2) | grep ^UUID) + sed -e "s#root=[^ ]*#root=${rootdevuuid}#g" -i "${target}" types: - vm releases: @@ -374,10 +375,12 @@ actions: target=/boot/efi/EFI/rocky/grub.cfg # Create grub.cfg file grub2-mkconfig -o "${target}" - sed -i "s#root=[^ ]*#root=/dev/sda2#g" "${target}" + rootdevuuid=$(blkid -o export $(echo -n /dev/loop[0-9]*p2) | grep ^UUID) + sed -e "s#root=[^ ]*#root=${rootdevuuid}#g" -i "${target}" + # Update files in /boot/loader/entries/. `grubby` needs to be run after # `grub2-mkconfig` as the latter overwrites files in /boot/loader/entries/. - grubby --update-kernel=/boot/vmlinuz-${kver} --args="root=/dev/sda2 ro" + grubby --update-kernel=/boot/vmlinuz-${kver} --args="root=${rootdevuuid} ro" # Regenerate initramfs dracut --kver "${kver}" -f types: diff --git a/images/springdalelinux.yaml b/images/springdalelinux.yaml index 4c5636a4..9f2c7737 100644 --- a/images/springdalelinux.yaml +++ b/images/springdalelinux.yaml @@ -431,7 +431,8 @@ actions: umount /sys/firmware - sed -i "s#root=[^ ]*#root=/dev/sda2#g" "${target}" + rootdevuuid=$(blkid -o export $(echo -n /dev/loop[0-9]*p2) | grep ^UUID) + sed -e "s#root=[^ ]*#root=${rootdevuuid}#g" -i "${target}" # Workaround for broken systemd in centos7 systemctl enable incus-agent-workaround.service @@ -452,7 +453,8 @@ actions: target="$(readlink -f /etc/grub2-efi.cfg)" grub2-mkconfig -o "${target}" - sed -i "s#root=[^ ]*#root=/dev/sda2#g" "${target}" + rootdevuuid=$(blkid -o export $(echo -n /dev/loop[0-9]*p2) | grep ^UUID) + sed -e "s#root=[^ ]*#root=${rootdevuuid}#g" -i "${target}" types: - vm releases: diff --git a/images/ubuntu.yaml b/images/ubuntu.yaml index 0f6101a6..ee183f5d 100644 --- a/images/ubuntu.yaml +++ b/images/ubuntu.yaml @@ -713,7 +713,8 @@ actions: grub-install --uefi-secure-boot --target="${TARGET}-efi" --no-nvram update-grub - sed -i "s#root=[^ ]*#root=/dev/sda2#g" /boot/grub/grub.cfg + rootdevuuid=$(blkid -o export $(echo -n /dev/loop[0-9]*p2) | grep ^UUID) + sed -e "s#root=[^ ]*#root=${rootdevuuid}#g" -i /boot/grub/grub.cfg types: - vm