Skip to main content
Topic: [SOLVED] Looking for systemd-nspawn equivalent or ARMtix liveISO (Read 527 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

[SOLVED] Looking for systemd-nspawn equivalent or ARMtix liveISO

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.

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? 

Re: Looking for systemd-nspawn equivalent or ARMtix liveISO or solution otherwise

Reply #1
systemd-nspawn is more or less just a better chroot, which does mounting, sets environment vars.

Re: Looking for systemd-nspawn equivalent or ARMtix liveISO or solution otherwise

Reply #2
qemu-user-static 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:

Code: [Select]
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.

Re: Looking for systemd-nspawn equivalent or ARMtix liveISO or solution otherwise

Reply #3
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? 


Re: Looking for systemd-nspawn equivalent or ARMtix liveISO or solution otherwise

Reply #4
I guess distrobox good alternative
or may be
incus container
Create problems which don't have solution

Re: Looking for systemd-nspawn equivalent or ARMtix liveISO or solution otherwise

Reply #5
I guess distrobox good alternative
or may be
incus container

I probably can't use a virtualizer for this. 
I need a chroot. 

qemu-user-static 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:

Code: [Select]
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.

I'm getting an invalid ELF image error.

Code: [Select]
$ 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.
Code: [Select]
$ 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 


Re: Looking for systemd-nspawn equivalent or ARMtix liveISO or solution otherwise

Reply #7
Does it? I tried to use it even with qemu-user-static and configured binfmt but couldn't run aarch64 chroot on x86_64.
ARMtix

Re: Looking for systemd-nspawn equivalent or ARMtix liveISO or solution otherwise

Reply #8
I've been getting ls to work. Every command needs to start with qemu-aarch64-static first


But I still have this issue:
Code: [Select]
[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

Re: Looking for systemd-nspawn equivalent or ARMtix liveISO or solution otherwise

Reply #9
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:

Code: [Select]
[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 <[email protected]>.

This is free software; see the source for copying conditions.
There is NO WARRANTY, to the extent permitted by law.

(AMD64 host)

Re: Looking for systemd-nspawn equivalent or ARMtix liveISO or solution otherwise

Reply #10
Quote
Does the file /proc/sys/fs/binfmt_misc/qemu-aarch64 exist on your system?

No

Code: [Select]
$ 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

Quote
Did you install the binfmt package on the host? (it seems you installed it on the guest).

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.

Code: [Select]
$ 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

Re: Looking for systemd-nspawn equivalent or ARMtix liveISO or solution otherwise

Reply #11
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.