Skip to content

Commit 0cce802

Browse files
committed
Merge branch 'dev'
2 parents 6fe2192 + 8ec9131 commit 0cce802

File tree

11 files changed

+106
-32
lines changed

11 files changed

+106
-32
lines changed

.github/workflows/build-image.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99

1010
strategy:
1111
matrix:
12-
board: [dedede, octopus, coral, grunt, nissa, zork, corsola, jacuzzi]
12+
board: [dedede, octopus, coral, grunt, nissa, zork, corsola, jacuzzi, hatch]
1313

1414
runs-on: ubuntu-latest
1515
steps:

README.md

+18-13
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,21 @@ Note that rootfs partitions have to be named `shimboot_rootfs:<partname>` for th
5656
Driver support depends on the device you are using shimboot on. The `patch_rootfs.sh` script attempts to copy all the firmware and drivers from the shim and recovery image into the rootfs, so expect most things to work on other boards. ARM Chromebooks are not supported at the moment.
5757

5858
### Device Compatibility Table:
59-
| Board Name | X11 | Wifi | Speakers | Backlight | Touchscreen | 3D Accel | Bluetooth | Webcam |
60-
|------------------------------------------------ |-------------------|------|----------|-----------|-------------|----------|-----------|----------|
61-
| [`dedede`](https://chrome100.dev/board/dedede) | yes | yes | no | yes | yes | yes | yes | yes |
62-
| [`octopus`](https://chrome100.dev/board/octopus) | yes | yes | yes | yes | yes | yes | yes | yes |
63-
| [`nissa`](https://chrome100.dev/board/nissa) | yes | yes | no | yes | yes | yes | yes | yes |
64-
| [`reks`](https://chrome100.dev/board/reks) | no<sup>[1]</sup> | yes | untested | untested | untested | no | untested | untested |
65-
| [`kefka`](https://chrome100.dev/board/kefka) | no<sup>[1]</sup> | yes | yes | yes | untested | no | untested | untested |
66-
| [`zork`](https://chrome100.dev/board/zork) | yes | yes | no | untested | yes | yes | yes | yes |
67-
| [`grunt`](https://chrome100.dev/board/grunt) | yes | yes | no | yes | yes | yes | yes | yes |
68-
| [`jacuzzi`](https://chrome100.dev/board/jacuzzi) | yes | yes | no | yes | untested | no | no | yes |
69-
| [`corsola`](https://chrome100.dev/board/corsola) | yes | yes | untested | untested | untested | untested | untested | untested |
70-
71-
<sup>1. The kernel is too old.</sup>
59+
| Board Name | X11 | Wifi | Speakers | Backlight | Touchscreen | 3D Accel | Bluetooth | Webcam |
60+
|------------------------------------------------ |-------------------|-------------------|----------|-----------|-------------|----------|-----------|----------|
61+
| [`dedede`](https://chrome100.dev/board/dedede) | yes | yes | no | yes | yes | yes | yes | yes |
62+
| [`octopus`](https://chrome100.dev/board/octopus) | yes | yes | yes | yes | yes | yes | yes | yes |
63+
| [`nissa`](https://chrome100.dev/board/nissa) | yes | yes | no | yes | yes | yes | yes | yes |
64+
| [`reks`](https://chrome100.dev/board/reks) | no<sup>[1]</sup> | yes | untested | untested | untested | no | untested | untested |
65+
| [`kefka`](https://chrome100.dev/board/kefka) | no<sup>[1]</sup> | yes | yes | yes | untested | no | untested | untested |
66+
| [`zork`](https://chrome100.dev/board/zork) | yes | yes | no | untested | yes | yes | yes | yes |
67+
| [`grunt`](https://chrome100.dev/board/grunt) | yes | yes | no | yes | yes | yes | yes | yes |
68+
| [`jacuzzi`](https://chrome100.dev/board/jacuzzi) | yes | yes | no | yes | untested | no | no | yes |
69+
| [`corsola`](https://chrome100.dev/board/corsola) | yes | yes | untested | untested | untested | untested | untested | untested |
70+
| [`hatch`](https://chrome100.dev/board/hatch) | yes | yes<sup>[2]</sup> | no | yes | yes | yes | yes | yes |
71+
72+
<sup>1. The kernel is too old.</sup><br>
73+
<sup>2. 5ghz wifi networks do not work, but 2.4ghz networks do.</sup>
7274

7375
This table is incomplete. If you want to contribute a device compatibility report please create a new issue on the Github repository.
7476

@@ -214,6 +216,9 @@ Steam should be installed using the `sudo apt install steam` command, however it
214216

215217
To get Steam running, install and run it normally. It will fail and show a message saying that "Steam now requires user namespaces to be enabled." Run `fix_bwrap` in your terminal, relaunch Steam, and it should be working again.
216218

219+
#### I broke something and the system does not boot anymore.
220+
If the rootfs fails to boot normally, you may use the rescue mode in the bootloader to enter a shell so you can debug and fix things. You can enter this mode by typing in `rescue <selection>` in the bootloader prompt, replacing `<selection>` with the number that is displayed for your rootfs. For example, `rescue 3` will enter rescue mode for the third boot option (usually Debian).
221+
217222
## Copyright:
218223
Shimboot is licensed under the [GNU GPL v3](https://www.gnu.org/licenses/gpl-3.0.txt). Unless otherwise indicated, all code has been written by me, [ading2210](https://github.com/ading2210).
219224

bootloader/bin/bootstrap.sh

+37-9
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#set -x
1313
set +x
1414

15-
SHIMBOOT_VERSION="v1.2.0"
15+
rescue_mode=""
1616

1717
invoke_terminal() {
1818
local tty="$1"
@@ -95,11 +95,13 @@ move_mounts() {
9595
}
9696

9797
print_license() {
98+
local shimboot_version="$(cat /opt/.shimboot_version)"
9899
if [ -f "/opt/.shimboot_version_dev" ]; then
99-
suffix="-dev"
100+
local git_hash="$(cat /opt/.shimboot_version_dev)"
101+
local suffix="-dev-$git_hash"
100102
fi
101103
cat << EOF
102-
Shimboot ${SHIMBOOT_VERSION}${suffix}
104+
Shimboot ${shimboot_version}${suffix}
103105
104106
ading2210/shimboot: Boot desktop Linux from a Chrome OS RMA shim.
105107
Copyright (C) 2023 ading2210
@@ -164,6 +166,14 @@ get_selection() {
164166
return 1
165167
fi
166168

169+
local selection_cmd="$(echo "$selection" | cut -d' ' -f1)"
170+
if [ "$selection_cmd" = "rescue" ]; then
171+
selection="$(echo "$selection" | cut -d' ' -f2-)"
172+
rescue_mode="1"
173+
else
174+
rescue_mode=""
175+
fi
176+
167177
for rootfs_partition in $rootfs_partitions; do
168178
local part_path=$(echo $rootfs_partition | cut -d ":" -f 1)
169179
local part_name=$(echo $rootfs_partition | cut -d ":" -f 2)
@@ -176,7 +186,7 @@ get_selection() {
176186
print_donor_selector "$rootfs_partitions"
177187
get_donor_selection "$rootfs_partitions" "$part_path"
178188
else
179-
boot_target $part_path
189+
boot_target "$part_path"
180190
fi
181191
return 1
182192
fi
@@ -253,7 +263,7 @@ get_donor_selection() {
253263
echo "selected $part_path as the donor partition"
254264
yes_no_prompt "would you like to spoof verified mode? this is useful if you're planning on using chrome os while enrolled. (y/n): " use_crossystem
255265
yes_no_prompt "would you like to spoof an invalid hwid? this will forcibly prevent the device from being enrolled. (y/n): " invalid_hwid
256-
boot_chromeos $target $part_path $use_crossystem $invalid_hwid
266+
boot_chromeos "$target" "$part_path" "$use_crossystem" "$invalid_hwid"
257267
fi
258268

259269
i=$((i+1))
@@ -264,6 +274,21 @@ get_donor_selection() {
264274
return 1
265275
}
266276

277+
exec_init() {
278+
if [ "$rescue_mode" = "1" ]; then
279+
echo "entering a rescue shell instead of starting init"
280+
echo "once you are done fixing whatever is broken, run 'exec /sbin/init' to continue booting the system normally"
281+
282+
if [ -f "/bin/bash" ]; then
283+
exec /bin/bash < "$TTY1" >> "$TTY1" 2>&1
284+
else
285+
exec /bin/sh < "$TTY1" >> "$TTY1" 2>&1
286+
fi
287+
else
288+
exec /sbin/init < "$TTY1" >> "$TTY1" 2>&1
289+
fi
290+
}
291+
267292
boot_target() {
268293
local target="$1"
269294

@@ -281,15 +306,15 @@ boot_target() {
281306
echo "switching root"
282307
mkdir -p /newroot/bootloader
283308
pivot_root /newroot /newroot/bootloader
284-
exec /sbin/init < "$TTY1" >> "$TTY1" 2>&1
309+
exec_init
285310
}
286311

287312
boot_chromeos() {
288313
local target="$1"
289314
local donor="$2"
290315
local use_crossystem="$3"
291316
local invalid_hwid="$4"
292-
317+
293318
echo "mounting target"
294319
mkdir /newroot
295320
mount -o ro $target /newroot
@@ -325,10 +350,14 @@ boot_chromeos() {
325350
echo "patching chrome os rootfs"
326351
cat /newroot/etc/ui_use_flags.txt | sed "/reven_branding/d" | sed "/os_install_service/d" > /newroot/tmp/ui_use_flags.txt
327352
mount -o bind /newroot/tmp/ui_use_flags.txt /newroot/etc/ui_use_flags.txt
353+
328354
cp /opt/mount-encrypted /newroot/tmp/mount-encrypted
329355
cp /newroot/usr/sbin/mount-encrypted /newroot/tmp/mount-encrypted.real
330356
mount -o bind /newroot/tmp/mount-encrypted /newroot/usr/sbin/mount-encrypted
331357

358+
cat /newroot/etc/init/boot-splash.conf | sed '/^script$/a \ pkill frecon-lite || true' > /newroot/tmp/boot-splash.conf
359+
mount -o bind /newroot/tmp/boot-splash.conf /newroot/etc/init/boot-splash.conf
360+
332361
if [ "$use_crossystem" = "y" ]; then
333362
echo "patching crossystem"
334363
cp /opt/crossystem /newroot/tmp/crossystem
@@ -349,8 +378,7 @@ boot_chromeos() {
349378

350379
echo "starting init"
351380
/sbin/modprobe zram
352-
pkill frecon-lite
353-
exec /sbin/init < "$TTY1" >> "$TTY1" 2>&1
381+
exec_init
354382
}
355383

356384
main() {

bootloader/opt/.shimboot_version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v1.2.1

build_complete.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ distro="${args['distro']-debian}"
3737
arm_boards="
3838
corsola hana jacuzzi kukui strongbad nyan-big kevin bob
3939
veyron-speedy veyron-jerry veyron-minnie scarlet elm
40-
kukui peach-pi peach-pit stumpy daisy-spring
40+
kukui peach-pi peach-pit stumpy daisy-spring trogdor
4141
"
4242
#a list of shims that have a patch for the sh1mmer vulnerability
4343
bad_boards="reef sand snappy pyro"

build_rootfs.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ else
104104
fi
105105

106106
print_info "copying rootfs setup scripts"
107-
cp -ar rootfs/* "$rootfs_dir"
107+
cp -arv rootfs/* "$rootfs_dir"
108108
cp /etc/resolv.conf "$rootfs_dir/etc/resolv.conf"
109109

110110
print_info "creating bind mounts for chroot"

image_utils.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ populate_partitions() {
104104

105105
#figure out if we are on a stable release
106106
local git_tag="$(git tag -l --contains HEAD)"
107+
local git_hash="$(git rev-parse --short HEAD)"
107108

108109
#mount and write empty file to stateful
109110
local stateful_mount=/tmp/shim_stateful
@@ -116,9 +117,9 @@ populate_partitions() {
116117
#mount and write to bootloader rootfs
117118
local bootloader_mount="/tmp/shim_bootloader"
118119
safe_mount "${image_loop}p3" "$bootloader_mount"
119-
cp -r $bootloader_dir/* "$bootloader_mount"
120+
cp -arv $bootloader_dir/* "$bootloader_mount"
120121
if [ ! "$git_tag" ]; then #mark it as a dev version if needed
121-
touch "$bootloader_mount/opt/.shimboot_version_dev"
122+
printf "$git_hash" > "$bootloader_mount/opt/.shimboot_version_dev"
122123
fi
123124
umount "$bootloader_mount"
124125

rootfs/etc/modules-load.d/wifi.conf

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
iwlmvm
2-
ccm
2+
ccm
3+
8021q

rootfs/opt/setup_rootfs.sh

+8-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Pin-Priority: 1000
6969
fi
7070

7171
#install the patched systemd
72-
apt-get upgrade -y
72+
apt-get upgrade -y --allow-downgrades
7373
installed_systemd="$(dpkg-query -W -f='${binary:Package}\n' | grep "systemd")"
7474
apt-get clean
7575
apt-get install -y --reinstall --allow-downgrades $installed_systemd
@@ -111,6 +111,9 @@ END
111111
#install desktop and other custom packages
112112
apt-get install -y $packages
113113

114+
#disable selinux to prevent a harmless error from showing up during the boot
115+
echo "SELINUX=disabled" | tee -a /etc/selinux/config
116+
114117
if [ ! $username ]; then
115118
read -p "Enter the username for the user account: " username
116119
fi
@@ -139,4 +142,7 @@ echo "Enter a user password:"
139142
set_password "$username" "$user_passwd"
140143

141144
#clean apt caches
142-
apt-get clean
145+
apt-get clean
146+
147+
#enable bash greeter
148+
echo "/usr/local/bin/shimboot_greeter" >> "/home/$username/.bashrc"

rootfs/usr/local/bin/expand_rootfs

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ part_name="$(echo "$part_dev" | rev | cut -d'/' -f1 | rev)"
1515
part_num="$(cat /proc/partitions | grep "$part_name" | awk '{print $2}')"
1616

1717
echo "Automatically detected root filesystem:"
18-
echo "Disk: $disk_dev"
19-
echo "Partition: $part_dev"
18+
fdisk -l "$disk_dev" 2>/dev/null | grep "${disk_dev}:" -A 1
19+
echo
20+
echo "Automatically detected root partition:"
21+
fdisk -l "$disk_dev" 2>/dev/null | grep "${part_dev}"
2022
echo
2123
read -p "Press enter to continue, or ctr+c to cancel. "
2224

rootfs/usr/local/bin/shimboot_greeter

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
#get shimboot version
4+
if [ -f "/bootloader/opt/.shimboot_version" ]; then
5+
shimboot_version="$(cat /bootloader/opt/.shimboot_version)"
6+
if [ -f "/bootloader/opt/.shimboot_version_dev" ]; then
7+
shimboot_version+="-dev-$(cat /bootloader/opt/.shimboot_version_dev)"
8+
fi
9+
fi
10+
11+
#get storage stats
12+
percent_full="$(df -BM / | tail -n1 | awk '{print $5}' | tr -d '%')"
13+
total_size="$(df -BM / | tail -n1 | awk '{print $2}' | tr -d 'M')"
14+
15+
#print the greeter
16+
if [ "$shimboot_version" ]; then
17+
echo "Welcome to the Shimboot Linux shell. (${shimboot_version})"
18+
else
19+
echo "Welcome to the Shimboot Linux shell."
20+
fi
21+
echo "For documentation and to report bugs, please visit the project's Github page:"
22+
echo " - https://github.com/ading2210/shimboot"
23+
24+
#a rootfs under 7GB should mean that it is not yet expanded
25+
if [ "$percent_full" -gt 80 ] && [ "$total_size" -lt 7000 ]; then
26+
echo
27+
echo "Warning: Your storage is nearly full and you have not yet expanded the root filesystem. Run 'sudo expand_rootfs' to fix this."
28+
fi
29+
30+
echo

0 commit comments

Comments
 (0)