Hello!
I created a custom ubuntu image with packer, but my script that works for the custom partition does not work with the custom image, more precisely the image automatically defines a disk capacity of its own. I set the “disk_size” parameter in the “ubuntu-lvm.pkr.hcl” file to 100G and then the generated script creates a /root partition of about 54GiB.
Finally, what I want to do is to use the 42-custom-lvm.sh commissioning script that works with the MAAS ubuntu standard image for the image I created with the packer. Which path should I follow for this.
Thanks.
My custom image configs:
ubuntu-lvm.pkr.hcl (I changed just disk_size)
scripts/curtin.sh (I added just “apt-get install ubuntu-desktop -yy”)
source "qemu" "lvm" {
boot_command = ["<wait>e<wait5>", "<down><wait><down><wait><down><wait2><end><wait5>", "<bs><bs><bs><bs><wait>autoinstall ---<wait><f10>"]
boot_wait = "2s"
cpus = 2
disk_size = "100G"
format = "raw"
headless = var.headless
http_directory = var.http_directory
iso_checksum = "file:http://releases.ubuntu.com/jammy/SHA256SUMS"
iso_target_path = "packer_cache/ubuntu.iso"
iso_url = "https://releases.ubuntu.com/jammy/ubuntu-22.04.3-live-server-amd64.iso"
memory = 2048
qemuargs = [
["-vga", "qxl"],
["-device", "virtio-blk-pci,drive=drive0,bootindex=0"],
["-device", "virtio-blk-pci,drive=cdrom0,bootindex=1"],
["-device", "virtio-blk-pci,drive=drive1,bootindex=2"],
["-drive", "if=pflash,format=raw,readonly=on,file=/usr/share/OVMF/OVMF_CODE.fd"],
["-drive", "if=pflash,format=raw,file=OVMF_VARS.fd"],
["-drive", "file=output-lvm/packer-lvm,if=none,id=drive0,cache=writeback,discard=ignore,format=raw"],
["-drive", "file=seeds-lvm.iso,format=raw,cache=none,if=none,id=drive1,readonly=on"],
["-drive", "file=packer_cache/ubuntu.iso,if=none,id=cdrom0,media=cdrom"]
]
shutdown_command = "sudo -S shutdown -P now"
ssh_handshake_attempts = 500
ssh_password = var.ssh_ubuntu_password
ssh_timeout = "5m"
ssh_username = "ubuntu"
ssh_wait_timeout = "5m"
}
build {
sources = ["source.qemu.lvm"]
provisioner "file" {
destination = "/tmp/curtin-hooks"
source = "${path.root}/scripts/curtin-hooks"
}
provisioner "shell" {
environment_vars = ["HOME_DIR=/home/ubuntu", "http_proxy=${var.http_proxy}", "https_proxy=${var.https_proxy}", "no_proxy=${var.no_proxy}"]
execute_command = "echo 'ubuntu' | {{ .Vars }} sudo -S -E sh -eux '{{ .Path }}'"
expect_disconnect = true
scripts = ["${path.root}/scripts/curtin.sh","${path.root}/scripts/networking.sh", "${path.root}/scripts/cleanup.sh"]
}
post-processor "compress" {
output = "custom-ubuntu-lvm.dd.gz"
}
}