-
Notifications
You must be signed in to change notification settings - Fork 0
/
usb
executable file
·102 lines (94 loc) · 2.96 KB
/
usb
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/sh
# Live USB filesystem mounting -*- shell-script -*-
mountroot ()
{
CFG_FILE=/etc/moblin-initramfs.cfg
if [ -f ${CFG_FILE} ]
then
. ${CFG_FILE}
else
echo "Did not find config file: ${CFG_FILE}"
sleep 5
fi
mkdir -p /container
mkdir -p /squashmnt
mkdir -p /persistmnt
mkdir -p /mnt
# Find the USB flash drive
while true
do
for try in '1' '2' '3'; do
for device in 'sda' 'sdb' 'sdc' 'sdd'; do
echo "checking device /dev/${device} for installation source..."
if [ -e /sys/block/${device}/removable ]; then
if [ "$(cat /sys/block/${device}/removable)" = "1" ]; then
echo "Found Removable drive at /dev/${device}"
mount /dev/${device} /mnt
if [ -f /mnt/rootfs.img ] ; then
echo "Found Boot drive at /dev/${device}"
found="yes"
fi
umount /dev/${device}
if [ "$found" = "yes" ]; then
break;
fi
echo "/dev/${device} does not contain a rootfs"
fi
fi
done
if [ "$found" = "yes" ]; then
break;
fi
echo "Sleeping for 5 seconds"
/bin/sleep 5
echo "Sleeping finished"
done
if [ "$found" = "yes" ]; then
break;
fi
echo "Trying non-removable drives"
/bin/sleep 5
for device in 'sda' 'sdb' 'sdc' 'sdd'; do
echo "checking device /dev/${device} for installation source..."
mount /dev/${device} /mnt
if [ -f /mnt/rootfs.img ] ; then
echo "Found Boot drive at /dev/${device}"
found="yes"
fi
umount /dev/${device}
if [ "$found" = "yes" ]; then
break;
fi
echo "/dev/${device} does not contain a rootfs"
done
if [ "$found" = "yes" ]; then
break;
fi
done
echo "will mount root from /dev/${device}"
mount -o rw /dev/${device} /container 2> /dev/null
while [ ! -e "/container/rootfs.img" ]; do
/bin/sleep 1
mount -o rw /dev/${device} /container 2> /dev/null
done
mount -o ro,loop -t squashfs /container/rootfs.img /squashmnt
if [ -f /container/ext3fs.img ]; then
mount -o rw,loop,noatime,nodiratime /container/ext3fs.img /persistmnt
else
mount -t tmpfs -o noatime,nodiratime none /persistmnt
fi
mount -t unionfs -o dirs=/persistmnt=rw:/squashmnt=ro none ${rootmnt}
if [ -f /container/install.sh ]; then
log_begin_msg "Install Process will begin shortly..."
maybe_break preinstall
mkdir -p ${rootmnt}/tmp/install
mount --bind /dev ${rootmnt}/dev
mount --bind /sys ${rootmnt}/sys
mount --bind /proc ${rootmnt}/proc
mount --bind /container ${rootmnt}/tmp/install
cp /container/install.sh ${rootmnt}
cp /container/install.cfg ${rootmnt}
maybe_break install
chroot ${rootmnt} /install.sh ${BOOT}
fi
}