This has been done before, also wrote an article. It was just three years ago. Recently toss again, found three years of change is quite big, decided to write another article. (or Archlinuxarm)
First use Cpu-z to view the hardware architecture of the (rooted) Android device, and then download a tarball of the base system for the corresponding architecture on the official website. Then get a EXT3/EXT4 file system on the device and unzip it inside.
If you have an external SD card, you can simply separate a EXT3/EXT4 partition for Linux. If not, you can only use loopback. The following is an example of using the loopback case.
The so-called use of loopback, is the system installed in a file. Create the file First:
$ dd if=/dev/zero of=./archlinux_arm bs=4m count=1024x768
This creates a 4GiB file. Smaller can be, but 2GiB or smaller is not enough (if the software installed more).
Next, format the file as a ext3 file system:
$ mkfs.ext3./archlinux_arm
Mount this file to /mnt :
Mount -O-loop./archlinux_arm/mnt
Unpacking the base system:
$ cd/mnt
tar -vxapf ~/downloads/archlinuxarm-aarch64-latest. tar. gz
To modify /mnt/etc/group , add the following two lines to the Internet (Android makes some restrictions, even if root is added to some group):
Inet:x:3003: rootnet_raw:x:3004: Root
Write another script for automating the chroot:
$ CD-umount /"$EDITOR" run_chroot.sh
Run_chroot.sh content is as follows:
1#!/system/bin/SH2 3root="/system/mnt"4 5 if[-D"$ROOT/usr"]; Then6 Echo "filesystems already mounted."7 Else8 Echo "Mounting Loopback ..."9 Mount-T Ext3-o loop/sdcard/archlinux_arm"$ROOT"Ten Echo "mounting API filesystems ..." One Mount-O Bind/dev"$ROOT/dev" A Mount-O Bind/proc"$ROOT/proc" - Mount-O Bind/sys"$ROOT/sys" - Echo "Binding SD Card ..." the Mount-O Bind/sdcard"$ROOT/sdcard" - fi - - Echo "Executing chroot ..." +Ld_preload=""Ld_library_path="$ROOT/usr/lib" "$ROOT/usr/lib/"LD-*.so"$ROOT/usr/bin/chroot" "$ROOT"/usr/bin/su-L
(Why is the last line so long?) --if there is no chroot command on the device, you must borrow the program inside the Gnu/linux.
where mount -o bind/sdcard "$ROOT/sdcard" is designed to facilitate access to external files in a chroot environment.
Send the file to the device (if you can mount the device directly on your computer, this step is not required):
$ adb push archlinux_arm/sdcard//sdcard/
$ RM Archlinux_arm
$ RM run_chroot.sh
To connect to the device, start the configuration:
SuMount -o remount,rw/mkdir /system/CP /sdcard/run_ Chroot. sh /system/bin/chmod755 /system/bin/arch
Enter the CHROOT environment:
(device) # Arch (chroot) #
Get!
After it's done, you can change a faster source of software (for example, USTC) and decorate the messy software (such as GCC, make, CMake, Vim, Emacs, octave, Maxima ... ), Roll the system ...
Configuring the Gnu/linux Chroot environment on Android