Skip to content

Commit

Permalink
images: Fixed hardcoded root partition device name sda2 (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomponline authored Aug 6, 2024
2 parents 1b8780e + 09a4f7a commit 005cae7
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions images/almalinux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ actions:
target="$(readlink -f /etc/grub2-efi.cfg)"
grub2-mkconfig -o "${target}"
sed -i "s#root=[^ ]*#root=/dev/sda2#g" "${target}"
sed -i "s#root=[^ ]*#root=${LXD_IMAGEBUILDER_ROOT_UUID}#g" "${target}"
types:
- vm
releases:
Expand All @@ -427,11 +427,11 @@ actions:
# Create grub.cfg file
grub2-mkconfig -o "${target}"
sed -i "s#root=[^ ]*#root=/dev/sda2#g" "${target}"
sed -i "s#root=[^ ]*#root=${LXD_IMAGEBUILDER_ROOT_UUID}#g" "${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=${LXD_IMAGEBUILDER_ROOT_UUID} ro"
# Regenerate initramfs
dracut --kver "${kver}" -f
Expand Down
2 changes: 1 addition & 1 deletion images/alpine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ actions:
target=/boot/grub/grub.cfg
grub-mkconfig -o "${target}"
sed -i "s#root=[^ ]*#root=/dev/sda2#g" "${target}"
sed -i "s#root=[^ ]*#root=${LXD_IMAGEBUILDER_ROOT_UUID}#g" "${target}"
TARGET="x86_64"
[ "$(uname -m)" = "aarch64" ] && TARGET="arm64"
Expand Down
2 changes: 1 addition & 1 deletion images/archlinux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ 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
sed -i "s#root=[^ ]*#root=${LXD_IMAGEBUILDER_ROOT_UUID}#g" /boot/grub/grub.cfg
# Rebuild initrd
sed -i 's#^MODULES=.*#MODULES=(virtio_pci virtio_scsi virtio_console)#' /etc/mkinitcpio.conf
Expand Down
4 changes: 2 additions & 2 deletions images/centos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -413,11 +413,11 @@ actions:
# Create grub.cfg file
grub2-mkconfig -o "${target}"
sed -i "s#root=[^ ]*#root=/dev/sda2#g" "${target}"
sed -i "s#root=[^ ]*#root=${LXD_IMAGEBUILDER_ROOT_UUID}#g" "${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=${LXD_IMAGEBUILDER_ROOT_UUID} ro"
# Regenerate initramfs
dracut --kver "${kver}" -f
Expand Down
2 changes: 1 addition & 1 deletion images/debian.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1386,7 +1386,7 @@ 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
sed -i "s#root=[^ ]*#root=${LXD_IMAGEBUILDER_ROOT_UUID}#g" /boot/grub/grub.cfg
types:
- vm

Expand Down
2 changes: 1 addition & 1 deletion images/fedora.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ actions:
target=/boot/efi/EFI/fedora/grub.cfg
grub2-mkconfig -o "${target}"
sed -i "s#root=[^ ]*#root=/dev/sda2#g" "${target}"
sed -i "s#root=[^ ]*#root=${LXD_IMAGEBUILDER_ROOT_UUID}#g" "${target}"
sed -Eri "s#^(linux|initrd) .+/overlay/#\1 /#g" /boot/loader/entries/*
sed -ri 's#^options .+#options $kernelopts#g' /boot/loader/entries/*
Expand Down
4 changes: 2 additions & 2 deletions images/gentoo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ actions:
systemd-machine-id-setup
bootctl install --no-variables --esp-path=/boot/efi/
echo "root=/dev/sda2" >> /etc/kernel/cmdline
echo "root=${LXD_IMAGEBUILDER_ROOT_UUID}" >> /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
Expand Down Expand Up @@ -673,7 +673,7 @@ 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
sed -i "s#root=[^ ]*#root=${LXD_IMAGEBUILDER_ROOT_UUID}#g" /boot/grub/grub.cfg
types:
- vm
variants:
Expand Down
2 changes: 1 addition & 1 deletion images/openeuler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ actions:
umount /sys/firmware
sed -i "s#root=[^ ]*#root=/dev/sda2#g" "${target}"
sed -i "s#root=[^ ]*#root=${LXD_IMAGEBUILDER_ROOT_UUID}#g" "${target}"
# Workaround for broken systemd in centos7
systemctl enable lxd-agent-workaround.service
Expand Down
2 changes: 1 addition & 1 deletion images/opensuse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ actions:
grub2-mkconfig -o /boot/grub2/grub.cfg
umount /sys/firmware
sed -i "s#root=[^ ]*#root=/dev/sda2#g" /boot/grub2/grub.cfg
sed -i "s#root=[^ ]*#root=${LXD_IMAGEBUILDER_ROOT_UUID}#g" /boot/grub2/grub.cfg
types:
- vm

Expand Down
6 changes: 3 additions & 3 deletions images/rockylinux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ 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}"
sed -i "s#root=[^ ]*#root=${LXD_IMAGEBUILDER_ROOT_UUID}#g" "${target}"
types:
- vm
releases:
Expand All @@ -357,10 +357,10 @@ 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}"
sed -i "s#root=[^ ]*#root=${LXD_IMAGEBUILDER_ROOT_UUID}#g" "${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=${LXD_IMAGEBUILDER_ROOT_UUID} ro"
# Regenerate initramfs
dracut --kver "${kver}" -f
types:
Expand Down
4 changes: 2 additions & 2 deletions images/springdalelinux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ actions:
umount /sys/firmware
sed -i "s#root=[^ ]*#root=/dev/sda2#g" "${target}"
sed -i "s#root=[^ ]*#root=${LXD_IMAGEBUILDER_ROOT_UUID}#g" "${target}"
# Workaround for broken systemd in centos7
systemctl enable lxd-agent-workaround.service
Expand All @@ -459,7 +459,7 @@ actions:
target="$(readlink -f /etc/grub2-efi.cfg)"
grub2-mkconfig -o "${target}"
sed -i "s#root=[^ ]*#root=/dev/sda2#g" "${target}"
sed -i "s#root=[^ ]*#root=${LXD_IMAGEBUILDER_ROOT_UUID}#g" "${target}"
types:
- vm
releases:
Expand Down
2 changes: 1 addition & 1 deletion images/ubuntu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ 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
sed -i "s#root=[^ ]*#root=${LXD_IMAGEBUILDER_ROOT_UUID}#g" /boot/grub/grub.cfg
types:
- vm

Expand Down

0 comments on commit 005cae7

Please sign in to comment.