Hello,
I know it’s early, but I wanted to try and setup some base rocky images so we are ready to migrate.
I’ve used packer to create our current centos 8 images, I tried switching out the ISO url to the rocky one but no luck the VM is stuck waiting for something on the dracut side:
The hcl I’ve used:
source "hyperv-iso" "rocky8" {
boot_command = [
"c",
"setparams 'kickstart'<enter>",
"linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=Rocky-8-3-x86_64-dvd inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg<enter>",
"initrdefi /images/pxeboot/initrd.img<enter>",
"boot<enter>"
]
boot_wait = "2s"
enable_dynamic_memory = true
enable_virtualization_extensions = false
generation = 2
http_directory = "."
iso_checksum = "sha256:fba979fde098027df79b4b686359a8e22daad7f6b269f34887dbe3a53f7cf73a"
iso_url = "https://download.rockylinux.org/pub/rocky/8.3/isos/x86_64/Rocky-8.3-x86_64-minimal.iso"
output_directory = "build"
shutdown_command = "echo 'packer' | sudo -S shutdown -P now"
ssh_password = "vagrant"
ssh_timeout = "10m"
ssh_username = "vagrant"
vm_name = "packer_vdl-rocky8"
}
build {
sources = ["source.hyperv-iso.rocky8"]
post-processor "vagrant" {
keep_input_artifact = true
output = "build/vdl-rocky8_{{ .Provider }}.box"
vagrantfile_template = "./Vagrantfile.template"
}
}
1 Like
What does your kickstart look like?
Also, you reference the HD label as the DVD and then use the minimal install iso is that intentional?
“Stripped down” version:
install
cdrom
lang en_US.UTF-8 --addsupport=en_GB.UTF-8,fr_BE.UTF-8
keyboard be
network --bootproto=dhcp
rootpw vagrant
firewall --disabled
timezone UTC
bootloader --location=mbr
text
skipx
zerombr
clearpart --all --initlabel
autopart --nohome --nolvm
firstboot --disabled
eula --agreed
services --enabled=NetworkManager,sshd,hypervfcopyd,hypervkvpd,hypervvssd
user --name=vagrant --plaintext --password=vagrant --groups=wheel
reboot
%packages --excludedocs
@Base
@Core
openssh-clients
sudo
net-tools
curl
# hyperv stuff
hyperv-daemons
# unnecessary stuff for servers
-cockpit
-quota
-fprintd*
-parted
# unnecessary firmware
-aic94xx-firmware
-alsa-firmware
-alsa-tools-firmware
-atmel-firmware
-b43-openfwwf
-bfa-firmware
-dracut-config-rescue
-ipw*-firmware
-irqbalance
-ivtv-firmware
-iwl*-firmware
-kernel-firmware
-libertas-usb8388-firmware
-microcode_ctl
-ql*-firmware
-rt61pci-firmware
-rt73usb-firmware
-xorg-x11-drv-ati-firmware
-zd1211-firmware
%end
%post
set -x
dnf update -y
dnf clean all
echo 'SUBSYSTEM=="memory", ACTION=="add", ATTR{state}="online"' > /etc/udev/rules.d/100-hyperv-dynamic-memory.rules
echo 'ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/scheduler}="none"' > /etc/udev/rules.d/100-hyperv-none-scheduler.rules
# sudo
echo "vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/vagrant
sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers
mkdir -p /home/vagrant/.ssh
(umask 0077 && curl -sLo /home/vagrant/.ssh/authorized_keys https://github.com/hashicorp/vagrant/raw/master/keys/vagrant.pub)
chown -R vagrant: /home/vagrant/.ssh
%end
Because the label of the iso is wrong, the minimal iso has the same label as the dvd:
$ isoinfo -d -i packer_cache/dddb8a2d7e41ad397d9d92442fb00d0241ecda6f.iso | grep 'Volume id'
Volume id: Rocky-8-3-x86_64-dvd
Not sure what happened, but the file I was using didn’t contain :LABEL=
in the inst.stage2
param. Adding it back and it works perfectly.
Also, I had to switch to the DVD image since minimal doesn’t contain the hyperv daemons.
1 Like
bendem
November 8, 2021, 10:50am
5
Thought I’d come back and show our final setup since people might be interested:
Build script
$env:PACKER_CACHE_DIR = "$env:TEMP\packer_cache"
try {
Get-VMSwitch packer -ErrorAction Stop
} catch {
# the default switch doesn't have internet access so that's a no go
New-VMSwitch packer -NetAdapterName Ethernet -AllowManagementOS $true
# Windows sets some stuff up before the interface has internet
Start-Sleep -Seconds 1
}
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue output-rocky8
# packer build -var type=internal .\build.pkr.hcl
packer build .\build.pkr.hcl
Remove-VMSwitch packer -Force
build.pkr.hcl
source "hyperv-iso" "rocky8" {
boot_command = [
"c",
"setparams 'kickstart'<enter>",
"linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=Rocky-8-4-x86_64-dvd inst.ks=hd:LABEL=ksdata:ks.cfg<enter>",
"initrdefi /images/pxeboot/initrd.img<enter>",
"boot<enter>"
]
boot_wait = "2s"
enable_dynamic_memory = true
enable_virtualization_extensions = false
generation = 2
iso_checksum = "sha256:ffe2fae67da6702d859cfb0b321561a5d616ce87a963d8a25b018c9c3d52d9a4"
iso_url = "https://download.rockylinux.org/pub/rocky/8/isos/x86_64/Rocky-8.4-x86_64-dvd1.iso"
disable_shutdown = true
shutdown_timeout = "10m"
communicator = "none"
vm_name = "packer_vdl-rocky8"
switch_name = "packer"
cd_files = [
"ks.cfg",
]
cd_label = "ksdata"
}
build {
sources = ["source.hyperv-iso.rocky8"]
post-processor "compress" {
keep_input_artifact = true
output = "{{.BuildName}}_{{.BuilderType}}.zip"
}
# post-processor "vagrant" {
# keep_input_artifact = true
# output = "build/vdl-rocky8_hyperv.box"
# vagrantfile_template = "./Vagrantfile.template"
# }
}
ks.cfg
cdrom
lang en_US.UTF-8 --addsupport=en_GB.UTF-8,fr_BE.UTF-8
keyboard be
network --bootproto=dhcp
rootpw --iscrypted ...
firewall --disabled
timezone UTC
bootloader --location=mbr
text
skipx
zerombr
clearpart --all --initlabel
autopart --nohome --type=lvm
firstboot --disabled
eula --agreed
services --enabled=NetworkManager,sshd,hypervfcopyd,hypervkvpd,hypervvssd
user --name=dsi --lock --groups=wheel
poweroff
%packages --excludedocs
@Base
@Core
openssh-clients
sudo
net-tools
curl
# hyperv stuff
hyperv-daemons
# unnecessary stuff for servers
-cockpit
-quota
-fprintd*
-parted
# unnecessary firmware
-aic94xx-firmware
-alsa-firmware
-alsa-tools-firmware
-atmel-firmware
-b43-openfwwf
-bfa-firmware
-dracut-config-rescue
-ipw*-firmware
-irqbalance
-ivtv-firmware
-iwl*-firmware
-kernel-firmware
-libertas-usb8388-firmware
-microcode_ctl
-ql*-firmware
-rt61pci-firmware
-rt73usb-firmware
-xorg-x11-drv-ati-firmware
-zd1211-firmware
%end
%post
set -x
dnf update -y
dnf clean all
echo 'SUBSYSTEM=="memory", ACTION=="add", ATTR{state}="online"' > /etc/udev/rules.d/100-hyperv-dynamic-memory.rules
echo 'ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/scheduler}="none"' > /etc/udev/rules.d/100-hyperv-none-scheduler.rules
# sudo
echo "dsi ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/dsi
sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers
mkdir -p /home/dsi/.ssh
(umask 0077 && echo '...' >> /home/dsi/.ssh/authorized_keys)
chown -R dsi: /home/dsi/.ssh
%end