canonical / packer-maas

Packer templates to create MAAS deployable images
Other
287 stars 174 forks source link

VFS: Unable to mount root fs Centos9 Custom #268

Open AlexVlan opened 1 month ago

AlexVlan commented 1 month ago

I am trying to run my “centos-9 Custom” image in “maas” using packer to build. My build works, after I try to install os in “proxmox” I get the following errors:

[  0.873208] Please append a correct "root=" boot option; here are the available partitions:
[  0.873208] 0b00      1048575 sr0
[  0.873208] driver: sr
[  0.873550] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[  0.873873] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.4.0-190-generic #210~18.04.1-Ubuntu
[  0.874191] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.1-0-g3208b098f51a-prebuilt.qemu.org 04/01/2014
[  0.874566] Call Trace:
[  0.874735]  dump_stack+0x6d/0x8b
[  0.874909]  panic+0x114/0x2fd
[  0.875070]  mount_block_root+0x23f/0x2e8
[  0.875264]  mount_root+0x38/0x3a
[  0.875441]  prepare_namespace+0x13f/0x194
[  0.875544]  kernel_init_freeable+0x265/0x289
[  0.875820]  ? rest_init+0xb0/0xb0
[  0.876020]  kernel_init+0xe/0x110
[  0.876217]  ret_from_fork+0x35/0x40
[  0.876377] Kernel Offset: 0x2c600000 from 0xffffffff81000000 (relocation range: 0xffffffff81000000 - 0xffffffffbfffffff)
[  0.876747] ---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0) ]---

I am using the standard packer-maas for centos-9-stream, my “centos9-stream.ks.pkrtpl.hcl:

poweroff
firewall --enabled --service=ssh
firstboot --disable
ignoredisk --only-use=vda
lang en_US.UTF-8
keyboard us
network --device eth0 --bootproto=dhcp
firewall --enabled --service=ssh
selinux --enforcing
timezone UTC --isUtc
bootloader --location=mbr --driveorder="vda" --timeout=1
rootpw --plaintext password

repo --name=baseos ${KS_BASEOS_REPOS} ${KS_PROXY}
repo --name=appstream ${KS_APPSTREAM_REPOS} ${KS_PROXY}
repo --name=centos ${KS_CENTOS_REPOS} ${KS_PROXY}

zerombr
clearpart --all --initlabel
part / --size=1 --grow --asprimary --fstype=ext4

%post --erroronfail
# workaround anaconda requirements and clear root password
passwd -d root
passwd -l root

# Clean up install config not applicable to deployed environments.
for f in resolv.conf fstab; do
    rm -f /etc/$f
    touch /etc/$f
    chown root:root /etc/$f
    chmod 644 /etc/$f
done

rm -f /etc/sysconfig/network-scripts/ifcfg-[^lo]*

# Kickstart copies install boot options. Serial is turned on for logging with
# Packer which disables console output. Disable it so console output is shown
# during deployments
sed -i 's/^GRUB_TERMINAL=.*/GRUB_TERMINAL_OUTPUT="console"/g' /etc/default/grub
sed -i '/GRUB_SERIAL_COMMAND="serial"/d' /etc/default/grub
sed -ri 's/(GRUB_CMDLINE_LINUX=".*)\s+console=ttyS0(.*")/\1\2/' /etc/default/grub
sed -i 's/GRUB_ENABLE_BLSCFG=.*/GRUB_ENABLE_BLSCFG=false/g' /etc/default/grub

dnf clean all
%end

%packages
@core
bash-completion
cloud-init
# cloud-init only requires python3-oauthlib with MAAS. As such upstream
# removed this dependency.
python3-oauthlib
rsync
tar
# grub2-efi-x64 ships grub signed for UEFI secure boot. If grub2-efi-x64-modules
# is installed grub will be generated on deployment and unsigned which breaks
# UEFI secure boot.
grub2-efi-x64
efibootmgr
shim-x64
dosfstools
lvm2
mdadm
device-mapper-multipath
iscsi-initiator-utils
-plymouth
# Remove Intel wireless firmware
-i*-firmware
%end

My image build process:

packer init centos9-stream.pkr.hcl && packer build -var timeout=1h centos9-stream.pkr.hcl
2024/09/17 11:08:38 [INFO] Packer version: 1.11.2 [go1.21.12 linux amd64]
2024/09/17 11:08:38 [INFO] PACKER_CONFIG env var not set; checking the default config file path
2024/09/17 11:08:38 [INFO] PACKER_CONFIG env var set; attempting to open config file: /root/.packerconfig
2024/09/17 11:08:38 [WARN] Config file doesn't exist: /root/.packerconfig
2024/09/17 11:08:38 [INFO] Setting cache directory: /root/.cache/packer
2024/09/17 11:08:38 [TRACE] init: plugingetter.ListInstallationsOptions{PluginDirectory:"/root/.config/packer/plugins", BinaryInstallationOptions:plugingetter.BinaryInstallationOptions{APIVersionMajor:"5", APIVersionMinor:"0", OS:"linux", ARCH:"amd64", Ext:"", Checksummers:[]plugingetter.Checksummer{plugingetter.Checksummer{Type:"sha256", Hash:(*sha256.digest)(0xc0005fa000)}}, ReleasesOnly:true}}
2024/09/17 11:08:38 [TRACE] listing potential installations for "github.com/hashicorp/qemu" that match "~> 1.0". plugingetter.ListInstallationsOptions{PluginDirectory:"/root/.config/packer/plugins", BinaryInstallationOptions:plugingetter.BinaryInstallationOptions{APIVersionMajor:"5", APIVersionMinor:"0", OS:"linux", ARCH:"amd64", Ext:"", Checksummers:[]plugingetter.Checksummer{plugingetter.Checksummer{Type:"sha256", Hash:(*sha256.digest)(0xc0005fa000)}}, ReleasesOnly:true}}
2024/09/17 11:08:38 [INFO] (telemetry) Finalizing.

***

2024/09/17 11:20:12 packer-plugin-qemu_v1.1.0_x5.0_linux_amd64 plugin: 2024/09/17 11:20:12 VM shut down.
==> qemu.centos9-stream: Converting hard drive...
2024/09/17 11:20:12 packer-plugin-qemu_v1.1.0_x5.0_linux_amd64 plugin: 2024/09/17 11:20:12 Executing qemu-img: []string{"convert", "-O", "qcow2", "output-centos9-stream/packer-centos9-stream", "output-centos9-stream/packer-centos9-stream.convert"}
2024/09/17 11:20:13 packer-plugin-qemu_v1.1.0_x5.0_linux_amd64 plugin: 2024/09/17 11:20:13 stdout:
2024/09/17 11:20:13 packer-plugin-qemu_v1.1.0_x5.0_linux_amd64 plugin: 2024/09/17 11:20:13 stderr:
2024/09/17 11:20:14 packer-plugin-qemu_v1.1.0_x5.0_linux_amd64 plugin: 2024/09/17 11:20:14 failed to unlock port lockfile: close tcp 127.0.0.1:5924: use of closed network connection
2024/09/17 11:20:14 [INFO] (telemetry) ending qemu.centos9-stream
2024/09/17 11:20:14 [INFO] (telemetry) Starting post-processor shell-local
==> qemu.centos9-stream: Running post-processor:  (type shell-local)
2024/09/17 11:20:14 packer-post-processor-shell-local plugin: [INFO] (shell-local): Prepending inline script with #!/bin/bash -e
2024/09/17 11:20:14 packer-post-processor-shell-local plugin: [INFO] (shell-local): starting local command: /bin/sh -c PACKER_BUILDER_TYPE='qemu' PACKER_BUILD_NAME='centos9-stream' PACKER_HTTP_ADDR='10.0.2.2:8384' PACKER_HTTP_IP='10.0.2.2' PACKER_HTTP_PORT='8384'  /tmp/packer-shell3223465247
2024/09/17 11:20:14 packer-post-processor-shell-local plugin: [INFO] (shell-local communicator): Executing local shell command [/bin/sh -c PACKER_BUILDER_TYPE='qemu' PACKER_BUILD_NAME='centos9-stream' PACKER_HTTP_ADDR='10.0.2.2:8384' PACKER_HTTP_IP='10.0.2.2' PACKER_HTTP_PORT='8384'  /tmp/packer-shell3223465247]
==> qemu.centos9-stream (shell-local): Running local shell script: /tmp/packer-shell3223465247
==> qemu.centos9-stream (shell-local): ++ PACKER_OUTPUT=output-centos9-stream/packer-centos9-stream
==> qemu.centos9-stream (shell-local): ++ IMG_FMT=qcow2
==> qemu.centos9-stream (shell-local): ++ '[' '!' -f output-centos9-stream/packer-centos9-stream ']'
==> qemu.centos9-stream (shell-local): ++ sync -f output-centos9-stream/packer-centos9-stream
==> qemu.centos9-stream (shell-local): +++ mktemp -d /tmp/packer-maas-XXXX
==> qemu.centos9-stream (shell-local): ++ TMP_DIR=/tmp/packer-maas-6vRG
==> qemu.centos9-stream (shell-local): ++ trap cleanup EXIT
==> qemu.centos9-stream (shell-local): ++ sleep 5
==> qemu.centos9-stream (shell-local): ++ qemu-nbd --socket=/tmp/packer-maas-6vRG/qemu-img.sock --format=qcow2 --shared=10 output-centos9-stream/packer-centos9-stream
==> qemu.centos9-stream (shell-local): ++ mkdir -p /tmp/packer-maas-6vRG/root
==> qemu.centos9-stream (shell-local): + source ../scripts/fuse-tar-root
==> qemu.centos9-stream (shell-local): ++ ROOT_PARTITION=1
    qemu.centos9-stream (shell-local): Mounting root partition...
==> qemu.centos9-stream (shell-local): ++ ROOT_MOUNT=/tmp/packer-maas-6vRG/root
==> qemu.centos9-stream (shell-local): ++ DETECT_BLS_BOOT=0
==> qemu.centos9-stream (shell-local): ++ BOOT_MOUNT=/tmp/packer-maas-6vRG/boot
==> qemu.centos9-stream (shell-local): ++ echo 'Mounting root partition...'
==> qemu.centos9-stream (shell-local): ++ mount_part 1 /tmp/packer-maas-6vRG/root
==> qemu.centos9-stream (shell-local): ++ PART=1
==> qemu.centos9-stream (shell-local): ++ MOUNTPOINT=/tmp/packer-maas-6vRG/root
==> qemu.centos9-stream (shell-local): ++ FUSEDRV=fuse2fs
==> qemu.centos9-stream (shell-local): ++ DEV=/tmp/packer-maas-6vRG/p1
==> qemu.centos9-stream (shell-local): ++ mkdir -p /tmp/packer-maas-6vRG/root
==> qemu.centos9-stream (shell-local): ++ mkdir -p /tmp/packer-maas-6vRG/p1
==> qemu.centos9-stream (shell-local): ++ retries=0
==> qemu.centos9-stream (shell-local): ++ '[' -f /tmp/packer-maas-6vRG/p1/nbd ']'
==> qemu.centos9-stream (shell-local): ++ sleep 1
==> qemu.centos9-stream (shell-local): ++ nbdfuse /tmp/packer-maas-6vRG/p1 --command nbdkit -s nbd socket=/tmp/packer-maas-6vRG/qemu-img.sock --filter=partition partition=1
==> qemu.centos9-stream (shell-local): ++ (( ++retries > 10 ))
==> qemu.centos9-stream (shell-local): ++ '[' -f /tmp/packer-maas-6vRG/p1/nbd ']'
==> qemu.centos9-stream (shell-local): ++ case "${FUSEDRV}" in
==> qemu.centos9-stream (shell-local): ++ fuse2fs /tmp/packer-maas-6vRG/p1/nbd /tmp/packer-maas-6vRG/root -o fakeroot
==> qemu.centos9-stream (shell-local): ++ '[' -f /tmp/packer-maas-6vRG/root/etc/machine-id ']'
    qemu.centos9-stream (shell-local): reseting machine-id...
==> qemu.centos9-stream (shell-local): ++ echo 'reseting machine-id...'
==> qemu.centos9-stream (shell-local): ++ :
==> qemu.centos9-stream (shell-local): ++ '[' -f /tmp/packer-maas-6vRG/root/var/lib/cloud/instance ']'
==> qemu.centos9-stream (shell-local): ++ '[' -d curtin ']'
==> qemu.centos9-stream (shell-local): ++ '[' -d '' ']'
==> qemu.centos9-stream (shell-local): ++ echo 'Creating MAAS image centos9-stream.tar.gz...'
    qemu.centos9-stream (shell-local): Creating MAAS image centos9-stream.tar.gz...
==> qemu.centos9-stream (shell-local): ++ TARFILE=centos9-stream.tar
==> qemu.centos9-stream (shell-local): ++ tar -Scpf centos9-stream.tar --acls --selinux --xattrs --one-file-system --exclude-backups -C /tmp/packer-maas-6vRG/root .
==> qemu.centos9-stream (shell-local): ++ '[' 0 -eq 1 ']'
==> qemu.centos9-stream (shell-local): ++ gzip --best --force centos9-stream.tar
==> qemu.centos9-stream (shell-local): ++ '[' -n '' ']'
==> qemu.centos9-stream (shell-local): ++ sync
==> qemu.centos9-stream (shell-local): ++ fusermount -z -u /tmp/packer-maas-6vRG/root
==> qemu.centos9-stream (shell-local): ++ grep -qs '/tmp/packer-maas-6vRG/root ' /proc/mounts
    qemu.centos9-stream (shell-local): Done
==> qemu.centos9-stream (shell-local): ++ echo Done
==> qemu.centos9-stream (shell-local): + rm -rf output-centos9-stream
==> qemu.centos9-stream (shell-local): + cleanup
==> qemu.centos9-stream (shell-local): + for dev in "${TMP_DIR}"/p*/ "${TMP_DIR}"/disk/ "${TMP_DIR}"/boot/
==> qemu.centos9-stream (shell-local): + dev=/tmp/packer-maas-6vRG/p1
==> qemu.centos9-stream (shell-local): + '[' -d /tmp/packer-maas-6vRG/p1 ']'
==> qemu.centos9-stream (shell-local): + fusermount -u -z /tmp/packer-maas-6vRG/p1
==> qemu.centos9-stream (shell-local): + grep -qs '/tmp/packer-maas-6vRG/p1 ' /proc/mounts
==> qemu.centos9-stream (shell-local): + for dev in "${TMP_DIR}"/p*/ "${TMP_DIR}"/disk/ "${TMP_DIR}"/boot/
==> qemu.centos9-stream (shell-local): + dev=/tmp/packer-maas-6vRG/disk
==> qemu.centos9-stream (shell-local): + '[' -d /tmp/packer-maas-6vRG/disk ']'
==> qemu.centos9-stream (shell-local): + for dev in "${TMP_DIR}"/p*/ "${TMP_DIR}"/disk/ "${TMP_DIR}"/boot/
==> qemu.centos9-stream (shell-local): + dev=/tmp/packer-maas-6vRG/boot
==> qemu.centos9-stream (shell-local): + '[' -d /tmp/packer-maas-6vRG/boot ']'
==> qemu.centos9-stream (shell-local): + rm -rf /tmp/packer-maas-6vRG
2024/09/17 11:22:58 [INFO] (telemetry) ending shell-local
2024/09/17 11:22:58 Flagging to keep original artifact from post-processor 'shell-local'
==> Wait completed after 14 minutes 16 seconds
==> Builds finished. The artifacts of successful builds are:
2024/09/17 11:22:58 machine readable: qemu.centos9-stream,artifact-count []string{"2"}
Build 'qemu.centos9-stream' finished after 14 minutes 16 seconds.

==> Wait completed after 14 minutes 16 seconds

==> Builds finished. The artifacts of successful builds are:
2024/09/17 11:22:58 machine readable: qemu.centos9-stream,artifact []string{"0", "builder-id", "transcend.qemu"}
2024/09/17 11:22:58 machine readable: qemu.centos9-stream,artifact []string{"0", "id", "VM"}
2024/09/17 11:22:58 machine readable: qemu.centos9-stream,artifact []string{"0", "string", "VM files in directory: output-centos9-stream"}
2024/09/17 11:22:58 machine readable: qemu.centos9-stream,artifact []string{"0", "files-count", "1"}
2024/09/17 11:22:58 machine readable: qemu.centos9-stream,artifact []string{"0", "file", "0", "output-centos9-stream/packer-centos9-stream"}
2024/09/17 11:22:58 machine readable: qemu.centos9-stream,artifact []string{"0", "end"}
--> qemu.centos9-stream: VM files in directory: output-centos9-stream
2024/09/17 11:22:58 machine readable: qemu.centos9-stream,artifact []string{"1", "builder-id", "transcend.qemu"}
2024/09/17 11:22:58 machine readable: qemu.centos9-stream,artifact []string{"1", "id", "VM"}
2024/09/17 11:22:58 machine readable: qemu.centos9-stream,artifact []string{"1", "string", "VM files in directory: output-centos9-stream"}
2024/09/17 11:22:58 machine readable: qemu.centos9-stream,artifact []string{"1", "files-count", "1"}
2024/09/17 11:22:58 machine readable: qemu.centos9-stream,artifact []string{"1", "file", "0", "output-centos9-stream/packer-centos9-stream"}
2024/09/17 11:22:58 machine readable: qemu.centos9-stream,artifact []string{"1", "end"}
2024/09/17 11:22:58 [INFO] (telemetry) Finalizing.
--> qemu.centos9-stream: VM files in directory: output-centos9-stream
2024/09/17 11:22:58 waiting for all plugin processes to complete...
2024/09/17 11:22:58 /usr/bin/packer: plugin process exited
2024/09/17 11:22:58 /root/.config/packer/plugins/github.com/hashicorp/qemu/packer-plugin-qemu_v1.1.0_x5.0_linux_amd64: plugin process exited

If I using Ubuntu Custom, its good working. I have small skills for that works, and dont understand what is happen,

P.S I tryed changed the next directives:

network --bootproto=dhcp --onboot=yes --activate
bootloader --location=mbr
autopart --type=lvm
ignoredisk --only-use=sda
sed -i 's/GRUB_ENABLE_BLSCFG=true/GRUB_ENABLE_BLSCFG=false/g' /etc/default/grub
part / --size=1 --grow --fstype=ext4
network --bootproto=dhcp --onboot=yes --activate
part / --fstype xfs --grow --size=6144
part swap --fstype swap --size=512
auth --enableshadow --passalgo=sha512 --kickstart

one step, one change, its dont helped

jurekh commented 1 month ago

@AlexVlan just to clarify - does the problem happen when you use the image with MAAS? Or are you trying to use the image with proxmox?

AlexVlan commented 1 month ago

@AlexVlan just to clarify - does the problem happen when you use the image with MAAS? Or are you trying to use the image with proxmox?

when I use MAAS. I think this problem is due to the fact that when I build the image on my PC (sudo PACKER_LOG=1 packer build centos9-stream.pkr.hcl or make), I cannot use the disk sda during the build, e.g. bootloader --location=mbr --driveorder=“sda” --timeout=1. get error

==> qemu.centos9-stream (shell-local): ++ (( ++retries > 10 ))
==> qemu.centos9-stream (shell-local): ++ '[' -f /tmp/packer-maas-7iZo/p1/nbd ']'
==> qemu.centos9-stream (shell-local): ++ sleep 1
==> qemu.centos9-stream (shell-local): ++ (( ++retries > 10 ))
==> qemu.centos9-stream (shell-local): ++ return 1
==> qemu.centos9-stream (shell-local): + cleanup
==> qemu.centos9-stream (shell-local): + for dev in "${TMP_DIR}"/p*/ "${TMP_DIR}"/disk/ "${TMP_DIR}"/boot/
==> qemu.centos9-stream (shell-local): + dev=/tmp/packer-maas-7iZo/p1
==> qemu.centos9-stream (shell-local): + '[' -d /tmp/packer-maas-7iZo/p1 ']'
==> qemu.centos9-stream (shell-local): + fusermount -u -z /tmp/packer-maas-7iZo/p1
==> qemu.centos9-stream (shell-local): fusermount: failed to unmount /tmp/packer-maas-7iZo/p1: Invalid argument
2024/09/19 15:41:44 packer-post-processor-shell-local plugin: error: Script exited with non-zero exit status: 1. Allowed exit codes are: [0]
2024/09/19 15:41:44 [INFO] (telemetry) ending shell-local
2024/09/19 15:41:44 Deleting original artifact for build 'qemu.centos9-stream'

* Post-processor failed: Script exited with non-zero exit status: 1. Allowed exit codes are: [0]
==> Wait completed after 5 minutes 7 seconds
2024/09/19 15:41:44 machine readable: error-count []string{"1"}
==> Some builds didn't complete successfully and had errors:
2024/09/19 15:41:44 machine readable: qemu.centos9-stream,error []string{"1 error(s) occurred:\n\n* Post-processor failed: Script exited with non-zero exit status: 1. Allowed exit codes are: [0]"}

* Post-processor failed: Script exited with non-zero exit status: 1. Allowed exit codes are: [0]
==> Builds finished but no artifacts were created.
Build 'qemu.centos9-stream' errored after 5 minutes 7 seconds: 1 error(s) occurred:
2024/09/19 15:41:44 [INFO] (telemetry) Finalizing.```

It dont find such a disk. But I cant using that image(with the '''vda''') with my proxmox ,it have next storage on the test mashine:

AlexVlan commented 1 month ago

photo_2024-09-19_15-56-38

AlexVlan commented 1 month ago

I see the issue for solved for ubuntu, https://github.com/canonical/packer-maas/issues/155 but dont understand how do for Centos, it dont using any scripts

AlexVlan commented 1 month ago

Important! Read the logs, the problem was in the installation of the packages.

github-actions[bot] commented 5 days ago

This issue is stale because it has been open for 30 days with no activity.