sp4rkie / debian-on-termux

HOWTO install plain Debian 10 (buster) on your non-rooted Android smartphone
GNU Lesser General Public License v2.1
401 stars 87 forks source link

Attention on /proc folder and /dev/shm #67

Open JanuszChmiel opened 4 years ago

JanuszChmiel commented 4 years ago

Yours script is excellent. Unfortunately it do not contain important code, which makes installed Debian system less usable than ArchLinux. I have found very useful line from The startarch script from MR Rausty. The aim of his command is to use /dev/shem to allow used shared memory by special native .so library and by mounting /proc folder on Android 8 and newer.

exec proot --kill-on-exit --link2symlink -0 -r /data/data/com.termux/files/home/arch -b /data/data/com.termux/files/home/arch/tmp:/dev/shm -b /data/data/com.termux/files/home/arch/var/binds/fbindprocstat:/proc/stat -b /proc/self/fd/1:/dev/stdout -b /proc/self/fd/2:/dev/stderr -b "$ANDROID_DATA" -b /dev/ -b "$EXTERNAL_STORAGE" -b "$HOME" -b /proc/ -b /storage/ -b /sys/ -w "$PWD" /usr/bin/env -i HOME=/root TERM=xterm /bin/bash -l ||: Do you think, that some part of The Archlinux starting command could be incorporated to yours script to allow users to acces /proc folder also on Android 8 and newer and to allow them to use shared memory? There are currently two libraryes to support shared memory on Android, thus none of them is A full replacement for standard Linux memory sharing. Because if .C code of The library access some files to emulate shared memory, if app calls too many request related to shared memory access, device drivers which acces file storage chip have no chance to have The equal speed like direct memory access. Gnuroot debian contain compiled .so library for shared memory. Its source code is here. https://github.com/pelya/android-shmem

Termux programmers have used tis code to develop their own release of Android-shmem.so but their library is only for Termux. It do not use file handles to emulate shared memory, so it is much more faster and much more reliable. Unfortunately, it is compatible only with Termux, so it would very probably crash on Debian. Android-shmem.so from Pelia can be loaded by adding The following line at The end of /etc/profile Bash script file. export LD_PRELOAD=/data/data/com.termux/files/home/ubuntu-fs/usr/lib/libandroid-shmem.so Sure, folder have been assigned for Ubuntu, not for Debian installed by using yorus script. Shared memory has also last approach for Android. Approach, which have been used by Userland developers. They are using memalloc.so and other .so files, I do not know, which .so file emulate shared memory while using their project. But their approach is fast but produces also crashes. X11vnc and xinit Xorg is incompatible. Very probably, also their .so library uses file handles. Recoding android-shmem for Termux to be compatible with various Linux distros is very probably heavy task for very experienced C programmers. And I even do not know, if is it possible or no.

Dmole commented 4 years ago

What is the use case for shared memory?

proot ... -b /data/data/com.termux/files/home/arch/tmp:/dev/shm

how is arch/tmp made?

mounting /proc

proc is already mounted; https://github.com/sp4rkie/debian-on-termux/issues/53#issuecomment-644267911

JanuszChmiel commented 4 years ago

Shared memory have several areas of use in Linux programming. It allow faster data exchange between running processes. The typical use scenario of shared memory is to allow faster app usability while using Xserver XSDL and some X11 based apps. Shared memory library from Pelia can be also used if somebody would want to use vnc protocol and Xorg. Running xinit and configuring xorg.conf to allow VNC protocol use not by using Tigervnc so XVNC process but use xinit directly with whole Xorg modules. Pcman file manager also uses shared memory. Many C and C++ programmers of Linux apps have incorporated two various programmers approaches for memory use. So if shared memory is not presented, programmer have defined other way to manipulate with memory data so app will run. The typical use of those two various approaches are presented inside source code of Mate-session and in other Mate desktop environment C source code parts.

The lmimitation of Pelisa library is The fact, that it depend on fila handles. And RAm chip will be always much more faster than flash chip, which must be accessed by using kernel driver. I hope, that I have understood Pelia approach well that his code uses file handels some file to emulate shared memory.

JanuszChmiel commented 4 years ago

You have done amazing think, that you have added /proc mount to yours script. Before I have recognized professionaly prepared ArchLinux scripts from MR Rausty, I have thought that every Linux installation script must be prepared like scripts for other Termux based tools to install Linux by using Termux and Proot. But I think, that ArchLinux instalation script from MR Rausty is The good example of The procedure, which would allow us to install also other distros like Arch Linux. Including /proc folder, shared memory support. Seamonkey Internet suite also uses shared memory. Unfortunately, Debian packages did not prepared this suite for aarch64. And compiling it from scratch on Android device is impossible thanks to some tools, which require direct dbus connection and real Linux kernel. Gnome-builder will also newer work in chroots executed by Proot and Termux. It requires dbus. So there will be always some limitations. But even though those limitations are presented, I AM able to run ArchLinux with Orca screen reader, Pulseaudio sound support and I can use VNC protocol by using Tigervnc or by using Xorg and Xinit with full shared memory support without crashes. Tigervnc do not support shared memory while using Pelias library. But Xorg, Xinit and x11vnc if it is started by using -noshm option support Pelias library.

JanuszChmiel commented 4 years ago

To find which content have tmp file it would be necessary to analyse all Bash script available by downloading this Github tree. Git clone https://github.com/SDRausty/termux-archlinux.git

This series of scripts is The example of profesionally prepared tool to really configure and install Linux distro. Some used routines may be need adaption according to The Debian specific differences. The same thinks would had to make all authors of other Bash scripts to install Linux distros by using Termux including Fedora installaers. Because Fedora do not support Dbus sessions at all. Debian yes, fortunately, Ubuntu and Arch Linux.