junest icon indicating copy to clipboard operation
junest copied to clipboard

Use QEMU with namespace backend

Open fsquillace opened this issue 4 years ago • 1 comments

If binfmt-user-static is installed in the native OS (say x86_64 arch), it is possible to run JuNest on a different architecture (say ARM) using the namespace more. More information here

To achieve this on a JuNest ARM architecture with x86_64 arch native system:

bwrap <all_common_bwrap_options_to_bind> /tmp/qemu-arm-static /bin/sh

where bwrap and qemu-arm-static are x86_64 compiled binaries. qemu-arm-static must be within the JuNest env in order for this to work.

The biggest challenge is how to set binfmt as unprivileged user. There are attempt to have binfmt for unprivileged containers. Some references here:

  • https://lwn.net/Articles/767780/
  • https://discuss.linuxcontainers.org/t/3-1-0-binfmt-support-service-in-unprivileged-guest-requires-write-access-on-hosts-proc-sys-fs-binfmt-misc/5249/5

Reference about the need to use binfmt for making is working:

  • https://ownyourbits.com/2018/06/13/transparently-running-binaries-from-any-architecture-in-linux-with-qemu-and-binfmt_misc/

fsquillace avatar Jan 17 '21 16:01 fsquillace

Modified the line in namespace.sh in this way:

JUNEST_ENV=1 ~/.junest/usr/bin/bwrap $COMMON_BWRAP_OPTION $backend_args /usr/bin/qemu-arm-static -L ~/.junest-arm ~/.junest-arm/lib/ld-linux-armhf.so.3 "${DEFAULT_SH[@]}" "${args[@]}"

/usr/bin/qemu-arm-static has to be within the junest image.

fsquillace avatar Jan 17 '21 17:01 fsquillace