Waydroid on Silverblue!

Hey folks!

I followed some guides on how to get Waydroid installed and working on Silverblue and thought I would share my findings. I’m also hoping that someone will share a way of doing some of these things a bit easier by sharing my steps with you =)

Special thanks to Karuboniru for his blogpost “Waydroid need kernel with ashmem and binder”.

Instead of using fedpkg to make a build based on the vanilla Silverblue kernel I decided to use rmnscns kernel-xanmod copr repo. This is particularly laborious as you’ll have to run rpm-ostree override replace for the various kernel packages, for every update even. If you have a better way of doing it, I’d be all ears :slight_smile: This requires that you have rpm-ostree 2021.12 or higher.

XANMOD_KERNEL_REPO="https://copr-be.cloud.fedoraproject.org/results/rmnscnce/kernel-xanmod/fedora-35-x86_64/02980126-kernel-xanmod-lts"
rpm-ostree override replace \
--uninstall=kernel \
--uninstall=kernel-core \
--uninstall=kernel-modules \
--uninstall=kernel-headers \
--uninstall=kernel-devel \
--install=${XANMOD_KERNEL_REPO}/kernel-xanmod-lts-5.10.80-xm1.0.fc35.x86_64.rpm \
--install=${XANMOD_KERNEL_REPO}/kernel-xanmod-lts-core-5.10.80-xm1.0.fc35.x86_64.rpm \
--install=${XANMOD_KERNEL_REPO}/kernel-xanmod-lts-modules-5.10.80-xm1.0.fc35.x86_64.rpm \
--install=${XANMOD_KERNEL_REPO}/kernel-xanmod-lts-headers-5.10.80-xm1.0.fc35.x86_64.rpm \
--install=${XANMOD_KERNEL_REPO}/kernel-xanmod-lts-devel-5.10.80-xm1.0.fc35.x86_64.rpm \
${XANMOD_KERNEL_REPO}/kernel-xanmod-lts-5.10.80-xm1.0.fc35.x86_64.rpm

If you have a better, easier, automatically updatable way of doing this, please let me know, as I have to uninstall the older xanmod kernel packages to then also install the newer xanmod kernel packages - which is laborious.

After that I would install the waydroid packages from yanqiyu’s fc35 waydroid copr repo by scrolling down to Active Releases, downloading the yanqiyu-waydroid-fedora-35.repo repo file and placed it in /etc/yum.repo.d and installed it using rpm-ostree install waydroid. All dependencies should be installed automatically.

After that I had to set SELinux to permissive, despite the fact that the repo package provides SELinux configuration. I’m not sure why it didn’t work, but setting SELinux to permissive was necessary to not get access denied errors.

When all that is done you simply run sudo waydroid init, systemctl start waydroid-container.service , followed by waydroid session start , waiting a little and then running waydroid show-full-ui in a seperate terminal.

Presto! Lineage OS running containerised under Silverblue using lxc :slight_smile:

I hope this helps and that you have a better way of doing this, because I had some pains going through the motions. If you do have a better way I will gladly edit this post and update the information :slight_smile:

Thanks for reading!

3 Likes

Hello @hopland ,
Thank you for sharing this how to. I’m curious, since you are running it containerized, why didn’t you just use toolbox to create a container that you then modify the kernel packages and install waydroid onto?

1 Like

Tbh I wouldn’t know where to start. I’ve been tinkering a bit with toolbox, but I have no idea how to use podman to make a reproducable container - let alone give it access to kernel features such as ashmem or binder. Heck, someone asked me on #silverblue:matrix.org if I could try to disable the ashmem module to see if waydroid could run without it.

But I think a podman OSI container makes sense as they can be rootless, but I don’t know enough about either waydroid or podman OSI containers to be able to try something like that. Wouldn’t it be redundant to run an lxc container inside of podman, can podman handle lxc containers,

Seems to me that someone would have to make a container image specifically for running android/waydroid runtimes… call it droidpod :stuck_out_tongue:.

When I get more time I’ll see what else I find out.

1 Like

Hello @hopland ,
Toolbox is a container that is set up as a Pet container with access to the users home dir OOTB and incorporates shell settings and uses podman to run the container image.
A link to Podman https://podman.io/, and for writing Docerfiles https://docs.docker.com/develop/develop-images/dockerfile_best-practices/.
Podman containers can be run as a systemd service, podman is systemd aware. Images for Unbuntu can be run in a container using podman on Fedora Linux. Therefore you could run an Unbuntu image in a container and use that image to build up a working Waydroid container.

1 Like

…and as per usual I forget one step that completely escaped me after I had finished the process. Apo-low-gees.

Before I could get binder to work properly I had to run rpm-ostree kargs --append=psi=1 to add a kernel line parameter necessary for the xanmod-kernel. Perhaps building from scratch is a better solution…

Apparently I can’t edit it into the guide above. So hey, you there… you need to set a kernel arg first!

I’m both in toolbox and podman on matrix.org :slight_smile: gonna soak up as much as I possibly can and try to do a project I’ve been thinking about.

My idea was to create some form of rpm-ostree repo factory, where you can fork/clone and edit the Silverblue ostree config, so you can host, build and update your own Silverblue-based ostree :slight_smile: instead of having to use rpm-ostree override replace

Has anyone started working on something like that?

I also know that @jaydoubleu was mulling over a way to convert the Wayland lxc based container over to a Podman pod so that you can run x86 Android directly from inside a pod… which sounds absolutely awesome! But ashmem is not in the default kernel, and probably won’t be… so there needs to either be a replacement for ashmem, or possibly figure out how to get ashmem into akmod form.

So kernel 5.15 has made it to ostree now and rpm-ostree update should give you binder.

For ashmem, I created this helper script here : GitHub - JayDoubleu/silverblue-toolbox-ashmem: Script to build ashmem on fedora Silverblue and toolbx

It will allow you to build and load ashmem_linux using toolbox (works if executed inside or outside of toolbox)

Then I was able to get waydroid working via:

  • Layering lxc and waydroid rpm-ostree. (waydroid from copr)
  • ashmem from repo above.
  • selinux set to setenforce 0

It’s probably even possible to just get waydroid working from git but it fails because you need to build python-gbinder (which is included in waydroid copr) so there might be no need for layering waydroid at all.

While this does seem to work, I would not exactly recommend it. Mainly because LXC being layered and it can introduce instability to your system.

I have noticed that while I was testing it, Silverblue on my laptop would not shut down properly and just sit on black screen after which I had to force shutdown by pressing power button for 5 seconds. After removing layered LXC problem went away.

1 Like

This is interesting stuff, and I appreciate all of you sharing what has worked. But I also found myself mumbling “ew” a few times ;-). Between custom kernel builds and (more egregiously) disabling SELinux, I’m left wondering if there are any less-invasive-but-still-useful ways of running Android software on top of Fedora.

Any suggestions?

Awesome job, man! An easy fix on getting Waydroid working on Silverblue without having to replace the kernel, and in a pod no less :slight_smile: Milestone!

But I think you were right when you at a previous occasion said that it should rather be implemented using toolbox somehow. According to the Waydroid Git repo it “uses Linux namespaces (user, pid, uts, net, mount, ipc) to run a full Android system in a container”.

Is it possible to make a pod image using the Lineage 10 system image maybe? But then you would need a pod inside a pod, because ashmem support is needed…? The prospect is cool, because you could then actually run several Android systems in each their containers… ehr, pods.

I don’t think you would need to have pod inside pod. You would probably just need to pass ashmem device to container or run it privileged.

It might also need some loop devices (rootless podman cannot create those) so they would need to be pre-created on host.

One could try to just replicate what lxc.py in waydroid repo does and somehow port it there but I don’t think I’ll have any time soon to play with it.

Also there is redroid GitHub - remote-android/redroid-doc: ReDroid (Remote-Android) is a multi-arch, GPU enabled, Android in Cloud solution. Track issues / docs here which seems to be doing exactly that already so I’ll probably play with it once new podman version ships to Fedora.

There are some fixes to make it work with podman.

I’m not 100% sure but I believe it should work with rootless podman + selinux enabled.

Podman bugs mentioned:

podman can not run a container with a symlinked /etc dir · Issue #12189 · containers/podman · GitHub < already merged and should hopefully be available on next release.

Unable to pull image : `Error processing tar file(exit status 1): lsetxattr /vendor: invalid argument` · Issue #1076 · containers/storage · GitHub < PR with fix created. Waiting for review. Not sure if it will make it to next podam release.

2 Likes

Hey, i have created rpm package for ashmem and binder that also works with fedora silverblue, for more info look into this post: Ashmem and binderfs copr for anbox and waydroid - Fedora Discussion

2 Likes

I have tried to install Xanmod (on both 35 and 36), using both a variant of your script and ostree override (@hopland you can do this by wget the repo directly into /etc/yum.repos.d). In both instances I ran into:

Unexpected / in .vmlinuz.hmac: <hmac> /lib/modules/5.17.0-xm1.0.fc36.x86_64/vmlinuz`

It looks like I am not alone: https://www.reddit.com/r/Fedora/comments/t03o8j/silverblue_how_would_i_go_about_installing_a/i1jdgwt/

Has anyone run into this, or have any pointers on how I can start tracking down a solution?

Related issue: Installation of xanmod kernel fails · Issue #3546 · coreos/rpm-ostree · GitHub

1 Like