修改:     README.md
	新文件:   chrootonandroid.sh
This commit is contained in:
aixiao 2018-08-07 17:27:49 +00:00
parent db6ad4faaa
commit d1faf0df79
2 changed files with 94 additions and 1 deletions

View File

@ -1 +1,44 @@
# chrootonandroid # chrootonandroid
本机SD卡分区
root@LT18i:/ # fdisk /dev/block/mmcblk0
Command (m for help): p
Disk /dev/block/mmcblk0: 3768 MB, 3951034368 bytes, 7716864 sectors
478 cylinders, 256 heads, 63 sectors/track
Units: sectors of 1 * 512 = 512 bytes
Device Boot StartCHS EndCHS StartLBA EndLBA Sectors Size Id Type
/dev/block/mmcblk0p1 0,1,1 199,255,63 63 3225599 3225537 1574M 83 Linux
/dev/block/mmcblk0p2 200,0,1 477,255,63 3225600 7709183 4483584 2189M 83 Linux
Command (m for help):
格式化分区
mkfs.vfat /dev/block/mmcblk0p1
mkfs.ext3 /dev/block/mmcblk0p2
制作镜像
http://webthen.net/thread-140-1-2.html
mount /dev/block/mmcblk0p2 /mnt
debootstrap --foreign --arch armel wheezy /mnt http://ftp.cn.debian.org/debian/
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C chroot /mnt /debootstrap/debootstrap --second-stage
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C chroot /mnt dpkg --configure -a
安装opensh-server
chroot /data/local/debian/ /bin/bash
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH
export HOME=/root
apt-get update
apt-get install openssh-server
启动ChrootOnAndroid
SDDEVICEBLOCK=/dev/block/mmcblk0p2
export ROOT=/data/local/debian/
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH
export HOME=/root
#mount -t ext3 /dev/block/vold/179:2 /data/local/debian/
mount -t ext3 $SDDEVICEBLOCK /data/local/debian/
for f in dev dev/pts proc sys ; do mount -o bind /$f $ROOT/$f ; done
chroot $ROOT /etc/init.d/ssh start

50
chrootonandroid.sh Normal file
View File

@ -0,0 +1,50 @@
#!/system/bin/sh
#
# sony lt18i, CM 11, Android 4.4.4, Kernel 3.4
# ChrootOnAndroid
# 20180807
#
BBOX=/system/xbin/busybox
SDDEVICEBLOCK=/dev/block/mmcblk0p2
export ROOT=/data/local/debian/
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH
export HOME=/root
function start() {
#mount -t ext3 /dev/block/vold/179:2 /data/local/debian/
mount -t ext3 $SDDEVICEBLOCK /data/local/debian/
for f in dev dev/pts proc sys ; do mount -o bind /$f $ROOT/$f ; done
chroot $ROOT /etc/init.d/ssh start
}
function stop() {
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH chroot /data/local/debian/ /etc/init.d/ssh stop
umount /data/local/debian/sys
umount /data/local/debian/proc
umount /data/local/debian/dev/pts
umount /data/local/debian/dev
umount /data/local/debian/
}
function check() {
FS=$(cat /proc/mounts | grep ${ROOT})
if ! test "${FS}" = ""; then
echo "Repeated mount."; exit 1
fi
}
case $@ in
"start")
check
start
;;
"stop")
stop
;;
*)
bash $0 start
;;
esac