So I'm trying to build a script for installing a customized Artix ARM directly to SD/eMMC cards without the need for images, based on Manjaro ARM Installer (https://gitlab.manjaro.org/manjaro-arm/applications/manjaro-arm-installer).
For the installment however, just to be really safe,
I also want to use a customized virtual machine,
so that for whatever reason the harddisk is selected,
I've had that happen once, it will destroy the virtual machine instead.
My issue is that Manjaro ARM Installer uses Systemd-nspawn
and so I have to either
1. Use artix-chroot
Artix-chroot however requires that my customized VM
is of the same OS and architecture as what I want to install.
The problem here is that I can't build a custom virtual machine using packer.
Packer demands a liveISO while ARMtix is only available as direct-to-harddisk.
But packer is what I know and I find building a custom VM complicated enough using that.
I don't want it to become even more complicated.
2. Find a systemd-nspawn equivalent
And I have no idea what that could be.
Is there a systemd-nspawn equivalent?
docker/podman maybe?
systemd-nspawn is more or less just a better chroot, which does mounting, sets environment vars.
qemu-user-static (https://packages.artixlinux.org/details/qemu-user-static-binfmt) is what you're looking for. It's a executable you can drop into your chroot and it bridges the architecture gap.
Something like
sudo install -m755 /{,your/chroot/}usr/bin/qemu-arm-static and then running:
artix-chroot /your/chroot qemu-arm-static sh
should work (if running additional binaries fails, install the
qemu-user-static-binfmt package).
Replace arm with aarch64 if you're using a 64-bit board.
Stupid question, but qemu-user-static (or systemd-nspawn) does not bridge the distro gap does it?
I can't use it to install a customized using artix-chroot Armtix from an Alpine VM?
I guess distrobox good alternative
or may be
incus container
I probably can't use a virtualizer for this.
I need a chroot.
I'm getting an invalid ELF image error.
$ ls -lha /var/tmp/eqstalxr-bastij/root/bin/qemu-arm-static
-rwxr-xr-x 1 root root 3.9M May 17 09:11 /var/tmp/eqstalxr-bastij/root/bin/qemu-arm-static
$ ls -lha /var/tmp/eqstalxr-bastij/root/usr/lib/binfmt.d/qemu-aarch64-static.conf
-rw-r--r-- 1 root root 202 May 17 11:06 /var/tmp/eqstalxr-bastij/root/usr/lib/binfmt.d/qemu-aarch64-static.conf
$ sudo artix-chroot /var/tmp/eqstalxr-bastij/root qemu-arm-static sh
Error while loading sh: No such file or directory
[edit]
I'm able to chroot using qemu-aarch64-static, but not allowed to do more than change directory.
$ artix-chroot /var/tmp/eqstalxr-bastij/root qemu-aarch64-static /bin/bash
bash: /usr/bin/dircolors: cannot execute binary file: Exec format error
[bastille-installer /]# ls -lha
bash: /usr/bin/ls: cannot execute binary file: Exec format error
[bastille-installer /]# ls
bash: /usr/bin/ls: cannot execute binary file: Exec format error
[bastille-installer /]# cat
bash: /usr/bin/cat: cannot execute binary file: Exec format error
[bastille-installer /]# dir
bash: /usr/bin/dir: cannot execute binary file: Exec format error
[bastille-installer /]# cd .
[bastille-installer /]# cd bin
[bastille-installer bin]# cd ..
[bastille-installer /]# exit
We actually use a chroot wrapper for package building that essentially replaces the nspawn calls arch use.
It supports different arches.
https://gitea.artixlinux.org/artix/artools/src/branch/master/src/pkg/chroot-run.in
Does it? I tried to use it even with qemu-user-static and configured binfmt but couldn't run aarch64 chroot on x86_64.
I've been getting ls to work. Every command needs to start with qemu-aarch64-static first
But I still have this issue:
[bastille-installer /]# qemu-aarch64-static /bin/ls
bin boot dev etc home lib mnt opt proc root run sbin srv sys tmp usr var
[bastille-installer /]# qemu-aarch64-static /bin/pacman-key
Error while loading /usr/bin/pacman-key: Exec format error
That's weird, the
qemu-user-static-binfmt package is supposed to handle the "not needing to prefix everything with qemu-aarch64-static" part.
Does the file
/proc/sys/fs/binfmt_misc/qemu-aarch64 exist on your system? Did you install the binfmt package on the host? (it seems you installed it on the guest).
The ARMtix mirrors are extremely slow in my country, but I'm going to download a tarball and see if I can reproduce the issue..
Wasn't able to:
[g3583 /]# /bin/echo Hello from $(uname -m)
Hello from aarch64
[g3583 /]# pacman-key --version
pacman-key (pacman) 6.0.2
Copyright (c) 2010-2021 Pacman Development Team <pacman-dev@archlinux.org>.
This is free software; see the source for copying conditions.
There is NO WARRANTY, to the extent permitted by law.
(AMD64 host)
No
$ ls -lha /proc/sys/fs/binfmt_misc/
total 0
drwxr-xr-x 2 root root 0 May 19 20:12 .
dr-xr-xr-x 1 root root 0 May 19 15:34 ..
--w------- 1 root root 0 May 19 20:12 register
-rw-r--r-- 1 root root 0 May 19 20:12 status
I assume by host you mean the Artix OS one layer deep with Armtix as the guest two layers deep.
Then I installed the qemu-user-stitac-binfmt package on the host.
$ sudo pacman -Ss binfmt
world/qemu-user-binfmt 9.0.0-1
Binary format rules for QEMU user mode emulation
world/qemu-user-static-binfmt 9.0.0-1 [installed]
Binary format rules for QEMU static user mode emulation
Yes, by "host" I meant what you're running chroot on.
Try running, in a root shell, cat /usr/lib/binfmt.d/qemu-aarch64-static.conf > /proc/sys/fs/binfmt_misc/register.
A pacman hook should be running that for you, but since the file doesn't exist, this means the hook isn't running, weirdly.
I followed this thread:
https://forum.artixlinux.org/index.php/topic,5766.0.html
Like the original poster,
I can't tell if I had to restart binfmt or not, but it's working.