diff options
Diffstat (limited to 'meta/recipes-core/initrdscripts/files')
6 files changed, 1112 insertions, 0 deletions
diff --git a/meta/recipes-core/initrdscripts/files/init-boot.sh b/meta/recipes-core/initrdscripts/files/init-boot.sh new file mode 100644 index 0000000000..e82eba025d --- /dev/null +++ b/meta/recipes-core/initrdscripts/files/init-boot.sh | |||
@@ -0,0 +1,10 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | PATH=/sbin:/bin:/usr/sbin:/usr/bin | ||
4 | |||
5 | mkdir /proc | ||
6 | mkdir /sys | ||
7 | mount -t proc proc /proc | ||
8 | mount -t sysfs sysfs /sys | ||
9 | |||
10 | exec sh | ||
diff --git a/meta/recipes-core/initrdscripts/files/init-install-efi-testfs.sh b/meta/recipes-core/initrdscripts/files/init-install-efi-testfs.sh new file mode 100644 index 0000000000..7a0b4d4406 --- /dev/null +++ b/meta/recipes-core/initrdscripts/files/init-install-efi-testfs.sh | |||
@@ -0,0 +1,199 @@ | |||
1 | #!/bin/sh -e | ||
2 | # | ||
3 | # Copyright (c) 2012, Intel Corporation. | ||
4 | # All rights reserved. | ||
5 | # | ||
6 | # install.sh [device_name] [rootfs_name] | ||
7 | # | ||
8 | |||
9 | PATH=/sbin:/bin:/usr/sbin:/usr/bin | ||
10 | |||
11 | # We need 200 Mb for the boot partition | ||
12 | boot_size=200 | ||
13 | |||
14 | # 50% for the second rootfs | ||
15 | testfs_ratio=50 | ||
16 | |||
17 | found="no" | ||
18 | |||
19 | echo "Searching for a hard drive..." | ||
20 | for device in 'hda' 'hdb' 'sda' 'sdb' 'mmcblk0' 'mmcblk1' | ||
21 | do | ||
22 | if [ -e /sys/block/${device}/removable ]; then | ||
23 | if [ "$(cat /sys/block/${device}/removable)" = "0" ]; then | ||
24 | found="yes" | ||
25 | |||
26 | while true; do | ||
27 | # Try sleeping here to avoid getting kernel messages | ||
28 | # obscuring/confusing user | ||
29 | sleep 5 | ||
30 | echo "Found drive at /dev/${device}. Do you want to install this image there ? [y/n]" | ||
31 | read answer | ||
32 | if [ "$answer" = "y" ] ; then | ||
33 | break | ||
34 | fi | ||
35 | |||
36 | if [ "$answer" = "n" ] ; then | ||
37 | found=no | ||
38 | break | ||
39 | fi | ||
40 | |||
41 | echo "Please answer y or n" | ||
42 | done | ||
43 | fi | ||
44 | fi | ||
45 | |||
46 | if [ "$found" = "yes" ]; then | ||
47 | break; | ||
48 | fi | ||
49 | |||
50 | done | ||
51 | |||
52 | if [ "$found" = "no" ]; then | ||
53 | exit 1 | ||
54 | fi | ||
55 | |||
56 | echo "Installing image on /dev/${device}" | ||
57 | |||
58 | # | ||
59 | # The udev automounter can cause pain here, kill it | ||
60 | # | ||
61 | rm -f /etc/udev/rules.d/automount.rules | ||
62 | rm -f /etc/udev/scripts/mount* | ||
63 | |||
64 | # | ||
65 | # Unmount anything the automounter had mounted | ||
66 | # | ||
67 | umount /dev/${device}* 2> /dev/null || /bin/true | ||
68 | |||
69 | mkdir -p /tmp | ||
70 | cat /proc/mounts > /etc/mtab | ||
71 | |||
72 | disk_size=$(parted /dev/${device} unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//") | ||
73 | |||
74 | testfs_size=$((disk_size*testfs_ratio/100)) | ||
75 | rootfs_size=$((disk_size-boot_size-testfs_size)) | ||
76 | |||
77 | rootfs_start=$((boot_size)) | ||
78 | rootfs_end=$((rootfs_start+rootfs_size)) | ||
79 | testfs_start=$((rootfs_end)) | ||
80 | |||
81 | # MMC devices are special in a couple of ways | ||
82 | # 1) they use a partition prefix character 'p' | ||
83 | # 2) they are detected asynchronously (need rootwait) | ||
84 | rootwait="" | ||
85 | part_prefix="" | ||
86 | if [ ! "${device#mmcblk}" = "${device}" ]; then | ||
87 | part_prefix="p" | ||
88 | rootwait="rootwait" | ||
89 | fi | ||
90 | bootfs=/dev/${device}${part_prefix}1 | ||
91 | rootfs=/dev/${device}${part_prefix}2 | ||
92 | testfs=/dev/${device}${part_prefix}3 | ||
93 | |||
94 | echo "*****************" | ||
95 | echo "Boot partition size: $boot_size MB ($bootfs)" | ||
96 | echo "Rootfs partition size: $rootfs_size MB ($rootfs)" | ||
97 | echo "Testfs partition size: $testfs_size MB ($testfs)" | ||
98 | echo "*****************" | ||
99 | echo "Deleting partition table on /dev/${device} ..." | ||
100 | dd if=/dev/zero of=/dev/${device} bs=512 count=2 | ||
101 | |||
102 | echo "Creating new partition table on /dev/${device} ..." | ||
103 | parted /dev/${device} mklabel gpt | ||
104 | |||
105 | echo "Creating boot partition on $bootfs" | ||
106 | parted /dev/${device} mkpart primary 0% $boot_size | ||
107 | parted /dev/${device} set 1 boot on | ||
108 | |||
109 | echo "Creating rootfs partition on $rootfs" | ||
110 | parted /dev/${device} mkpart primary $rootfs_start $rootfs_end | ||
111 | |||
112 | echo "Creating testfs partition on $testfs" | ||
113 | parted /dev/${device} mkpart primary $testfs_start 100% | ||
114 | |||
115 | parted /dev/${device} print | ||
116 | |||
117 | echo "Formatting $bootfs to vfat..." | ||
118 | mkfs.vfat -n "boot" $bootfs | ||
119 | |||
120 | echo "Formatting $rootfs to ext3..." | ||
121 | mkfs.ext3 -L "platform" $rootfs | ||
122 | |||
123 | echo "Formatting $testfs to ext3..." | ||
124 | mkfs.ext3 -L "testrootfs" $testfs | ||
125 | |||
126 | mkdir /ssd | ||
127 | mkdir /rootmnt | ||
128 | mkdir /bootmnt | ||
129 | |||
130 | mount $rootfs /ssd | ||
131 | mount -o rw,loop,noatime,nodiratime /run/media/$1/$2 /rootmnt | ||
132 | |||
133 | echo "Copying rootfs files..." | ||
134 | cp -a /rootmnt/* /ssd | ||
135 | |||
136 | touch /ssd/etc/masterimage | ||
137 | |||
138 | if [ -d /ssd/etc/ ] ; then | ||
139 | # We dont want udev to mount our root device while we're booting... | ||
140 | if [ -d /ssd/etc/udev/ ] ; then | ||
141 | echo "/dev/${device}" >> /ssd/etc/udev/mount.blacklist | ||
142 | fi | ||
143 | fi | ||
144 | |||
145 | umount /ssd | ||
146 | umount /rootmnt | ||
147 | |||
148 | echo "Preparing boot partition..." | ||
149 | mount $bootfs /ssd | ||
150 | |||
151 | EFIDIR="/ssd/EFI/BOOT" | ||
152 | mkdir -p $EFIDIR | ||
153 | cp /run/media/$1/vmlinuz /ssd | ||
154 | # Copy the efi loader | ||
155 | cp /run/media/$1/EFI/BOOT/*.efi $EFIDIR | ||
156 | |||
157 | if [ -f /run/media/$1/EFI/BOOT/grub.cfg ]; then | ||
158 | GRUBCFG="$EFIDIR/grub.cfg" | ||
159 | cp /run/media/$1/EFI/BOOT/grub.cfg $GRUBCFG | ||
160 | # Update grub config for the installed image | ||
161 | # Delete the install entry | ||
162 | sed -i "/menuentry 'install'/,/^}/d" $GRUBCFG | ||
163 | # Delete the initrd lines | ||
164 | sed -i "/initrd /d" $GRUBCFG | ||
165 | # Delete any LABEL= strings | ||
166 | sed -i "s/ LABEL=[^ ]*/ /" $GRUBCFG | ||
167 | # Delete any root= strings | ||
168 | sed -i "s/ root=[^ ]*/ /" $GRUBCFG | ||
169 | # Add the root= and other standard boot options | ||
170 | sed -i "s@linux /vmlinuz *@linux /vmlinuz root=$rootfs rw $rootwait quiet @" $GRUBCFG | ||
171 | fi | ||
172 | |||
173 | if [ -d /run/media/$1/loader ]; then | ||
174 | GUMMIBOOT_CFGS="/ssd/loader/entries/*.conf" | ||
175 | # copy config files for gummiboot | ||
176 | cp -dr /run/media/$1/loader /ssd | ||
177 | # delete the install entry | ||
178 | rm -f /ssd/loader/entries/install.conf | ||
179 | # delete the initrd lines | ||
180 | sed -i "/initrd /d" $GUMMIBOOT_CFGS | ||
181 | # delete any LABEL= strings | ||
182 | sed -i "s/ LABEL=[^ ]*/ /" $GUMMIBOOT_CFGS | ||
183 | # delete any root= strings | ||
184 | sed -i "s/ root=[^ ]*/ /" $GUMMIBOOT_CFGS | ||
185 | # add the root= and other standard boot options | ||
186 | sed -i "s@options *@options root=$rootfs rw $rootwait quiet @" $GUMMIBOOT_CFGS | ||
187 | # Add the test label | ||
188 | echo -ne "title test\nlinux /test-kernel\noptions root=$testfs rw $rootwait quiet\n" > /ssd/loader/entries/test.conf | ||
189 | fi | ||
190 | |||
191 | umount /ssd | ||
192 | sync | ||
193 | |||
194 | echo "Remove your installation media, and press ENTER" | ||
195 | |||
196 | read enter | ||
197 | |||
198 | echo "Rebooting..." | ||
199 | reboot -f | ||
diff --git a/meta/recipes-core/initrdscripts/files/init-install-efi.sh b/meta/recipes-core/initrdscripts/files/init-install-efi.sh new file mode 100644 index 0000000000..329586d74d --- /dev/null +++ b/meta/recipes-core/initrdscripts/files/init-install-efi.sh | |||
@@ -0,0 +1,230 @@ | |||
1 | #!/bin/sh -e | ||
2 | # | ||
3 | # Copyright (c) 2012, Intel Corporation. | ||
4 | # All rights reserved. | ||
5 | # | ||
6 | # install.sh [device_name] [rootfs_name] | ||
7 | # | ||
8 | |||
9 | PATH=/sbin:/bin:/usr/sbin:/usr/bin | ||
10 | |||
11 | # We need 20 Mb for the boot partition | ||
12 | boot_size=20 | ||
13 | |||
14 | # 5% for swap | ||
15 | swap_ratio=5 | ||
16 | |||
17 | # Get a list of hard drives | ||
18 | hdnamelist="" | ||
19 | live_dev_name=${1%%/*} | ||
20 | live_dev_name=${live_dev_name%%[0-9]*} | ||
21 | |||
22 | echo "Searching for hard drives ..." | ||
23 | |||
24 | for device in `ls /sys/block/`; do | ||
25 | case $device in | ||
26 | loop*) | ||
27 | # skip loop device | ||
28 | ;; | ||
29 | sr*) | ||
30 | # skip CDROM device | ||
31 | ;; | ||
32 | ram*) | ||
33 | # skip ram device | ||
34 | ;; | ||
35 | *) | ||
36 | # skip the device LiveOS is on | ||
37 | # Add valid hard drive name to the list | ||
38 | if [ $device != $live_dev_name -a -e /dev/$device ]; then | ||
39 | hdnamelist="$hdnamelist $device" | ||
40 | fi | ||
41 | ;; | ||
42 | esac | ||
43 | done | ||
44 | |||
45 | TARGET_DEVICE_NAME="" | ||
46 | for hdname in $hdnamelist; do | ||
47 | # Display found hard drives and their basic info | ||
48 | echo "-------------------------------" | ||
49 | echo /dev/$hdname | ||
50 | if [ -r /sys/block/$hdname/device/vendor ]; then | ||
51 | echo -n "VENDOR=" | ||
52 | cat /sys/block/$hdname/device/vendor | ||
53 | fi | ||
54 | if [ -r /sys/block/$hdname/device/model ]; then | ||
55 | echo -n "MODEL=" | ||
56 | cat /sys/block/$hdname/device/model | ||
57 | fi | ||
58 | if [ -r /sys/block/$hdname/device/uevent ]; then | ||
59 | echo -n "UEVENT=" | ||
60 | cat /sys/block/$hdname/device/uevent | ||
61 | fi | ||
62 | echo | ||
63 | # Get user choice | ||
64 | while true; do | ||
65 | echo -n "Do you want to install this image there? [y/n] " | ||
66 | read answer | ||
67 | if [ "$answer" = "y" -o "$answer" = "n" ]; then | ||
68 | break | ||
69 | fi | ||
70 | echo "Please answer y or n" | ||
71 | done | ||
72 | if [ "$answer" = "y" ]; then | ||
73 | TARGET_DEVICE_NAME=$hdname | ||
74 | break | ||
75 | fi | ||
76 | |||
77 | done | ||
78 | |||
79 | if [ -n "$TARGET_DEVICE_NAME" ]; then | ||
80 | echo "Installing image on /dev/$TARGET_DEVICE_NAME ..." | ||
81 | else | ||
82 | echo "No hard drive selected. Installation aborted." | ||
83 | exit 1 | ||
84 | fi | ||
85 | |||
86 | device=$TARGET_DEVICE_NAME | ||
87 | |||
88 | # | ||
89 | # The udev automounter can cause pain here, kill it | ||
90 | # | ||
91 | rm -f /etc/udev/rules.d/automount.rules | ||
92 | rm -f /etc/udev/scripts/mount* | ||
93 | |||
94 | # | ||
95 | # Unmount anything the automounter had mounted | ||
96 | # | ||
97 | umount /dev/${device}* 2> /dev/null || /bin/true | ||
98 | |||
99 | mkdir -p /tmp | ||
100 | cat /proc/mounts > /etc/mtab | ||
101 | |||
102 | disk_size=$(parted /dev/${device} unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//") | ||
103 | |||
104 | swap_size=$((disk_size*swap_ratio/100)) | ||
105 | rootfs_size=$((disk_size-boot_size-swap_size)) | ||
106 | |||
107 | rootfs_start=$((boot_size)) | ||
108 | rootfs_end=$((rootfs_start+rootfs_size)) | ||
109 | swap_start=$((rootfs_end)) | ||
110 | |||
111 | # MMC devices are special in a couple of ways | ||
112 | # 1) they use a partition prefix character 'p' | ||
113 | # 2) they are detected asynchronously (need rootwait) | ||
114 | rootwait="" | ||
115 | part_prefix="" | ||
116 | if [ ! "${device#mmcblk}" = "${device}" ]; then | ||
117 | part_prefix="p" | ||
118 | rootwait="rootwait" | ||
119 | fi | ||
120 | bootfs=/dev/${device}${part_prefix}1 | ||
121 | rootfs=/dev/${device}${part_prefix}2 | ||
122 | swap=/dev/${device}${part_prefix}3 | ||
123 | |||
124 | echo "*****************" | ||
125 | echo "Boot partition size: $boot_size MB ($bootfs)" | ||
126 | echo "Rootfs partition size: $rootfs_size MB ($rootfs)" | ||
127 | echo "Swap partition size: $swap_size MB ($swap)" | ||
128 | echo "*****************" | ||
129 | echo "Deleting partition table on /dev/${device} ..." | ||
130 | dd if=/dev/zero of=/dev/${device} bs=512 count=2 | ||
131 | |||
132 | echo "Creating new partition table on /dev/${device} ..." | ||
133 | parted /dev/${device} mklabel gpt | ||
134 | |||
135 | echo "Creating boot partition on $bootfs" | ||
136 | parted /dev/${device} mkpart primary 0% $boot_size | ||
137 | parted /dev/${device} set 1 boot on | ||
138 | |||
139 | echo "Creating rootfs partition on $rootfs" | ||
140 | parted /dev/${device} mkpart primary $rootfs_start $rootfs_end | ||
141 | |||
142 | echo "Creating swap partition on $swap" | ||
143 | parted /dev/${device} mkpart primary $swap_start 100% | ||
144 | |||
145 | parted /dev/${device} print | ||
146 | |||
147 | echo "Formatting $bootfs to vfat..." | ||
148 | mkfs.vfat $bootfs | ||
149 | |||
150 | echo "Formatting $rootfs to ext3..." | ||
151 | mkfs.ext3 $rootfs | ||
152 | |||
153 | echo "Formatting swap partition...($swap)" | ||
154 | mkswap $swap | ||
155 | |||
156 | mkdir /tgt_root | ||
157 | mkdir /src_root | ||
158 | mkdir -p /boot | ||
159 | |||
160 | # Handling of the target root partition | ||
161 | mount $rootfs /tgt_root | ||
162 | mount -o rw,loop,noatime,nodiratime /run/media/$1/$2 /src_root | ||
163 | echo "Copying rootfs files..." | ||
164 | cp -a /src_root/* /tgt_root | ||
165 | if [ -d /tgt_root/etc/ ] ; then | ||
166 | echo "$swap swap swap defaults 0 0" >> /tgt_root/etc/fstab | ||
167 | echo "$bootfs /boot vfat defaults 1 2" >> /tgt_root/etc/fstab | ||
168 | # We dont want udev to mount our root device while we're booting... | ||
169 | if [ -d /tgt_root/etc/udev/ ] ; then | ||
170 | echo "/dev/${device}" >> /tgt_root/etc/udev/mount.blacklist | ||
171 | fi | ||
172 | fi | ||
173 | |||
174 | umount /src_root | ||
175 | |||
176 | # Handling of the target boot partition | ||
177 | mount $bootfs /boot | ||
178 | echo "Preparing boot partition..." | ||
179 | |||
180 | EFIDIR="/boot/EFI/BOOT" | ||
181 | mkdir -p $EFIDIR | ||
182 | # Copy the efi loader | ||
183 | cp /run/media/$1/EFI/BOOT/*.efi $EFIDIR | ||
184 | |||
185 | if [ -f /run/media/$1/EFI/BOOT/grub.cfg ]; then | ||
186 | GRUBCFG="$EFIDIR/grub.cfg" | ||
187 | cp /run/media/$1/EFI/BOOT/grub.cfg $GRUBCFG | ||
188 | # Update grub config for the installed image | ||
189 | # Delete the install entry | ||
190 | sed -i "/menuentry 'install'/,/^}/d" $GRUBCFG | ||
191 | # Delete the initrd lines | ||
192 | sed -i "/initrd /d" $GRUBCFG | ||
193 | # Delete any LABEL= strings | ||
194 | sed -i "s/ LABEL=[^ ]*/ /" $GRUBCFG | ||
195 | # Delete any root= strings | ||
196 | sed -i "s/ root=[^ ]*/ /" $GRUBCFG | ||
197 | # Add the root= and other standard boot options | ||
198 | sed -i "s@linux /vmlinuz *@linux /vmlinuz root=$rootfs rw $rootwait quiet @" $GRUBCFG | ||
199 | fi | ||
200 | |||
201 | if [ -d /run/media/$1/loader ]; then | ||
202 | GUMMIBOOT_CFGS="/boot/loader/entries/*.conf" | ||
203 | # copy config files for gummiboot | ||
204 | cp -dr /run/media/$1/loader /boot | ||
205 | # delete the install entry | ||
206 | rm -f /boot/loader/entries/install.conf | ||
207 | # delete the initrd lines | ||
208 | sed -i "/initrd /d" $GUMMIBOOT_CFGS | ||
209 | # delete any LABEL= strings | ||
210 | sed -i "s/ LABEL=[^ ]*/ /" $GUMMIBOOT_CFGS | ||
211 | # delete any root= strings | ||
212 | sed -i "s/ root=[^ ]*/ /" $GUMMIBOOT_CFGS | ||
213 | # add the root= and other standard boot options | ||
214 | sed -i "s@options *@options root=$rootfs rw $rootwait quiet @" $GUMMIBOOT_CFGS | ||
215 | fi | ||
216 | |||
217 | umount /tgt_root | ||
218 | |||
219 | cp /run/media/$1/vmlinuz /boot | ||
220 | |||
221 | umount /boot | ||
222 | |||
223 | sync | ||
224 | |||
225 | echo "Remove your installation media, and press ENTER" | ||
226 | |||
227 | read enter | ||
228 | |||
229 | echo "Rebooting..." | ||
230 | reboot -f | ||
diff --git a/meta/recipes-core/initrdscripts/files/init-install-testfs.sh b/meta/recipes-core/initrdscripts/files/init-install-testfs.sh new file mode 100644 index 0000000000..ac62160528 --- /dev/null +++ b/meta/recipes-core/initrdscripts/files/init-install-testfs.sh | |||
@@ -0,0 +1,220 @@ | |||
1 | #!/bin/sh -e | ||
2 | # | ||
3 | # Copyright (C) 2008-2011 Intel | ||
4 | # | ||
5 | # install.sh [device_name] [rootfs_name] [video_mode] [vga_mode] | ||
6 | # | ||
7 | |||
8 | PATH=/sbin:/bin:/usr/sbin:/usr/bin | ||
9 | |||
10 | # We need 20 Mb for the boot partition | ||
11 | boot_size=200 | ||
12 | |||
13 | # 50% for the the test partition | ||
14 | testfs_ratio=50 | ||
15 | |||
16 | # Get a list of hard drives | ||
17 | hdnamelist="" | ||
18 | live_dev_name=${1%%/*} | ||
19 | |||
20 | echo "Searching for hard drives ..." | ||
21 | |||
22 | for device in `ls /sys/block/`; do | ||
23 | case $device in | ||
24 | loop*) | ||
25 | # skip loop device | ||
26 | ;; | ||
27 | ram*) | ||
28 | # skip ram device | ||
29 | ;; | ||
30 | *) | ||
31 | # skip the device LiveOS is on | ||
32 | # Add valid hard drive name to the list | ||
33 | if [ $device != $live_dev_name -a -e /dev/$device ]; then | ||
34 | hdnamelist="$hdnamelist $device" | ||
35 | fi | ||
36 | ;; | ||
37 | esac | ||
38 | done | ||
39 | |||
40 | TARGET_DEVICE_NAME="" | ||
41 | for hdname in $hdnamelist; do | ||
42 | # Display found hard drives and their basic info | ||
43 | echo "-------------------------------" | ||
44 | echo /dev/$hdname | ||
45 | if [ -r /sys/block/$hdname/device/vendor ]; then | ||
46 | echo -n "VENDOR=" | ||
47 | cat /sys/block/$hdname/device/vendor | ||
48 | fi | ||
49 | echo -n "MODEL=" | ||
50 | cat /sys/block/$hdname/device/model | ||
51 | cat /sys/block/$hdname/device/uevent | ||
52 | echo | ||
53 | # Get user choice | ||
54 | while true; do | ||
55 | echo -n "Do you want to install this image there? [y/n] " | ||
56 | read answer | ||
57 | if [ "$answer" = "y" -o "$answer" = "n" ]; then | ||
58 | break | ||
59 | fi | ||
60 | echo "Please answer y or n" | ||
61 | done | ||
62 | if [ "$answer" = "y" ]; then | ||
63 | TARGET_DEVICE_NAME=$hdname | ||
64 | break | ||
65 | fi | ||
66 | done | ||
67 | |||
68 | if [ -n "$TARGET_DEVICE_NAME" ]; then | ||
69 | echo "Installing image on /dev/$TARGET_DEVICE_NAME ..." | ||
70 | else | ||
71 | echo "No hard drive selected. Installation aborted." | ||
72 | exit 1 | ||
73 | fi | ||
74 | |||
75 | device=$TARGET_DEVICE_NAME | ||
76 | |||
77 | # | ||
78 | # The udev automounter can cause pain here, kill it | ||
79 | # | ||
80 | rm -f /etc/udev/rules.d/automount.rules | ||
81 | rm -f /etc/udev/scripts/mount* | ||
82 | |||
83 | # | ||
84 | # Unmount anything the automounter had mounted | ||
85 | # | ||
86 | umount /dev/${device}* 2> /dev/null || /bin/true | ||
87 | |||
88 | if [ ! -b /dev/loop0 ] ; then | ||
89 | mknod /dev/loop0 b 7 0 | ||
90 | fi | ||
91 | |||
92 | mkdir -p /tmp | ||
93 | if [ ! -L /etc/mtab ]; then | ||
94 | cat /proc/mounts > /etc/mtab | ||
95 | fi | ||
96 | |||
97 | disk_size=$(parted /dev/${device} unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//") | ||
98 | |||
99 | testfs_size=$((disk_size*testfs_ratio/100)) | ||
100 | rootfs_size=$((disk_size-boot_size-testfs_size)) | ||
101 | |||
102 | rootfs_start=$((boot_size)) | ||
103 | rootfs_end=$((rootfs_start+rootfs_size)) | ||
104 | testfs_start=$((rootfs_end)) | ||
105 | |||
106 | # MMC devices are special in a couple of ways | ||
107 | # 1) they use a partition prefix character 'p' | ||
108 | # 2) they are detected asynchronously (need rootwait) | ||
109 | rootwait="" | ||
110 | part_prefix="" | ||
111 | if [ ! "${device#mmcblk}" = "${device}" ]; then | ||
112 | part_prefix="p" | ||
113 | rootwait="rootwait" | ||
114 | fi | ||
115 | bootfs=/dev/${device}${part_prefix}1 | ||
116 | rootfs=/dev/${device}${part_prefix}2 | ||
117 | testfs=/dev/${device}${part_prefix}3 | ||
118 | |||
119 | echo "*****************" | ||
120 | echo "Boot partition size: $boot_size MB ($bootfs)" | ||
121 | echo "Rootfs partition size: $rootfs_size MB ($rootfs)" | ||
122 | echo "Testfs partition size: $testfs_size MB ($testfs)" | ||
123 | echo "*****************" | ||
124 | echo "Deleting partition table on /dev/${device} ..." | ||
125 | dd if=/dev/zero of=/dev/${device} bs=512 count=2 | ||
126 | |||
127 | echo "Creating new partition table on /dev/${device} ..." | ||
128 | parted /dev/${device} mklabel msdos | ||
129 | |||
130 | echo "Creating boot partition on $bootfs" | ||
131 | parted /dev/${device} mkpart primary 0% $boot_size | ||
132 | |||
133 | echo "Creating rootfs partition on $rootfs" | ||
134 | parted /dev/${device} mkpart primary $rootfs_start $rootfs_end | ||
135 | |||
136 | echo "Creating testfs partition on $testfs" | ||
137 | parted /dev/${device} mkpart primary $testfs_start 100% | ||
138 | |||
139 | parted /dev/${device} print | ||
140 | |||
141 | echo "Formatting $bootfs to ext3..." | ||
142 | mkfs.ext3 -L "boot" $bootfs | ||
143 | |||
144 | echo "Formatting $rootfs to ext3..." | ||
145 | mkfs.ext3 -L "rootfs" $rootfs | ||
146 | |||
147 | echo "Formatting $testfs to ext3..." | ||
148 | mkfs.ext3 -L "testrootfs" $testfs | ||
149 | |||
150 | mkdir /tgt_root | ||
151 | mkdir /src_root | ||
152 | mkdir -p /boot | ||
153 | |||
154 | # Handling of the target root partition | ||
155 | mount $rootfs /tgt_root | ||
156 | mount -o rw,loop,noatime,nodiratime /run/media/$1/$2 /src_root | ||
157 | |||
158 | echo "Copying rootfs files..." | ||
159 | cp -a /src_root/* /tgt_root | ||
160 | |||
161 | touch /tgt_root/etc/masterimage | ||
162 | |||
163 | if [ -d /tgt_root/etc/ ] ; then | ||
164 | echo "$bootfs /boot ext3 defaults 1 2" >> /tgt_root/etc/fstab | ||
165 | # We dont want udev to mount our root device while we're booting... | ||
166 | if [ -d /tgt_root/etc/udev/ ] ; then | ||
167 | echo "/dev/${device}" >> /tgt_root/etc/udev/mount.blacklist | ||
168 | fi | ||
169 | fi | ||
170 | umount /tgt_root | ||
171 | umount /src_root | ||
172 | |||
173 | # Handling of the target boot partition | ||
174 | mount $bootfs /boot | ||
175 | echo "Preparing boot partition..." | ||
176 | if [ -f /etc/grub.d/00_header ] ; then | ||
177 | echo "Preparing custom grub2 menu..." | ||
178 | GRUBCFG="/boot/grub/grub.cfg" | ||
179 | mkdir -p $(dirname $GRUBCFG) | ||
180 | cat >$GRUBCFG <<_EOF | ||
181 | serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1 | ||
182 | terminal_input --append serial | ||
183 | terminal_output --append serial | ||
184 | set timeout_style=hidden | ||
185 | set timeout=5 | ||
186 | menuentry "Linux" { | ||
187 | set root=(hd0,1) | ||
188 | linux /vmlinuz root=$rootfs $rootwait rw $5 $3 $4 quiet | ||
189 | } | ||
190 | _EOF | ||
191 | # Add the test label | ||
192 | echo -ne "\nmenuentry 'test' --hotkey x {\nlinux /test-kernel root=$testfs rw $rootwait quiet\n}\n" >> $GRUBCFG | ||
193 | |||
194 | chmod 0444 $GRUBCFG | ||
195 | fi | ||
196 | grub-install /dev/${device} | ||
197 | echo "(hd0) /dev/${device}" > /boot/grub/device.map | ||
198 | |||
199 | # If grub.cfg doesn't exist, assume GRUB 0.97 and create a menu.lst | ||
200 | if [ ! -f /boot/grub/grub.cfg ] ; then | ||
201 | echo "Preparing custom grub menu..." | ||
202 | echo "default 0" > /boot/grub/menu.lst | ||
203 | echo "timeout 30" >> /boot/grub/menu.lst | ||
204 | echo "title Live Boot/Install-Image" >> /boot/grub/menu.lst | ||
205 | echo "root (hd0,0)" >> /boot/grub/menu.lst | ||
206 | echo "kernel /vmlinuz root=$rootfs rw $3 $4 quiet" >> /boot/grub/menu.lst | ||
207 | fi | ||
208 | |||
209 | cp /run/media/$1/vmlinuz /boot/ | ||
210 | |||
211 | umount /boot | ||
212 | |||
213 | sync | ||
214 | |||
215 | echo "Remove your installation media, and press ENTER" | ||
216 | |||
217 | read enter | ||
218 | |||
219 | echo "Rebooting..." | ||
220 | reboot -f | ||
diff --git a/meta/recipes-core/initrdscripts/files/init-install.sh b/meta/recipes-core/initrdscripts/files/init-install.sh new file mode 100644 index 0000000000..fb537ee310 --- /dev/null +++ b/meta/recipes-core/initrdscripts/files/init-install.sh | |||
@@ -0,0 +1,218 @@ | |||
1 | #!/bin/sh -e | ||
2 | # | ||
3 | # Copyright (C) 2008-2011 Intel | ||
4 | # | ||
5 | # install.sh [device_name] [rootfs_name] [video_mode] [vga_mode] | ||
6 | # | ||
7 | |||
8 | PATH=/sbin:/bin:/usr/sbin:/usr/bin | ||
9 | |||
10 | # We need 20 Mb for the boot partition | ||
11 | boot_size=20 | ||
12 | |||
13 | # 5% for the swap | ||
14 | swap_ratio=5 | ||
15 | |||
16 | # Get a list of hard drives | ||
17 | hdnamelist="" | ||
18 | live_dev_name=${1%%/*} | ||
19 | live_dev_name=${live_dev_name%%[0-9]*} | ||
20 | |||
21 | echo "Searching for hard drives ..." | ||
22 | |||
23 | for device in `ls /sys/block/`; do | ||
24 | case $device in | ||
25 | loop*) | ||
26 | # skip loop device | ||
27 | ;; | ||
28 | sr*) | ||
29 | # skip CDROM device | ||
30 | ;; | ||
31 | ram*) | ||
32 | # skip ram device | ||
33 | ;; | ||
34 | *) | ||
35 | # skip the device LiveOS is on | ||
36 | # Add valid hard drive name to the list | ||
37 | if [ $device != $live_dev_name -a -e /dev/$device ]; then | ||
38 | hdnamelist="$hdnamelist $device" | ||
39 | fi | ||
40 | ;; | ||
41 | esac | ||
42 | done | ||
43 | |||
44 | TARGET_DEVICE_NAME="" | ||
45 | for hdname in $hdnamelist; do | ||
46 | # Display found hard drives and their basic info | ||
47 | echo "-------------------------------" | ||
48 | echo /dev/$hdname | ||
49 | if [ -r /sys/block/$hdname/device/vendor ]; then | ||
50 | echo -n "VENDOR=" | ||
51 | cat /sys/block/$hdname/device/vendor | ||
52 | fi | ||
53 | if [ -r /sys/block/$hdname/device/model ]; then | ||
54 | echo -n "MODEL=" | ||
55 | cat /sys/block/$hdname/device/model | ||
56 | fi | ||
57 | if [ -r /sys/block/$hdname/device/uevent ]; then | ||
58 | echo -n "UEVENT=" | ||
59 | cat /sys/block/$hdname/device/uevent | ||
60 | fi | ||
61 | echo | ||
62 | # Get user choice | ||
63 | while true; do | ||
64 | echo -n "Do you want to install this image there? [y/n] " | ||
65 | read answer | ||
66 | if [ "$answer" = "y" -o "$answer" = "n" ]; then | ||
67 | break | ||
68 | fi | ||
69 | echo "Please answer y or n" | ||
70 | done | ||
71 | if [ "$answer" = "y" ]; then | ||
72 | TARGET_DEVICE_NAME=$hdname | ||
73 | break | ||
74 | fi | ||
75 | done | ||
76 | |||
77 | if [ -n "$TARGET_DEVICE_NAME" ]; then | ||
78 | echo "Installing image on /dev/$TARGET_DEVICE_NAME ..." | ||
79 | else | ||
80 | echo "No hard drive selected. Installation aborted." | ||
81 | exit 1 | ||
82 | fi | ||
83 | |||
84 | device=$TARGET_DEVICE_NAME | ||
85 | |||
86 | # | ||
87 | # The udev automounter can cause pain here, kill it | ||
88 | # | ||
89 | rm -f /etc/udev/rules.d/automount.rules | ||
90 | rm -f /etc/udev/scripts/mount* | ||
91 | |||
92 | # | ||
93 | # Unmount anything the automounter had mounted | ||
94 | # | ||
95 | umount /dev/${device}* 2> /dev/null || /bin/true | ||
96 | |||
97 | if [ ! -b /dev/loop0 ] ; then | ||
98 | mknod /dev/loop0 b 7 0 | ||
99 | fi | ||
100 | |||
101 | mkdir -p /tmp | ||
102 | if [ ! -L /etc/mtab ]; then | ||
103 | cat /proc/mounts > /etc/mtab | ||
104 | fi | ||
105 | |||
106 | disk_size=$(parted /dev/${device} unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//") | ||
107 | |||
108 | swap_size=$((disk_size*swap_ratio/100)) | ||
109 | rootfs_size=$((disk_size-boot_size-swap_size)) | ||
110 | |||
111 | rootfs_start=$((boot_size)) | ||
112 | rootfs_end=$((rootfs_start+rootfs_size)) | ||
113 | swap_start=$((rootfs_end)) | ||
114 | |||
115 | # MMC devices are special in a couple of ways | ||
116 | # 1) they use a partition prefix character 'p' | ||
117 | # 2) they are detected asynchronously (need rootwait) | ||
118 | rootwait="" | ||
119 | part_prefix="" | ||
120 | if [ ! "${device#mmcblk}" = "${device}" ]; then | ||
121 | part_prefix="p" | ||
122 | rootwait="rootwait" | ||
123 | fi | ||
124 | bootfs=/dev/${device}${part_prefix}1 | ||
125 | rootfs=/dev/${device}${part_prefix}2 | ||
126 | swap=/dev/${device}${part_prefix}3 | ||
127 | |||
128 | echo "*****************" | ||
129 | echo "Boot partition size: $boot_size MB ($bootfs)" | ||
130 | echo "Rootfs partition size: $rootfs_size MB ($rootfs)" | ||
131 | echo "Swap partition size: $swap_size MB ($swap)" | ||
132 | echo "*****************" | ||
133 | echo "Deleting partition table on /dev/${device} ..." | ||
134 | dd if=/dev/zero of=/dev/${device} bs=512 count=2 | ||
135 | |||
136 | echo "Creating new partition table on /dev/${device} ..." | ||
137 | parted /dev/${device} mklabel msdos | ||
138 | |||
139 | echo "Creating boot partition on $bootfs" | ||
140 | parted /dev/${device} mkpart primary 0% $boot_size | ||
141 | |||
142 | echo "Creating rootfs partition on $rootfs" | ||
143 | parted /dev/${device} mkpart primary $rootfs_start $rootfs_end | ||
144 | |||
145 | echo "Creating swap partition on $swap" | ||
146 | parted /dev/${device} mkpart primary $swap_start 100% | ||
147 | |||
148 | parted /dev/${device} print | ||
149 | |||
150 | echo "Formatting $bootfs to ext3..." | ||
151 | mkfs.ext3 $bootfs | ||
152 | |||
153 | echo "Formatting $rootfs to ext3..." | ||
154 | mkfs.ext3 $rootfs | ||
155 | |||
156 | echo "Formatting swap partition...($swap)" | ||
157 | mkswap $swap | ||
158 | |||
159 | mkdir /tgt_root | ||
160 | mkdir /src_root | ||
161 | mkdir -p /boot | ||
162 | |||
163 | # Handling of the target root partition | ||
164 | mount $rootfs /tgt_root | ||
165 | mount -o rw,loop,noatime,nodiratime /run/media/$1/$2 /src_root | ||
166 | echo "Copying rootfs files..." | ||
167 | cp -a /src_root/* /tgt_root | ||
168 | if [ -d /tgt_root/etc/ ] ; then | ||
169 | echo "$swap swap swap defaults 0 0" >> /tgt_root/etc/fstab | ||
170 | echo "$bootfs /boot ext3 defaults 1 2" >> /tgt_root/etc/fstab | ||
171 | # We dont want udev to mount our root device while we're booting... | ||
172 | if [ -d /tgt_root/etc/udev/ ] ; then | ||
173 | echo "/dev/${device}" >> /tgt_root/etc/udev/mount.blacklist | ||
174 | fi | ||
175 | fi | ||
176 | umount /tgt_root | ||
177 | umount /src_root | ||
178 | |||
179 | # Handling of the target boot partition | ||
180 | mount $bootfs /boot | ||
181 | echo "Preparing boot partition..." | ||
182 | if [ -f /etc/grub.d/00_header ] ; then | ||
183 | echo "Preparing custom grub2 menu..." | ||
184 | GRUBCFG="/boot/grub/grub.cfg" | ||
185 | mkdir -p $(dirname $GRUBCFG) | ||
186 | cat >$GRUBCFG <<_EOF | ||
187 | menuentry "Linux" { | ||
188 | set root=(hd0,1) | ||
189 | linux /vmlinuz root=$rootfs $rootwait rw $5 $3 $4 quiet | ||
190 | } | ||
191 | _EOF | ||
192 | chmod 0444 $GRUBCFG | ||
193 | fi | ||
194 | grub-install /dev/${device} | ||
195 | echo "(hd0) /dev/${device}" > /boot/grub/device.map | ||
196 | |||
197 | # If grub.cfg doesn't exist, assume GRUB 0.97 and create a menu.lst | ||
198 | if [ ! -f /boot/grub/grub.cfg ] ; then | ||
199 | echo "Preparing custom grub menu..." | ||
200 | echo "default 0" > /boot/grub/menu.lst | ||
201 | echo "timeout 30" >> /boot/grub/menu.lst | ||
202 | echo "title Live Boot/Install-Image" >> /boot/grub/menu.lst | ||
203 | echo "root (hd0,0)" >> /boot/grub/menu.lst | ||
204 | echo "kernel /vmlinuz root=$rootfs rw $3 $4 quiet" >> /boot/grub/menu.lst | ||
205 | fi | ||
206 | |||
207 | cp /run/media/$1/vmlinuz /boot/ | ||
208 | |||
209 | umount /boot | ||
210 | |||
211 | sync | ||
212 | |||
213 | echo "Remove your installation media, and press ENTER" | ||
214 | |||
215 | read enter | ||
216 | |||
217 | echo "Rebooting..." | ||
218 | reboot -f | ||
diff --git a/meta/recipes-core/initrdscripts/files/init-live.sh b/meta/recipes-core/initrdscripts/files/init-live.sh new file mode 100644 index 0000000000..d852c5737f --- /dev/null +++ b/meta/recipes-core/initrdscripts/files/init-live.sh | |||
@@ -0,0 +1,235 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | PATH=/sbin:/bin:/usr/sbin:/usr/bin | ||
4 | |||
5 | ROOT_MOUNT="/rootfs/" | ||
6 | ROOT_IMAGE="rootfs.img" | ||
7 | MOUNT="/bin/mount" | ||
8 | UMOUNT="/bin/umount" | ||
9 | ISOLINUX="" | ||
10 | |||
11 | ROOT_DISK="" | ||
12 | |||
13 | # Copied from initramfs-framework. The core of this script probably should be | ||
14 | # turned into initramfs-framework modules to reduce duplication. | ||
15 | udev_daemon() { | ||
16 | OPTIONS="/sbin/udev/udevd /sbin/udevd /lib/udev/udevd /lib/systemd/systemd-udevd" | ||
17 | |||
18 | for o in $OPTIONS; do | ||
19 | if [ -x "$o" ]; then | ||
20 | echo $o | ||
21 | return 0 | ||
22 | fi | ||
23 | done | ||
24 | |||
25 | return 1 | ||
26 | } | ||
27 | |||
28 | _UDEV_DAEMON=`udev_daemon` | ||
29 | |||
30 | early_setup() { | ||
31 | mkdir -p /proc | ||
32 | mkdir -p /sys | ||
33 | mount -t proc proc /proc | ||
34 | mount -t sysfs sysfs /sys | ||
35 | mount -t devtmpfs none /dev | ||
36 | |||
37 | # support modular kernel | ||
38 | modprobe isofs 2> /dev/null | ||
39 | |||
40 | mkdir -p /run | ||
41 | mkdir -p /var/run | ||
42 | |||
43 | $_UDEV_DAEMON --daemon | ||
44 | udevadm trigger --action=add | ||
45 | } | ||
46 | |||
47 | read_args() { | ||
48 | [ -z "$CMDLINE" ] && CMDLINE=`cat /proc/cmdline` | ||
49 | for arg in $CMDLINE; do | ||
50 | optarg=`expr "x$arg" : 'x[^=]*=\(.*\)'` | ||
51 | case $arg in | ||
52 | root=*) | ||
53 | ROOT_DEVICE=$optarg ;; | ||
54 | rootimage=*) | ||
55 | ROOT_IMAGE=$optarg ;; | ||
56 | rootfstype=*) | ||
57 | modprobe $optarg 2> /dev/null ;; | ||
58 | LABEL=*) | ||
59 | label=$optarg ;; | ||
60 | video=*) | ||
61 | video_mode=$arg ;; | ||
62 | vga=*) | ||
63 | vga_mode=$arg ;; | ||
64 | console=*) | ||
65 | if [ -z "${console_params}" ]; then | ||
66 | console_params=$arg | ||
67 | else | ||
68 | console_params="$console_params $arg" | ||
69 | fi ;; | ||
70 | debugshell*) | ||
71 | if [ -z "$optarg" ]; then | ||
72 | shelltimeout=30 | ||
73 | else | ||
74 | shelltimeout=$optarg | ||
75 | fi | ||
76 | esac | ||
77 | done | ||
78 | } | ||
79 | |||
80 | boot_live_root() { | ||
81 | # Watches the udev event queue, and exits if all current events are handled | ||
82 | udevadm settle --timeout=3 --quiet | ||
83 | killall "${_UDEV_DAEMON##*/}" 2>/dev/null | ||
84 | |||
85 | # Allow for identification of the real root even after boot | ||
86 | mkdir -p ${ROOT_MOUNT}/media/realroot | ||
87 | mount -n --move "/run/media/${ROOT_DISK}" ${ROOT_MOUNT}/media/realroot | ||
88 | |||
89 | # Move the mount points of some filesystems over to | ||
90 | # the corresponding directories under the real root filesystem. | ||
91 | for dir in `awk '/\/dev.* \/run\/media/{print $2}' /proc/mounts`; do | ||
92 | mkdir -p ${ROOT_MOUNT}/media/${dir##*/} | ||
93 | mount -n --move $dir ${ROOT_MOUNT}/media/${dir##*/} | ||
94 | done | ||
95 | mount -n --move /proc ${ROOT_MOUNT}/proc | ||
96 | mount -n --move /sys ${ROOT_MOUNT}/sys | ||
97 | mount -n --move /dev ${ROOT_MOUNT}/dev | ||
98 | |||
99 | cd $ROOT_MOUNT | ||
100 | |||
101 | # busybox switch_root supports -c option | ||
102 | exec switch_root -c /dev/console $ROOT_MOUNT /sbin/init $CMDLINE || | ||
103 | fatal "Couldn't switch_root, dropping to shell" | ||
104 | } | ||
105 | |||
106 | fatal() { | ||
107 | echo $1 >$CONSOLE | ||
108 | echo >$CONSOLE | ||
109 | exec sh | ||
110 | } | ||
111 | |||
112 | early_setup | ||
113 | |||
114 | [ -z "$CONSOLE" ] && CONSOLE="/dev/console" | ||
115 | |||
116 | read_args | ||
117 | |||
118 | echo "Waiting for removable media..." | ||
119 | C=0 | ||
120 | while true | ||
121 | do | ||
122 | for i in `ls /run/media 2>/dev/null`; do | ||
123 | if [ -f /run/media/$i/$ROOT_IMAGE ] ; then | ||
124 | found="yes" | ||
125 | ROOT_DISK="$i" | ||
126 | break | ||
127 | elif [ -f /run/media/$i/isolinux/$ROOT_IMAGE ]; then | ||
128 | found="yes" | ||
129 | ISOLINUX="isolinux" | ||
130 | ROOT_DISK="$i" | ||
131 | break | ||
132 | fi | ||
133 | done | ||
134 | if [ "$found" = "yes" ]; then | ||
135 | break; | ||
136 | fi | ||
137 | # don't wait for more than $shelltimeout seconds, if it's set | ||
138 | if [ -n "$shelltimeout" ]; then | ||
139 | echo -n " " $(( $shelltimeout - $C )) | ||
140 | if [ $C -ge $shelltimeout ]; then | ||
141 | echo "..." | ||
142 | echo "Mounted filesystems" | ||
143 | mount | grep media | ||
144 | echo "Available block devices" | ||
145 | cat /proc/partitions | ||
146 | fatal "Cannot find $ROOT_IMAGE file in /run/media/* , dropping to a shell " | ||
147 | fi | ||
148 | C=$(( C + 1 )) | ||
149 | fi | ||
150 | sleep 1 | ||
151 | done | ||
152 | |||
153 | # Try to mount the root image read-write and then boot it up. | ||
154 | # This function distinguishes between a read-only image and a read-write image. | ||
155 | # In the former case (typically an iso), it tries to make a union mount if possible. | ||
156 | # In the latter case, the root image could be mounted and then directly booted up. | ||
157 | mount_and_boot() { | ||
158 | mkdir $ROOT_MOUNT | ||
159 | mknod /dev/loop0 b 7 0 2>/dev/null | ||
160 | |||
161 | if ! mount -o rw,loop,noatime,nodiratime /run/media/$ROOT_DISK/$ISOLINUX/$ROOT_IMAGE $ROOT_MOUNT ; then | ||
162 | fatal "Could not mount rootfs image" | ||
163 | fi | ||
164 | |||
165 | if touch $ROOT_MOUNT/bin 2>/dev/null; then | ||
166 | # The root image is read-write, directly boot it up. | ||
167 | boot_live_root | ||
168 | fi | ||
169 | |||
170 | # determine which unification filesystem to use | ||
171 | union_fs_type="" | ||
172 | if grep -q -w "overlayfs" /proc/filesystems; then | ||
173 | union_fs_type="overlayfs" | ||
174 | elif grep -q -w "aufs" /proc/filesystems; then | ||
175 | union_fs_type="aufs" | ||
176 | else | ||
177 | union_fs_type="" | ||
178 | fi | ||
179 | |||
180 | # make a union mount if possible | ||
181 | case $union_fs_type in | ||
182 | "overlayfs") | ||
183 | mkdir -p /rootfs.ro /rootfs.rw | ||
184 | if ! mount -n --move $ROOT_MOUNT /rootfs.ro; then | ||
185 | rm -rf /rootfs.ro /rootfs.rw | ||
186 | fatal "Could not move rootfs mount point" | ||
187 | else | ||
188 | mount -t tmpfs -o rw,noatime,mode=755 tmpfs /rootfs.rw | ||
189 | mount -t overlayfs -o "lowerdir=/rootfs.ro,upperdir=/rootfs.rw" overlayfs $ROOT_MOUNT | ||
190 | mkdir -p $ROOT_MOUNT/rootfs.ro $ROOT_MOUNT/rootfs.rw | ||
191 | mount --move /rootfs.ro $ROOT_MOUNT/rootfs.ro | ||
192 | mount --move /rootfs.rw $ROOT_MOUNT/rootfs.rw | ||
193 | fi | ||
194 | ;; | ||
195 | "aufs") | ||
196 | mkdir -p /rootfs.ro /rootfs.rw | ||
197 | if ! mount -n --move $ROOT_MOUNT /rootfs.ro; then | ||
198 | rm -rf /rootfs.ro /rootfs.rw | ||
199 | fatal "Could not move rootfs mount point" | ||
200 | else | ||
201 | mount -t tmpfs -o rw,noatime,mode=755 tmpfs /rootfs.rw | ||
202 | mount -t aufs -o "dirs=/rootfs.rw=rw:/rootfs.ro=ro" aufs $ROOT_MOUNT | ||
203 | mkdir -p $ROOT_MOUNT/rootfs.ro $ROOT_MOUNT/rootfs.rw | ||
204 | mount --move /rootfs.ro $ROOT_MOUNT/rootfs.ro | ||
205 | mount --move /rootfs.rw $ROOT_MOUNT/rootfs.rw | ||
206 | fi | ||
207 | ;; | ||
208 | "") | ||
209 | mount -t tmpfs -o rw,noatime,mode=755 tmpfs $ROOT_MOUNT/media | ||
210 | ;; | ||
211 | esac | ||
212 | |||
213 | # boot the image | ||
214 | boot_live_root | ||
215 | } | ||
216 | |||
217 | case $label in | ||
218 | boot) | ||
219 | mount_and_boot | ||
220 | ;; | ||
221 | install|install-efi) | ||
222 | if [ -f /run/media/$i/$ISOLINUX/$ROOT_IMAGE ] ; then | ||
223 | ./$label.sh $i/$ISOLINUX $ROOT_IMAGE $video_mode $vga_mode $console_params | ||
224 | else | ||
225 | fatal "Could not find $label script" | ||
226 | fi | ||
227 | |||
228 | # If we're getting here, we failed... | ||
229 | fatal "Installation image failed" | ||
230 | ;; | ||
231 | *) | ||
232 | # Not sure what boot label is provided. Try to boot to avoid locking up. | ||
233 | mount_and_boot | ||
234 | ;; | ||
235 | esac | ||