Talk:Anbox

From ArchWiki

AUR packages for prebuilt kernel

Maybe it's worth including linux-xanmod-anboxAUR? Dandart (talk) 13:09, 8 September 2020 (UTC)

Thank you for the tip

I got anbox working with network by following these steps.

I installed linux-xanmod-anboxAUR, anbox-image-gappsAUR and anbox-gitAUR.

Added the new kernel to my bootloader.

Autoloaded the modules via

/etc/modules-load.d/anbox.conf
ashmem_linux
binder_linux

Installed https://raw.githubusercontent.com/anbox/anbox/master/scripts/anbox-bridge.sh as /usr/bin/anbox-bridge and created

/etc/systemd/system/anbox-container-manager.service.d/enable-anbox-bridge.conf
[Service]
ExecStartPre=/usr/bin/mkdir /dev/binderfs
ExecStartPre=/usr/bin/mount -t binder binder /dev/binderfs
ExecStartPre=/usr/bin/anbox-bridge start
ExecStopPost=/usr/bin/anbox-bridge stop

Ran systemctl enable anbox-container-manager.service and rebooted.

The first call to anbox launch typically times out. But once the container is running it is responsive.

I hope I did not forget anything.


Installation instructions

Update: The instructions now seem to be correct (according to a user who tested them on AUR (link to comment).

Further questions:

1. Kernel config options:

There are two different configs in this article, do both work or not? And what method should be preferred?

Update: Config 1 is working for now, according to user reports. You might take a look at the official Anbox Github page to check for recent changes (especially regarding the use of binderfs and binder).

The main differences are:

  • Use of binderfs and
  • auto-activation with y instead of m.

Config 1: Debian is using the same options as the linux-zen kernel:

  
CONFIG_ASHMEM=m
# CONFIG_ION is not set
# end of Android
...
CONFIG_ANDROID=y
CONFIG_ANDROID_BINDER_IPC=m
# CONFIG_ANDROID_BINDERFS is not set
CONFIG_ANDROID_BINDER_DEVICES="binder"
# CONFIG_ANDROID_BINDER_IPC_SELFTEST is not set
# end of Android

Config 2: While the instructions for rebuilding the kernel mention different config options:

  
CONFIG_ASHMEM=y
CONFIG_ANDROID=y
CONFIG_ANDROID_BINDER_IPC=y
CONFIG_ANDROID_BINDERFS=y
CONFIG_ANDROID_BINDER_DEVICES="binder,hwbinder,vndbinder"
...

G3ro (talk) 18:44, 19 October 2020 (UTC) G3ro

Compiling binderfs as module

It seems bootup is quicker if one compiles into modules instead of all into the kernel. At least bootup took me longer when I compiled all modules required for my hardware into the kernel, compared to putting them in a initramfs.

I wonder how to compile binder with the binderfs implementation into a module

CONFIG_ANDROID_BINDERFS=m

will show an error (hard to spot, as there is plenty of output) and treat is as undefined, i.e. binder will be built without binderfs. Using

CONFIG_ANDROID_BINDER_IPC=m
CONFIG_ANDROID_BINDERFS=y
CONFIG_ANDROID_BINDER_DEVICES=""

did lead me to an error during compilation

ERROR: modpost: "init_ipc_ns" [drivers/android/binder_linux.ko] undefined!
ERROR: modpost: "put_ipc_ns" [drivers/android/binder_linux.ko] undefined! 

I see in the config used by Ubuntu that they try to do it, but couldn't replicate it. (I don't see if they succeeded! It's also likely to be a mistake to set CONFIG_ANDROID_BINDERFS=m, as it's throwing an error) Their .config file can be downloaded with this package:

[1] (click on amd64 to download the deb file)

However, there's also this blogpost by Simon Fels – the developer of Anbox which implies they compiled it as module in Ubuntu.

RoundCube (talk) 05:16, 5 January 2021 (UTC)

Snap package

Should we add a mention of the snap package, according to the official installation instructions?

G3ro (talk) 14:32, 18 October 2020 (UTC) G3ro

NetworkManager

Some suggestions and questions:

1. I think the command should be explained a bit more.

2. The custom options should be clarified as such:

  • IP
  • Bridgename etc.

3. Also could someone confirm that this is the only command necessary? I don't use it, so I don't know, but many Howtos mention more commands, including:

  • specifying the network the bridge connects to
  • startcommand for the bridge

4. Add notes about Firewall rules?

G3ro (talk) 18:53, 24 October 2020 (UTC) G3ro

1. I've added some more clarification of what the command does.
2. The only parameter easily customizable in the command is the connection.id which specifies the name of the connection when displayed in NetworkManager.
The ifname must be anbox0 as this is hardcoded in the Anbox source code: https://github.com/anbox/anbox/blob/f77590472ab366a1249295a1cf4675b345a0b7ec/src/anbox/container/lxc_container.cpp#L151
You can change the IPv4 subnet specified in {{ic|ipv4.addresses|} but then you must also change the container's IPv4 address and gateway by modifying anbox-container-manager.service and adding the following CLI parameters: --container-network-address=PUT_YOUR_NETWORK_ADDRESS_HERE --container-network-gateway=PUT_YOUR_NETWORK_GATEWAY_HERE.
3. NetworkManager tries to deal with all that for you I think. It will automatically run the commands necessary to start the bridge and make the required iptables changes to make the bridge work. You don't need to specify the network the bridge connects to as I think it will route any packets according to the routing rules currently active on your system. That means the bridge behaves just like any other application. If you have a VPN running for example, the bridge will route through that too.
4. Not sure how firewall works in this case but if you are talking about the iptables rules set by the anbox-bridge script, NetworkManager deals with iptables automatically (it will generate and setup iptables rules automatically).
Thanks for all the suggestions. This is my first contribution to the Arch Wiki so any help is greatly appreciated!
Nulldev (talk) 20:43, 24 October 2020 (UTC)
Thank you for providing content and for the detailed and informed answer :).
Now everything seems to be fine (at least to me) :+1:.
And let me tell you: Your writing is very well structured and formulated.
One more thing: For answers in the talk section Indenting is used (see also: Help:Discussion#Joining_a_discussion).
G3ro (talk) 16:02, 25 October 2020 (UTC) G3ro

Anbox-Images outdated

All Images in AUR seem to be quite old (dated to July 2018). Search for anbox-image for reference.

The official builds are outdated as well: https://build.anbox.io/android-images/

The official image template is outdated as well (based on Android 7 which is deprecated according to Wikipedia): https://github.com/anbox/platform_manifests/blob/anbox/default.xml

Update: The official documentation "build android" is also outdated, because it uses the same outdated image template (see above).

Upstream is not responding to any issues about this topic (see e.g.: Anbox Github Issue 1652).

G3ro (talk) 19:04, 24 October 2020 (UTC) G3ro

That's true.
Turns out there is documentation on how to do create a new image. Linked it in the article.
RoundCube (talk) 05:22, 5 January 2021 (UTC)
The documentation also directs the user to the outdated platform manifest file, so it is no solution, instead misleading info.
G3ro (talk) 00:16, 30 January 2021 (UTC)

Clarify difference between binder and binderfs

While it is explained to some degree, if one reads very focused, it is still a bit confusing for people to see the difference and how to proceed.

I propose the following structure: Necessary config options -> You can either use the binder module or binderfs. -> followed by two sub-sections for each option. Then a link to "Mounting binderfs" for "binderfs".

A good question to be answered is also, what is the current and future status of binder and binderfs? Will only binderfs be supported, by both the kernel and anbox? Or will both options continue to be supported?

G3ro (talk) 20:21, 12 March 2021 (UTC)

Building a kernel: Questionable parts

1. This sentence might not belong here imho:

  Modules can either be compiled into the kernel (y), into modules (m), or not at all (n). Also, not all combinations in the config are possible, and some options will require other options.

2. These instructions might also not belong here (but are useful in an article about building AUR kernels):

  When building a kernel from the AUR, one can do it with these steps:
   run makepkg --nobuild, which will download the sources, verify and extract them and run the prepare() function.
   edit the .config file (with the dot in the filename), which is located at the base of the kernel directory.
   at the end of the prepare() function was probably a command which regenerates the makefiles with information from the config, possibly make olddefconfig. Move that to the build() function, or execute it yourself.
   run makepkg --noextract, which will continue from the place where makepkg --nobuild stopped.

3. config using binderfs: Instead of using a script ( scripts/config --module CONFIG_ASHMEM ) it should probably use options like before, to have continuity.

4. This following sentence might be deleted, because binderfs is implemented as internal module mostly everywhere (also in linux-zen) so it seems that it's not possible in a different way.

  You will notice that here binder is not compiled as module. The reason is, I did not find out how to. Discuss it in Talk:Anbox.

G3ro (talk) 20:31, 12 March 2021 (UTC)

Does ashmem compile as module?

I used the following config to my kernel:

scripts/config --module  CONFIG_ASHMEM
scripts/config --enable  CONFIG_ANDROID
scripts/config --enable  CONFIG_ANDROID_BINDER_IPC
scripts/config --enable  CONFIG_ANDROID_BINDERFS
scripts/config --set-str CONFIG_ANDROID_BINDER_DEVICES ""

But the CONFIG_ASHMEM is still commented out in the modified .config file. There is also a warning about CONFIG_ASHMEM not being able to be compiled as a module. However building it into kernel appears to work. Can anyone confirm this? Thanks. —This unsigned comment is by Whenov (talk) 04:26, 29 July 2021‎ (UTC). Please sign your posts with ~~~~!

The config used in the linux-zen kernel also uses "CONFIG_ASHMEM=y" (see: linux-zen config).
Additionally there is a reason why the dkms modules no longer work. So it is possible that ashmem cannot be compiled as module.
Thus we should maybe edit the article to reflect that.
G3ro (talk) 13:25, 29 July 2021 (UTC)

Linux zen does include binderfs and ashmem

The last change https://wiki.archlinux.org/index.php?title=Anbox&oldid=697677 claims that linux zen doesn't support them but as far as I know linux-zen still has binderfs and ashmem builtin.

You are right, it is still included, see config: https://github.com/archlinux/svntogit-packages/blob/packages/linux-zen/trunk/config
G3ro (talk) 13:46, 29 September 2021 (UTC)
Update: Just noticed that someone added this kernel config option "CONFIG_SW_SYNC=y" which is not activated in linux-zen. Can someone verify that this option is necessary?
And if thats the case, can someone write a feature request for the linux-zen kernel for it to be included?
G3ro (talk) 14:39, 29 September 2021 (UTC)