SoulInfernoDE / compile-kernel-from-source

Script to be able to automate compiling procedures. Eg. if you need to add .config options to your kernel sources like android (ASHMEM, BINDER, etc.)
MIT License
8 stars 4 forks source link

Inconsistent sets of files for the different kernel builds #3

Open sja45uk opened 2 years ago

sja45uk commented 2 years ago

I was getting a large number of blacklist messages during boot of kernel-6.0.3-android, and an attempt to run install-playstore.sh produced an error and the instruction to see "systemctl status anbox-container-manager.service". This gave a modprobe: FATAL: Module ashmem_linux not found in directory /lib/modules/6.0.3-android. It also produced messages about anbox-bridge, which I have ignored for now.

Doing 'ls -l /lib/mod*' showed that the two folders modeprobe.d/ and modules/ had not been populated or cleaned consistently.

/lib/modprobe.d doesn't contain a '.blacklist_linux_6.0.3-android.conf' file

/lib/modules contains folders for an excessive number of kernels but no folder for '6.0.1-android'

I would appreciate it if you would take a look to ensure whether these folders are correctly populated, whether the install-playstore should expect to find ashmem_linux and anbox-bridge, and whether some folders should be removed to create more space?

SoulInfernoDE commented 2 years ago

Hey Steve, thanks for reporting. I will have a look at this maybe tomorrow. Actually i have not much spare time left due to other real life priority and i do all this in my spare time. Anyways thanks for keeping reporting. Hopefully i will find some time tomorrow to help investigate.

can you do the following for now to check if ashmem is already installed and running:

sudo dkms status the output should look similiar like this: image

If yes please try this command: sudo modprobe ashmem_linux This should load the installed ashmem module if it's there by dkms

If not please try these sets of commands one by one:

export CPATH=~/Downloads
cd $CPATH
wget https://raw.githubusercontent.com/SoulInfernoDE/compile-kernel-from-source/v6.x/nogui/ashmemk6.tar.xz
mkdir anboxashmem
cd $CPATH/anboxashmem
wget https://raw.githubusercontent.com/SoulInfernoDE/compile-kernel-from-source/v6.x/nogui/ashmemsourcefix6x.patch
tar xvf $CPATH/ashmemk6.tar.xz -C $CPATH/anboxashmem/ --strip-components=1
patch -p1 -i ashmemsourcefix6x.patch
sudo cp -rT $CPATH/anboxashmem/ /usr/src/anbox-ashmem-1
sudo cp $CPATH/anboxashmem/anbox.conf /etc/modules-load.d/
sudo cp $CPATH/anboxashmem/99-anbox.rules /lib/udev/rules.d/
sudo dkms install anbox-ashmem/1
sudo modprobe ashmem_linux
sudo lsmod | grep -e ashmem_linux -e binder_linux
sudo ls -alh /dev/binder /dev/ashmem

The last two commands will list / show modules and their bindings that should be in /dev/

sja45uk commented 2 years ago

$ uname -r 6.0.3-android JUST TO CHECK

$ sudo dkms status NO OUTPUT

$ sudo modprobe ashmem_linux modprobe: FATAL: Module ashmem_linux not found in directory /lib/modules/6.0.3-android

NOTE: THERE WERE MULTIPLE FILES RETURNED PREVIOUSLY BY WGET SO I REMOVED THE DUPLICATES

$ sudo dkms install anbox-ashmem/1 Creating symlink /var/lib/dkms/anbox-ashmem/1/source -> /usr/src/anbox-ashmem-1

Kernel preparation unnecessary for this kernel. Skipping...

Building module: cleaning build area... make -j8 KERNELRELEASE=6.0.3-android all KERNEL_SRC=/lib/modules/6.0.3-android/build... cleaning build area...

ashmem_linux.ko: Running module version sanity check.

depmod....

$ sudo modprobe ashmem_linux NO OUTPUT

$ sudo modprobe binder_linux modprobe: ERROR: could not insert 'binder_linux': Exec format error

$ ls -1 /dev/{ashmem,binder} /dev/ashmem

/dev/binder: binder binder-control binderfs features hwbinder vndbinder

THIS IS THE LIMIT TO THE TESTS THAT I KNOW ABOUT

$ sudo lsmod | grep -e ashmem_linux -e binder_linux ashmem_linux 20480 0

$ sudo ls -alh /dev/binder /dev/ashmem ls: cannot access '/dev/binder': No such file or directory crw------- 1 root root 10, 119 Nov 1 09:30 /dev/ashmem

SO I DECIDE TO CREATE DIRECTORY

$ sudo mkdir /dev/binder

$ sudo mkdir /dev/binderfs mkdir: cannot create directory ‘/dev/binderfs’: File exists

$ sudo mount -t binder binder /dev/binderfs

sudo ls -alh /dev/binder /dev/ashmem crw------- 1 root root 10, 119 Nov 1 09:30 /dev/ashmem

/dev/binder: total 0 drwxr-xr-x 2 root root 40 Nov 1 09:36 . drwxr-xr-x 24 root root 6.5K Nov 1 09:36 ..

$ sudo mount -t binder binder /dev/binder

$ sudo ls -alh /dev/binder /dev/ashmem crw------- 1 root root 10, 119 Nov 1 09:30 /dev/ashmem

/dev/binder: total 0 drwxr-xr-x 3 root root 0 Nov 1 09:43 . drwxr-xr-x 24 root root 6.5K Nov 1 09:36 .. crw------- 1 root root 239, 11 Nov 1 09:43 binder crw------- 1 root root 239, 10 Nov 1 09:43 binder-control crw------- 1 root root 239, 14 Nov 1 09:43 binderfs drwxr-xr-x 2 root root 0 Nov 1 09:43 features crw------- 1 root root 239, 12 Nov 1 09:43 hwbinder crw------- 1 root root 239, 13 Nov 1 09:43 vndbinder

$ sudo dkms status anbox-ashmem/1, 6.0.3-android, x86_64: installed

$ sudo modprobe ashmem_linux STILL NOTHING SO TRY A FINAL TEST

$ anbox session-manager --software-rendering [ 2022-11-01 10:02:26] [daemon.cpp:61@Run] Failed to connect to socket /run/anbox-container.socket: No such file or directory

SoulInfernoDE commented 2 years ago

You said still nothing, but then sudo modprobe ashmem_linux did not throw an error if I am right?

Linux often does not confirm success rather then sending you some error output only when something doesn't work.

About the socket error that is now the main trouble we need to fix/investigate. Everything else seems fine right?

SoulInfernoDE commented 2 years ago

Here is something I found on the quick:

https://github.com/anbox/anbox/issues/1642#issuecomment-714420024

sja45uk commented 2 years ago

I will give it all a try tomorrow, but I always prefer to know what response to expect. So long as I know that no response is good, I am happy. That is why I detail what I am doing, so you can just say looks good. I am also going to have to Google that uid stuff, so I understand it better. I hate having to do a sequence of commands without comprehending why.

sja45uk commented 2 years ago

I found this issue #115, which I think contains more useful information on the same subject: https://github.com/anbox/anbox/issues/115. I have contacted Pekka.Helenius (@Fjorde.com) to try and access the anbox-install code. In the meantime the results of my tests, based on #1642 are as follows:

$ cd ~/Downloads/Android_down/ $ wget https://build.anbox.io/android-images/2018/07/19/android_amd64.img $ if . . . fi $ sudo ./anbox/build/src/ container-manager \ --daemon \ --android-image=${PWD}/android-image.img \ --data-path=${PWD}/anbox-data LONG WAIT WITH NOTHING HAPPENING ^C $ anbox/build/src/anbox session-manager

$ anbox/build/src/anbox launch \ --package=org.anbox.appmgr \ --component=org.anbox.appmgr.AppViewActivity

NOTE: I WAS UNCLEAR WHAT TO DO ABOUT /etc/subuid & /etc/subgid, SO DID NOTHING NOTE ALSO: $ which anbox /usr/bin/anbox $ anbox version anbox 0.0-git20181020-2build1-Ubuntu $ ./anbox/build/src/anbox version anbox local-7a0bee7 $ anbox system-info version: anbox 0.0 . . . cpu: arch: x64 brand: Intel . . . features:

I NEED TO READ https://FunToo.org/LXD/What_are_subuids_and_subgids? AND ALSO https:://Man7.org/linux/man-pages/man5/subuid.5.html BUT I THINK THE KEY (IF I CAN ACCESS IT) IS: https://FjordTek.com/git/Fincer/anbox-install WHICH UNFORTUNATELY IS NOT A REPOSITORY IN: https:://GitHub.com/fincer/ I ALSO THINK WE WE NEED TO CORRECT THE FOLLOWING: $ sudo find / -name anbox_container_manager.service NOTHING FOUND $ sudo find / -name anbox_session_manager.service NOTHING FOUND

SoulInfernoDE commented 2 years ago

I think it was a script or similiar. Try to save the following content into a text file and name it like you want. For example: anbox_container_manager.sh

Make it executable by right clicking it and selecting properties-make file executable or by: sudo chmod +x nameofyourscript.sh and place it into your ~/.scripts folder so you can use it again if needed. Not sure if it works as expected yet I just throw it together in the quick without testing yet..

About the subgid and subuid: In linux every user has an unique identity as a number (user ID or uid) . There are also groups which have unique numbers (group ID or guid) Not sure about the sub uid/gid yet but maybe there's some kind of secondary identifiers added to the first ones. This security system ensures that people, apps and anything related can only view/access/execute their own files. To be able to execute files where the owner is root for example you could add the user to a group which has executive rights or add that user to the root group (which is obviously dangerous). You can also set uids/gids to files and folders.

You can look at your current uid by just typing this command: id

doing sudo -i locks you in to the root user and every command is executed as root. (which is in most cases not recommended because it may destroy some uid/gid in some cases when the root user created a folder for example in your normal user home directory that folder belongs to root which is unreadable / unaccessible to the normal user then.) If you now do: id you'll get the id/gid of your root user which often is 0/0

#!/bin/bash

if [ ! -d "/dev/binderfs" ] ; then
  # load modules
  sudo modprobe ashmem_linux

  # mount binder
  sudo mkdir /dev/binderfs
  sudo mount -t binder binder /dev/binderfs
fi
 #start container manager in daemon mode with android image on the specified path
sudo anbox/build/src/anbox container-manager \
    --daemon \
    --android-image=${PWD}/android_amd64.img \
    --data-path=${PWD}/anbox-data

I am not sure what is saved in the variable $PWD can you check that just of curiosity: echo $PWD

SoulInfernoDE commented 2 years ago

Very nice digging here Steve 💟 : https://github.com/SoulInfernoDE/compile-kernel-from-source/issues/3#issuecomment-1300735417

Yes the missing services is the main problem I think. The solution may be the container manager creating these files when run correctly but I'm not sure about this yet. We are getting closer 😃

One note: binderfs is the successor of binder itself. Most people prefer this one instead of binder. Older anbox builds couldn't handle the newer binderfs so binder was used in first place. I guess that anbox system-info is showing binderfs true/false means that in the newest anbox edge channel which obviously is also on the latest git commits the code to support binderfs was added and therefore you can use binderfs:true without worrying about binder: false.

sja45uk commented 2 years ago

Pekka Helenius has restored access to FjordTek.com/git/Fincer/anbox-install and his other repositories, so you might want to look at them. I will try and find time to look tomorrow, but you are probably more familiar with what he has done. I will also work through your response and try to decide how best to proceed, since I suspect there are several options.

sja45uk commented 2 years ago

THIS DID NOT HELP ME WITH ANBOX SUBUID & SUBGID $ id uid=1000(steve) gid=1000(steve) groups=1000(steve),4(adm),20(dialout),24(cdrom),27(sudo),30(dip),46(plugdev),116(lpadmin),126(sambashare),129(docker),130(kvm),132(libvirt)

THIS IS WHAT WE WOULD EXPECT $ sudo id uid=0(root) gid=0(root) groups=0(root)

$PWD IS YOUR CURRENT DIRECTORY, AS GIVEN BY PWD (PRINT WORKING DIRECTORY) $ pwd /home/steve $ echo $PWD /home/steve $ cd ~/Downloads/Android_down $ echo $PWD /home/steve/Downloads/Android_down

THIS IS WHERE I EXECUTED THE COMMANDS $ ls -l total 1278060 drwxrwxr-x 15 steve steve 4096 Oct 18 11:44 anbox drwxrwxr-x 3 steve steve 4096 Oct 17 21:38 Anbox_186 drwxrwxr-x 5 steve steve 4096 Oct 17 21:55 Anbox_214 drwxr-xr-x 5 root root 4096 Nov 2 09:35 anbox-data drwxrwxr-x 4 steve steve 4096 Jul 31 2021 anbox-install -rw-rw-r-- 1 steve steve 40206 Nov 2 20:59 anbox-install-master.tar.gz drwxrwxr-x 7 steve steve 4096 Oct 18 16:06 anbox-modules -rw-rw-r-- 1 steve steve 325902336 Nov 2 09:33 android_amd64.img -rw-rw-r-- 1 steve steve 982713473 Oct 17 09:42 android-studio-2021.3.1.17-linux.tar.gz -rw-rw-r-- 1 steve steve 20334 Oct 18 11:22 install_anbox_requirements_2.log -rw-rw-r-- 1 steve steve 9131 Oct 18 11:18 install_anbox_requirements.log drwxrwxr-x 2 steve steve 4096 Oct 17 09:28 Playstore drwxrwxr-x 2 steve steve 4096 Oct 18 19:51 SoulInfernoDE_files

INTERESTING THAT anbox-data IS OWNED BY ROOT, WHICH IS PROBABLY WRONG!

sja45uk commented 2 years ago

NOTE: I EDITED MY PREVIOUS COMMENT (ABOVE) TO ANSWER MORE OF YOUR QUESTIONS

$ cd ~/Downloads/Android_down $ nano ~/.scripts/anbox_container_manager.sh $ chmod +x !$

$ /bin/bash -x ~/.scripts/anbox_container_manager.sh

SO NO IMPROVEMENT FROM YESTERDAY, BUT NOW I HAVE TO CHECK OUT EXACTLY WHAT YOUR SCRIPT IS MEANT TO BE DOING

SoulInfernoDE commented 1 year ago

Im very sorry that i have not much spare time left to support you with that error. The trouble definitly belongs to the container manager / socket and maybe the android image that is used by anbox.