Creating my first Vagrant box fails. Remote command exited with '1'. (Please delete the Vagrant thread)

Moderators: Please delete the Vagrant thread and adjust the title from the Vagrant thread to this one. I’m new here and didn’t know there are multiple categories. Thank you.

Hey there!

I’m planning to virtualize manjaro-arm-installer, so it can be run on every platform.
Docker was my initial aim, because I’m virtualizing an application.
But that so far turned out to be very difficult to do, due to the app running all sorts of systemd functions and also it’s a flasher app, so I probably want virtual partitions as well.
That way, if people choose the incorrect device to flash, it’s only a virtual partition that gets destroyed.

I figure that since manjaro-arm-installer is a CLI app,
and Manjaro releases only GUI OSes these days,
I’m better off building from Arch Linux and work my way up to Manjaro from there.

I’m using Elasticdog packer-arch as my template.

I then converted it’s json packerfile to hcl, took out the virtualbox/vmware/parrarel,
because I figure I only want to use QEMU/libvrt as being the most lightweight virtual machine after docker.

So this is where I’m at right now:

[folaht@pjehrsohmehj mai-base]$ packer build manjaro-arm-installer.pkr.hcl
qemu.mai: output will be in this color.

==> qemu.mai: Retrieving ISO
==> qemu.mai: Trying
==> qemu.mai: Trying
    qemu.mai: archlinux-2021.08.01-x86_64.iso 831.32 MiB / 831.32 MiB [====================================================] 100.00% 3m33s
==> qemu.mai: => /home/folaht/Nwaȥ/Êspas dû travaj/neovîm/Âp/mai-packer/mai-base/packer_cache/a5e0e4d374e7eb55e1c5cec0171e1dfac7ff1eb4.iso
==> qemu.mai: Starting HTTP server on port 8414
==> qemu.mai: Found port for communicator (SSH, WinRM, etc): 4376.
==> qemu.mai: Looking for available port between 5900 and 6000 on
==> qemu.mai: Starting VM, booting from CD-ROM
==> qemu.mai: Waiting 5s for boot...
==> qemu.mai: Connecting to VM via VNC (
==> qemu.mai: Typing the boot command over VNC...
    qemu.mai: Not using a NetBridge -- skipping StepWaitGuestAddress
==> qemu.mai: Using SSH communicator to connect:
==> qemu.mai: Waiting for SSH to become available...
==> qemu.mai: Connected to SSH!
==> qemu.mai: Provisioning with shell script: scripts/
==> qemu.mai: Provisioning step had errors: Running the cleanup provisioner, if present...
==> qemu.mai: Deleting output directory...
Build 'qemu.mai' errored after 10 minutes 56 seconds: Error uploading script: Process exited with status 1

==> Wait completed after 10 minutes 56 seconds

==> Some builds didn't complete successfully and had errors:
--> qemu.mai: Error uploading script: Process exited with status 1

==> Builds finished but no artifacts were created.

As one can see it produces an error and I have no idea why.


variable "country" {
  type    = string
  default = "US"

variable "headless" {
  type    = string
  default = "false"

variable "ssh_timeout" {
  type    = string
  default = "20m"

variable "write_zeros" {
  type    = string
  default = "true"

locals {
  iso_checksum_url = "${legacy_isotime("2006.01")}.01/sha1sums.txt"
  iso_url          = "${legacy_isotime("2006.01")}.01/archlinux-${legacy_isotime("2006.01")}.01-x86_64.iso"

source "qemu" "mai" {
    accelerator            = "kvm"
    boot_command           = [
                            "/usr/bin/curl -O http://{{ .HTTPIP }}:{{ .HTTPPort }}/<enter><wait10>",
                            "/usr/bin/curl -O http://{{ .HTTPIP }}:{{ .HTTPPort }}/poweroff.timer<enter><wait10>",
                            "/usr/bin/bash ./<enter>"
    boot_wait              = "5s"
    cpus                    = 1
    disk_interface         = "virtio"
    disk_size              = 2048
    format                 = "qcow2"
    headless               = "${var.headless}"
    http_directory         = "srv"
    iso_checksum           = "file:${local.iso_checksum_url}"
    iso_url                = "${local.iso_url}"
    memory                 = 768
    net_device             = "virtio-net"
    output_directory       = "output_manjaro-arm-installer"
    ssh_username           = "vagrant"
    ssh_password           = "vagrant"
    ssh_timeout            = "${var.ssh_timeout}"
    shutdown_command       = "sudo systemctl start poweroff.timer"
    vm_name                = "manjaro-arm-installer"

build {
  sources = ["source.qemu.mai"]

  provisioner "shell" {
    execute_command   = "{{ .Vars }} COUNTRY=${} sudo -E -S bash '{{ .Path }}'"
    expect_disconnect = true
    script            = "scripts/"

  provisioner "shell" {
    execute_command = "{{ .Vars }} WRITE_ZEROS=${var.write_zeros} sudo -E -S bash '{{ .Path }}'"
    script          = "scripts/"

  post-processor "vagrant" {
    output = "output/packer_arch_<no value>-${legacy_isotime("2006.01")}"


I have the same problem with packer-arch itself.


I’ve noticed that running the build command with PACKER_LOG=1 in front of it I get the extra information:

==> qemu: Waiting for SSH to become available...
2021/08/14 00:17:10 packer-builder-qemu plugin: [ERROR] RequestAgentForwarding: &errors.errorString{s:"forwarding request denied"}
==> qemu: Connected to SSH!
2021/08/14 00:17:10 packer-builder-qemu plugin: Running the provision hook
==> qemu: Gracefully halting virtual machine...
2021/08/14 00:17:10 packer-builder-qemu plugin: Executing shutdown command: sudo systemctl start poweroff.timer
2021/08/14 00:17:10 packer-builder-qemu plugin: [DEBUG] Opening new ssh session
2021/08/14 00:17:10 packer-builder-qemu plugin: [DEBUG] starting remote command: sudo systemctl start poweroff.timer
2021/08/14 00:17:10 packer-builder-qemu plugin: [ERROR] Remote command exited with '1': sudo systemctl start poweroff.timer

It looks like packer-arch is outdated and several things need to changed.
First of all Arch Linux nowadays requires password changes after adding users. (administrator required).

echo -e 'vagrant\nvagrant' | /usr/bin/passwd vagrant