forked from adam8157/kernel-studio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmkrootfs
More file actions
executable file
·78 lines (64 loc) · 1.61 KB
/
mkrootfs
File metadata and controls
executable file
·78 lines (64 loc) · 1.61 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
[ "$#" != "3" ] || { echo "Usage: $(basename "$0") filename_of_image busybox_dir"; exit 1; }
CWD=$(pwd)
BUSYBOX=$2
TMPDIR=rootfs
mkdir -p $TMPDIR
dd if=/dev/zero of=rootfs.img bs=1M count=32
mkfs.ext3 rootfs.img
mount -o loop rootfs.img $TMPDIR
cd $TMPDIR
mkdir -p dev/pts etc/init.d mnt proc root sys tmp usr/local
chmod a+rwxt tmp
cd ${CWD}
cp -rf ${BUSYBOX}/_install/* $TMPDIR
cp -rf app/bin/* $TMPDIR/bin
cp -rf app/workspace $TMPDIR
cp -rf app/pkg/* $TMPDIR/usr/local
cd $TMPDIR
mkdir -p usr/share/udhcpc
#cp -rf ${BUSYBOX}/examples/udhcp/simple.script $TMPDIR/usr/share/udhcpc/default.script
cat << EOF > etc/profile
echo
echo "Let's hack the kernel! keloyang"
echo
EOF
cat << EOF > etc/fstab
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
tmpfs /tmp tmpfs defaults 0 0
EOF
cat << EOF > etc/inittab
::sysinit:/etc/init.d/rcS
::respawn:-/bin/sh
tty2::askfirst:-/bin/sh
::ctrlaltdel:/bin/umount -a -r
EOF
cat << EOF > etc/init.d/rcS
#!bin/sh
/bin/mount -a
/sbin/mdev -s
mkdir /dev/pts
mount -vt devpts devpts /dev/pts
#/sbin/ifconfig eth0 up >/dev/null 2>&1 && /sbin/udhcpc eth0 >/dev/null 2>&1
ifconfig lo up
ifconfig eth0 up
ifconfig eth0 172.20.0.10 netmask 255.255.255.0
route add default gw 172.20.0.1
/usr/local/sshdog/start.sh
EOF
cat << EOF > etc/resolv.conf
nameserver 192.168.1.1
EOF
chmod 755 etc/init.d/rcS
#find ./ | cpio -o -H newc | gzip > ${CWD}/${1}
cd ${CWD}
umount $TMPDIR
rm -rf $TMPDIR
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -s 172.20.0.0/24 -j MASQUERADE
cat << EOF > /etc/qemu-ifup
#!/bin/bash
ifconfig "\$1" 172.20.0.1
EOF
exit 0