Jump to content

Building Armbian using Ubuntu (jammy) in a systemd-nspawn container


Recommended Posts

Armbian & Khadas are rewarding contributors

oops, building from within systemd-nspawn-container, at the end of it

[🌱] Unmounting [ /home/armbian/build/.tmp/rootfs-7074b0dd-8f8a-4d2a-9eb5-2064fe133932 ]
[🌿] Actual rootfs size [ 1638MiB ]
[🌱] Preparing image file for rootfs [ orangepizero2 jammy ]
[🌱] Current rootfs size [ 1638 MiB ]
[🌱] Creating blank image for rootfs [ truncate: 2136 MiB ]
[🌱] Creating partitions [ root: ext4 ]
[🔨]   Checking that no-one is using this disk right now ... OK
[🔨]   
[🔨]   Disk /home/armbian/build/.tmp/rootfs-7074b0dd-8f8a-4d2a-9eb5-2064fe133932.raw: 2.09 GiB, 2239758336 bytes, 4374528 sectors
[🔨]   Units: sectors of 1 * 512 = 512 bytes
[🔨]   Sector size (logical/physical): 512 bytes / 512 bytes
[🔨]   I/O size (minimum/optimal): 512 bytes / 512 bytes
[🔨]   
[🔨]   >>> Script header accepted.
[🔨]   >>> Created a new DOS disklabel with disk identifier 0x6335c2bb.
[🔨]   /home/armbian/build/.tmp/rootfs-7074b0dd-8f8a-4d2a-9eb5-2064fe133932.raw1: Created a new partition 1 of type 'Linux' and of size 2.1 GiB.
[🔨]   /home/armbian/build/.tmp/rootfs-7074b0dd-8f8a-4d2a-9eb5-2064fe133932.raw2: Done.
[🔨]   
[🔨]   New situation:
[🔨]   Disklabel type: dos
[🔨]   Disk identifier: 0x6335c2bb
[🔨]   
[🔨]   Device                                                                    Boot Start     End Sectors  Size Id Type
[🔨]   /home/armbian/build/.tmp/rootfs-7074b0dd-8f8a-4d2a-9eb5-2064fe133932.raw1       8192 4374527 4366336  2.1G 83 Linux
[🔨]   
[🔨]   The partition table has been altered.
[🔨]   Syncing disks.
losetup: cannot find an unused loop device: No such device
[💥] error! [ Unable to find free loop device  ]
[💥] Exiting with error 43 [ at /home/armbian/build/lib/functions/logging/traps.sh:1
                exit_with_error() --> lib/functions/logging/traps.sh:1
             prepare_partitions() --> lib/functions/image/partitioning.sh:218
                do_with_logging() --> lib/functions/logging/section-logging.sh:81
         build_rootfs_and_image() --> lib/functions/main/rootfs-image.sh:80
   full_build_packages_rootfs_and_image() --> lib/functions/main/default-build.sh:36
          do_with_default_build() --> lib/functions/main/default-build.sh:42
         cli_standard_build_run() --> lib/functions/cli/cli-build.sh:25
        armbian_cli_run_command() --> lib/functions/cli/utils-cli.sh:136
                 cli_entrypoint() --> lib/functions/cli/entrypoint.sh:176
                           main() --> compile.sh:50
 ]
[💥] Cleaning up [ please wait for cleanups to finish ]
[🌿] Unmounting recursively [ SDCARD - be patient ]
[🌿] Unmounting recursively [ MOUNT - be patient ]
[🌿] ANSI log file built; inspect it by running: [ less -RS output/logs/log-build-7074b0dd-8f8a-4d2a-9eb5-2064fe133932.log.ans ]
[🌿] Share log manually (or SHARE_LOG=yes): [ curl --data-binary @output/logs/log-build-7074b0dd-8f8a-4d2a-9eb5-2064fe133932.log.ans https://paste.next.armbian.com/log ]
armbian@snoopy1:~/build$ ls /dev
console  fd    hugepages  log     net   ptmx  random  stderr  stdout  urandom
core     full  initctl    mqueue  null  pts   shm     stdin   tty     zero

 

well, this is an artifact / limitations of the systemd-nspawn container

but that reaching here is pretty good, just that the last few steps (probably) needs to be manually done

Link to comment
Share on other sites

Updated section on loop devices in systemd-nspawn container

https://gist.github.com/ag88/05245121cce37cb8f029424a20752e35

Currently systemd-nspawn do not support loop devices needed in the compile.sh build. This section documents some workarounds to create loop devices in a systemd-nspawn container. Use this shell script to start systemd-nspawn

#!/usr/bin/bash
sudo systemd-nspawn -b --capability=CAP_MKNOD \
        --property=DeviceAllow="block-loop rwm" \
        --property=DeviceAllow="block-blkext rwm" \
        --property=DeviceAllow="/dev/loop-control rwm" \
        -D /opt/armbian-build 

 

when the container is started up, in the shell within the container, use this shell script to create the loop devices

#!/usr/bin/bash
if ! test -e /dev/loop-control; then
  sudo mknod /dev/loop-control c 10 237
fi

for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do 
if ! test -e /dev/loop${i}; then
  sudo mknod /dev/loop${i} b 7 ${i}
fi
done

 

In current tests, the above did create the loop devices, but is inadequate to fully resolve the issue with loop devices in armbian build compile.sh.

Link to comment
Share on other sites

I've successfully made a workaround to build Armbian using Ubuntu (jammy) in a systemd-nspawn container.

However, this approach require changing the armbian build scripts in addition to the prior to running compile.sh PREFER_DOCKER=no

 

As the codes is quite verbose it is updated in the gist

loop devices in systemd-nspawn (workaround) requires editing the armbian-build scripts

 

this patch makes it possible to run compile.sh to completion successfully and produce the images.

 

The patches work around the 'missing' loop device files by creating them in /dev. However, note that it does so by patching loop devices from outside the container, hence it isn't risk free to the host operating system. 

 (use at your own risk)

 

Running this with compile.sh requires root access in the container, as losetup connects the image files to the loop devices to build the images.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines