3 For Anbox we're using a minimal customized version of Android but otherwise
4 base all our work of a recent release of the [Android Open Source Project](https://source.android.com/).
6 To rebuild the Android image you need first fetch all relevant sources. This
7 will take quite a huge amount of your disk space (~40GB). AOSP recommends at
8 least 100GB of free disk space. Have a look at [their](https://source.android.com/source/requirements.html) pages too.
10 In general for building the Anbox Andorid image the instructions found on [the pages
11 from the AOSP project](https://source.android.com/source/requirements.html) apply.
12 We will not describe again here of how to build the Android system in general but
13 only focus on the steps required for Anbox.
15 ## Fetch all relevant sources
17 First setup a new workspace where you will download all sources too.
20 $ mkdir $HOME/anbox-work
23 Now initialize the repository by download the manifest and start fetching
28 $ repo init -u https://github.com/anbox/platform_manifests.git -b anbox
32 This will take quite some time depending on the speed of your internet connection.
36 When all sources are successfully downloaded you can start building Android itself.
38 Firstly initialize the environment with the ```envsetup.sh``` script.
44 Then initialize the build using ```lunch```.
47 $ lunch anbox_x86_64-userdebug
50 The complete list of supported build targets:
52 * anbox_x86_64-userdebug
53 * anbox_armv7a_neon-userdebug
54 * anbox_arm64-userdebug
56 Now build everything with
62 Once the build is done we need to take the results and create an image file
66 $ cd $HOME/anbox-work/vendor/anbox
67 $ scripts/create-package.sh \
68 $PWD/../out/target/product/x86_64/ramdisk.img \
69 $PWD/../out/target/product/x86_64/system.img
72 This will create an *android.img* file in the current directory.
74 With this, you are now able to use your custom image within the Anbox runtime.
76 ## Run Anbox with self build android.img
78 If you have Anbox installed on your system you need to stop it first. If you used
79 the installer script and the snap you can do this via
83 $ sudo systemctl stop snap.anbox.container-manager
86 It is important that you stop both, the container manager and the session manager.
88 Once both services are stopped you can start the container manager with your
89 custom android.img file by running
92 $ datadir=$HOME/anbox-data
93 $ mkdir -p $datadir/rootfs
94 $ sudo anbox container-manager \
95 --android-image=/path/to/android.img \
99 This will start the container manager and setup the container rootfs inside the
103 $ ls -alh $HOME/anbox-data
105 drwxrwxr-x 5 ubuntu ubuntu 4,0K Feb 22 08:04 .
106 drwxrwxr-x 16 ubuntu ubuntu 4,0K Feb 22 08:04 ..
107 drwxr-xr-x 2 100000 100000 4,0K Feb 22 08:04 cache
108 drwxr-xr-x 2 100000 100000 4,0K Feb 22 08:04 data
109 drwxr-xr-x 2 root root 4,0K Feb 22 08:04 rootfs
112 **NOTE:** If you look into the $HOME/anbox-data/rootfs directory you won't see
113 anything as the container manager spawns up a private mount namespace which
114 prevents anything from the outside to see its mount points.
116 The *cache* and *data* directories are bind-mounted into the rootfs at *rootfs/data*