From 14af6e9f13eadae7b7a8a5288464ac36f10256d8 Mon Sep 17 00:00:00 2001 From: Ziyang Zhou Date: Wed, 27 Dec 2023 18:57:00 +0800 Subject: [PATCH] add LXC deploy instructions --- deploy/README.md | 1 + deploy/lxc.md | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 deploy/lxc.md diff --git a/deploy/README.md b/deploy/README.md index 4c4ede1..8d7d5b9 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -28,6 +28,7 @@ resort, it's always capable via customizing Linux kernel. - [Fedora](fedora.md) - [Gentoo](gentoo.md) - [Kubernetes](kubernetes.md) +- [LXC](lxc.md) - [Mint](mint.md) - [OpenEuler](openeuler.md) - [PopOS](pop_os.md) diff --git a/deploy/lxc.md b/deploy/lxc.md new file mode 100644 index 0000000..297611d --- /dev/null +++ b/deploy/lxc.md @@ -0,0 +1,55 @@ +# Deploy redroid via LXC + +``` +## take Ubuntu 22.04 as example here +## adjust for other Linux distros + +## install required kernel modules +apt install linux-modules-extra-`uname -r` +modprobe binder_linux devices="binder,hwbinder,vndbinder" + +## install lxc tools +apt install lxc-utils + +## check lxc netowrking +systemctl --no-pager status lxc-net + +## adjust oci template +sed -i 's/set -eu/set -u/g' /usr/share/lxc/templates/lxc-oci + +## install required tools +apt install skopeo umoci jq + +## create redroid container +lxc-create -n redroid11 -t oci -- -u docker://docker.io/redroid/redroid:11.0.0-latest + +## adjust container config +mkdir $HOME/data-redroid11 +sed -i '/lxc.include/d' /var/lib/lxc/redroid11/config +<> /var/lib/lxc/redroid11/config +### hacked +lxc.init.cmd = /init androidboot.hardware=redroid androidboot.redroid_gpu_mode=guest +lxc.apparmor.profile = unconfined +lxc.autodev = 1 +lxc.autodev.tmpfs.size = 25000000 +lxc.mount.entry = $HOME/data-redroid11 data none bind 0 0 +EOF + +## [workaround] for redroid networking +rm /var/lib/lxc/redroid11/rootfs/vendor/bin/ipconfigstore + +## start redroid container +lxc-start -l debug -o redroid11.log -n redroid11 + +## check container info +lxc-info redroid11 + +## grab adb shell +adb connect `lxc-info redroid11 -i | awk '{print $2}'`:5555 + +## or execute sh directly +nsenter -t `lxc-info redroid11 -p | awk '{print $2}'` -a sh + +## stop redroid container +lxc-stop -k redroid11 +```