OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 | 2 |
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 # Helper script that generates the signed kernel image | 7 # Helper script that generates the signed kernel image |
8 | 8 |
9 . "$(dirname "$0")/common.sh" | 9 . "$(dirname "$0")/common.sh" |
10 | 10 |
11 get_default_board | 11 get_default_board |
12 | 12 |
13 # Flags. | 13 # Flags. |
14 DEFINE_string arch "x86" \ | 14 DEFINE_string arch "x86" \ |
15 "The boot architecture: arm or x86. (Default: x86)" | 15 "The boot architecture: arm or x86. (Default: x86)" |
16 # TODO(wad) once extlinux is dead, we can remove this. | 16 # TODO(wad) once extlinux is dead, we can remove this. |
17 DEFINE_boolean install ${FLAGS_FALSE} \ | 17 DEFINE_boolean install ${FLAGS_FALSE} \ |
18 "Controls whether extlinux is run on 'to'. (Default: false)" | 18 "Controls whether extlinux is run on 'to'. (Default: false)" |
19 DEFINE_string to "/tmp/boot" \ | 19 DEFINE_string to "/tmp/boot" \ |
20 "Path to populate with bootloader templates (Default: /tmp/boot)" | 20 "Path to populate with bootloader templates (Default: /tmp/boot)" |
21 DEFINE_string usb_disk /dev/sdb3 \ | 21 DEFINE_string usb_disk /dev/sdb3 \ |
22 "Path syslinux should use to do a usb boot. Default: /dev/sdb3" | 22 "Path syslinux should use to do a usb boot. Default: /dev/sdb3" |
23 DEFINE_string boot_args "" \ | 23 DEFINE_string boot_args "" \ |
24 "Additional boot arguments to pass to the commandline (Default: '')" | 24 "Additional boot arguments to pass to the commandline (Default: '')" |
25 DEFINE_boolean use_vboot ${FLAGS_FALSE} \ | 25 DEFINE_boolean enable_rootfs_verification ${FLAGS_FALSE} \ |
26 "Controls whether the default boot targets are verified (Default: false)" | 26 "Controls if verity is used for root filesystem checking (Default: false)" |
27 DEFINE_integer vboot_error_behavior 2 \ | 27 DEFINE_integer verity_error_behavior 2 \ |
28 "Verified boot error behavior [0: I/O errors, 1: reboot, 2: nothing] \ | 28 "Verified boot error behavior [0: I/O errors, 1: reboot, 2: nothing] \ |
29 (Default: 2)" | 29 (Default: 2)" |
30 DEFINE_integer vboot_max_ios 1024 \ | 30 DEFINE_integer verity_max_ios 1024 \ |
31 "Optional number of outstanding I/O operations. (Default: 1024)" | 31 "Optional number of outstanding I/O operations. (Default: 1024)" |
32 | 32 |
33 # Parse flags | 33 # Parse flags |
34 FLAGS "$@" || exit 1 | 34 FLAGS "$@" || exit 1 |
35 eval set -- "${FLAGS_ARGV}" | 35 eval set -- "${FLAGS_ARGV}" |
36 set -e | 36 set -e |
37 | 37 |
38 # Common kernel command-line args | 38 # Common kernel command-line args |
39 common_args="quiet console=tty2 init=/sbin/init boot=local rootwait ro noresume" | 39 common_args="quiet console=tty2 init=/sbin/init boot=local rootwait ro noresume" |
40 common_args="${common_args} noswap loglevel=1" | 40 common_args="${common_args} noswap loglevel=1" |
41 | 41 |
42 # Common verified boot command-line args | 42 # Common verified boot command-line args |
43 vboot_common="dm_verity.error_behavior=${FLAGS_vboot_error_behavior}" | 43 verity_common="dm_verity.error_behavior=${FLAGS_verity_error_behavior}" |
44 vboot_common="${vboot_common} dm_verity.max_bios=${FLAGS_vboot_max_ios}" | 44 verity_common="${verity_common} dm_verity.max_bios=${FLAGS_verity_max_ios}" |
45 | 45 |
46 # Populate the x86 rootfs to support legacy and EFI bios config templates. | 46 # Populate the x86 rootfs to support legacy and EFI bios config templates. |
47 # The templates are used by the installer to populate partition 12 with | 47 # The templates are used by the installer to populate partition 12 with |
48 # the correct bootloader configuration. | 48 # the correct bootloader configuration. |
49 # While we transition to that model, extlinux.conf will still be used | 49 # While we transition to that model, extlinux.conf will still be used |
50 # on the root filesystem. | 50 # on the root filesystem. |
51 if [[ "${FLAGS_arch}" == "x86" ]]; then | 51 if [[ "${FLAGS_arch}" == "x86" ]]; then |
52 # Setup extlinux configuration. | 52 # Setup extlinux configuration. |
53 # TODO: For some reason the /dev/disk/by-uuid is not being generated by udev | 53 # TODO: For some reason the /dev/disk/by-uuid is not being generated by udev |
54 # in the initramfs. When we figure that out, switch to root=UUID=${UUID}. | 54 # in the initramfs. When we figure that out, switch to root=UUID=${UUID}. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 include /syslinux/usb.A.cfg | 91 include /syslinux/usb.A.cfg |
92 | 92 |
93 # chromeos-hd.A / chromeos-vhd.A | 93 # chromeos-hd.A / chromeos-vhd.A |
94 include /syslinux/root.A.cfg | 94 include /syslinux/root.A.cfg |
95 | 95 |
96 # chromeos-hd.B / chromeos-vhd.B | 96 # chromeos-hd.B / chromeos-vhd.B |
97 include /syslinux/root.B.cfg | 97 include /syslinux/root.B.cfg |
98 EOF | 98 EOF |
99 info "Emitted ${SYSLINUX_DIR}/syslinux.cfg" | 99 info "Emitted ${SYSLINUX_DIR}/syslinux.cfg" |
100 | 100 |
101 if [[ ${FLAGS_use_vboot} -eq ${FLAGS_TRUE} ]]; then | 101 if [[ ${FLAGS_enable_rootfs_verification} -eq ${FLAGS_TRUE} ]]; then |
102 # To change the active target, only this file needs to change. | 102 # To change the active target, only this file needs to change. |
103 cat <<EOF | sudo dd of="${SYSLINUX_DIR}/default.cfg" 2>/dev/null | 103 cat <<EOF | sudo dd of="${SYSLINUX_DIR}/default.cfg" 2>/dev/null |
104 DEFAULT chromeos-vusb.A | 104 DEFAULT chromeos-vusb.A |
105 EOF | 105 EOF |
106 else | 106 else |
107 cat <<EOF | sudo dd of="${SYSLINUX_DIR}/default.cfg" 2>/dev/null | 107 cat <<EOF | sudo dd of="${SYSLINUX_DIR}/default.cfg" 2>/dev/null |
108 DEFAULT chromeos-usb.A | 108 DEFAULT chromeos-usb.A |
109 EOF | 109 EOF |
110 fi | 110 fi |
111 info "Emitted ${SYSLINUX_DIR}/default.cfg" | 111 info "Emitted ${SYSLINUX_DIR}/default.cfg" |
112 | 112 |
113 cat <<EOF | sudo dd of="${SYSLINUX_DIR}/usb.A.cfg" 2>/dev/null | 113 cat <<EOF | sudo dd of="${SYSLINUX_DIR}/usb.A.cfg" 2>/dev/null |
114 label chromeos-usb.A | 114 label chromeos-usb.A |
115 menu label chromeos-usb.A | 115 menu label chromeos-usb.A |
116 kernel vmlinuz.A | 116 kernel vmlinuz.A |
117 append ${common_args} root=${FLAGS_usb_disk} i915.modeset=1 cros_legacy | 117 append ${common_args} root=${FLAGS_usb_disk} i915.modeset=1 cros_legacy |
118 | 118 |
119 label chromeos-vusb.A | 119 label chromeos-vusb.A |
120 menu label chromeos-vusb.A | 120 menu label chromeos-vusb.A |
121 kernel vmlinuz.A | 121 kernel vmlinuz.A |
122 append ${common_args} ${vboot_common} root=/dev/dm-0 i915.modeset=1 cros_legac
y dm="DMTABLEA" | 122 append ${common_args} ${verity_common} root=/dev/dm-0 i915.modeset=1 cros_lega
cy dm="DMTABLEA" |
123 EOF | 123 EOF |
124 info "Emitted ${SYSLINUX_DIR}/usb.A.cfg" | 124 info "Emitted ${SYSLINUX_DIR}/usb.A.cfg" |
125 | 125 |
126 # Different files are used so that the updater can only touch the file it | 126 # Different files are used so that the updater can only touch the file it |
127 # needs to for a given change. This will minimize any potential accidental | 127 # needs to for a given change. This will minimize any potential accidental |
128 # updates issues, hopefully. | 128 # updates issues, hopefully. |
129 cat <<EOF | sudo dd of="${SYSLINUX_DIR}/root.A.cfg" 2>/dev/null | 129 cat <<EOF | sudo dd of="${SYSLINUX_DIR}/root.A.cfg" 2>/dev/null |
130 label chromeos-hd.A | 130 label chromeos-hd.A |
131 menu label chromeos-hd.A | 131 menu label chromeos-hd.A |
132 kernel vmlinuz.A | 132 kernel vmlinuz.A |
133 append ${common_args} root=HDROOTA i915.modeset=1 cros_legacy | 133 append ${common_args} root=HDROOTA i915.modeset=1 cros_legacy |
134 | 134 |
135 label chromeos-vhd.A | 135 label chromeos-vhd.A |
136 menu label chromeos-vhd.A | 136 menu label chromeos-vhd.A |
137 kernel vmlinuz.A | 137 kernel vmlinuz.A |
138 append ${common_args} ${vboot_common} root=/dev/dm-0 i915.modeset=1 cros_legac
y dm="DMTABLEA" | 138 append ${common_args} ${verity_common} root=/dev/dm-0 i915.modeset=1 cros_lega
cy dm="DMTABLEA" |
139 EOF | 139 EOF |
140 info "Emitted ${SYSLINUX_DIR}/root.A.cfg" | 140 info "Emitted ${SYSLINUX_DIR}/root.A.cfg" |
141 | 141 |
142 cat <<EOF | sudo dd of="${SYSLINUX_DIR}/root.B.cfg" 2>/dev/null | 142 cat <<EOF | sudo dd of="${SYSLINUX_DIR}/root.B.cfg" 2>/dev/null |
143 label chromeos-hd.B | 143 label chromeos-hd.B |
144 menu label chromeos-hd.B | 144 menu label chromeos-hd.B |
145 kernel vmlinuz.B | 145 kernel vmlinuz.B |
146 append ${common_args} root=HDROOTB i915.modeset=1 cros_legacy | 146 append ${common_args} root=HDROOTB i915.modeset=1 cros_legacy |
147 | 147 |
148 label chromeos-vhd.B | 148 label chromeos-vhd.B |
149 menu label chromeos-vhd.B | 149 menu label chromeos-vhd.B |
150 kernel vmlinuz.B | 150 kernel vmlinuz.B |
151 append ${common_args} ${vboot_common} root=/dev/dm-0 i915.modeset=1 cros_legac
y dm="DMTABLEB" | 151 append ${common_args} ${verity_common} root=/dev/dm-0 i915.modeset=1 cros_lega
cy dm="DMTABLEB" |
152 EOF | 152 EOF |
153 info "Emitted ${SYSLINUX_DIR}/root.B.cfg" | 153 info "Emitted ${SYSLINUX_DIR}/root.B.cfg" |
154 | 154 |
155 cat <<EOF | sudo dd of="${SYSLINUX_DIR}/README" 2>/dev/null | 155 cat <<EOF | sudo dd of="${SYSLINUX_DIR}/README" 2>/dev/null |
156 Partition 12 contains the active bootloader configuration when | 156 Partition 12 contains the active bootloader configuration when |
157 booting from a non-Chrome OS BIOS. EFI BIOSes use /efi/* | 157 booting from a non-Chrome OS BIOS. EFI BIOSes use /efi/* |
158 and legacy BIOSes use this syslinux configuration. | 158 and legacy BIOSes use this syslinux configuration. |
159 EOF | 159 EOF |
160 info "Emitted ${SYSLINUX_DIR}/README" | 160 info "Emitted ${SYSLINUX_DIR}/README" |
161 | 161 |
(...skipping 12 matching lines...) Expand all Loading... |
174 | 174 |
175 menuentry "local image A" { | 175 menuentry "local image A" { |
176 linux \$grubpartA/boot/vmlinuz ${common_args} i915.modeset=1 cros_efi root=/de
v/\$linuxpartA | 176 linux \$grubpartA/boot/vmlinuz ${common_args} i915.modeset=1 cros_efi root=/de
v/\$linuxpartA |
177 } | 177 } |
178 | 178 |
179 menuentry "local image B" { | 179 menuentry "local image B" { |
180 linux \$grubpartB/boot/vmlinuz ${common_args} i915.modeset=1 cros_efi root=/de
v/\$linuxpartB | 180 linux \$grubpartB/boot/vmlinuz ${common_args} i915.modeset=1 cros_efi root=/de
v/\$linuxpartB |
181 } | 181 } |
182 | 182 |
183 menuentry "verified image A" { | 183 menuentry "verified image A" { |
184 linux \$grubpartA/boot/vmlinuz ${common_args} ${vboot_common} i915.modeset=1 c
ros_efi root=/dev/dm-0 dm="DMTABLEA" | 184 linux \$grubpartA/boot/vmlinuz ${common_args} ${verity_common} i915.modeset=1
cros_efi root=/dev/dm-0 dm="DMTABLEA" |
185 } | 185 } |
186 | 186 |
187 menuentry "verified image B" { | 187 menuentry "verified image B" { |
188 linux \$grubpartB/boot/vmlinuz ${common_args} ${vboot_common} i915.modeset=1 c
ros_efi root=/dev/dm-0 dm="DMTABLEB" | 188 linux \$grubpartB/boot/vmlinuz ${common_args} ${verity_common} i915.modeset=1
cros_efi root=/dev/dm-0 dm="DMTABLEB" |
189 } | 189 } |
190 | 190 |
191 # FIXME: usb doesn't support verified boot for now | 191 # FIXME: usb doesn't support verified boot for now |
192 menuentry "Alternate USB Boot" { | 192 menuentry "Alternate USB Boot" { |
193 linux (hd0,3)/boot/vmlinuz ${common_args} root=/dev/sdb3 i915.modeset=1 cros_e
fi | 193 linux (hd0,3)/boot/vmlinuz ${common_args} root=/dev/sdb3 i915.modeset=1 cros_e
fi |
194 } | 194 } |
195 EOF | 195 EOF |
196 if [[ ${FLAGS_use_vboot} -eq ${FLAGS_TRUE} ]]; then | 196 if [[ ${FLAGS_enable_rootfs_verification} -eq ${FLAGS_TRUE} ]]; then |
197 sudo sed -i -e 's/^set default=.*/set default=2/' \ | 197 sudo sed -i -e 's/^set default=.*/set default=2/' \ |
198 "${FLAGS_to}/efi/boot/grub.cfg" | 198 "${FLAGS_to}/efi/boot/grub.cfg" |
199 fi | 199 fi |
200 info "Emitted ${FLAGS_to}/efi/boot/grub.cfg" | 200 info "Emitted ${FLAGS_to}/efi/boot/grub.cfg" |
201 exit 0 | 201 exit 0 |
202 fi | 202 fi |
203 | 203 |
204 info "The target platform does not use bootloader templates." | 204 info "The target platform does not use bootloader templates." |
OLD | NEW |