-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootdebian
63 lines (51 loc) · 1.78 KB
/
bootdebian
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
### Remember this path(/dev/block/stl9 /system).
export system_mount_point=/dev/block/stl9
echo "Mounting system as R/W"
mount -o remount,rw -t yaffs2 $system_mount_point /system
### Strings for mount:
echo "Setting some stuff up.."
export bin=/system/bin
export img_path=/mnt/sdcard/external_sd
export img=$img_path/debian.img
export mnt=/data/local/debian
export loop_device=/dev/block/loop5
export PATH=$bin:/usr/bin:/usr/sbin:/bin:$PATH
export TERM=linux
export HOME=/root
[ ! -e $mnt ] && mkdir -p $mnt
[ ! -e $img_path ] && mkdir -p $img_path
### Strings for mounting image on loop device, and configure network:
echo "Mounting the Linux Image"
mknod $loop_device b 7 0
losetup $loop_device $img
mount -t ext2 -o noatime,nodiratime $loop_device $mnt
mount -t devpts devpts $mnt/dev/pts
mount -t proc proc $mnt/proc
mount -t sysfs sysfs $mnt/sys
echo "Setting Up Networking"
sysctl -w net.ipv4.ip_forward=1
echo "nameserver 8.8.8.8" > $mnt/etc/resolv.conf
echo "nameserver 8.8.4.4" >> $mnt/etc/resolv.conf
echo "127.0.0.1 localhost" > $mnt/etc/hosts
### Strings for mount memory card:
echo "Mounting sdcard and emmc in /mnt"
[ ! -e $mnt/mnt/external_sd ] && mkdir -p $mnt/mnt/external_sd
busybox mount --bind /mnt/sdcard/external_sd $mnt/mnt/external_sd
[ ! -e $mnt/mnt/sdcard ] && mkdir -p $mnt/mnt/sdcard
busybox mount --bind /mnt/sdcard/ $mnt/mnt/sdcard
### Strings for entering in image by chroot:
echo "Entering CHROOT "
echo " "
chroot $mnt /bin/bash
### When exit, unmount everything.
### That's why you should stop work with debian by "exit" command:
echo "Shutting down CHROOT"
umount $mnt/mnt/emmc
umount $mnt/mnt/sdcard
sysctl -w net.ipv4.ip_forward=0
umount $mnt/dev/pts
umount $mnt/proc
umount $mnt/sys
umount $mnt
losetup -d $loop_device
mount -o remount,ro -t yaffs2 $system_mount_point /system