Skip to content

Commit 6fe2192

Browse files
committed
Merge branch 'dev'
2 parents e9f4759 + 62d9244 commit 6fe2192

13 files changed

Lines changed: 434 additions & 63 deletions

File tree

README.md

Lines changed: 55 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,24 @@ Shimboot is a collection of scripts for patching a Chrome OS RMA shim to serve a
66
| ----- | ----- |
77
| Shimboot (KDE) on an HP Chromebook 11 G9 EE | Shimboot (XFCE) on an Acer Chromebook 311 C722 |
88

9+
## Table of Contents:
10+
- [Features](#features)
11+
- [About](#about)
12+
* [Partition Layout](#partition-layout)
13+
- [Status](#status)
14+
* [Device Compatibility Table](#device-compatibility-table)
15+
* [TODO](#todo)
16+
- [Usage](#usage)
17+
* [Prerequisites](#prerequisites)
18+
* [Video Tutorial](#video-tutorial)
19+
* [Build Instructions](#build-instructions)
20+
* [Booting the Image](#booting-the-image)
21+
- [FAQ](#faq)
22+
- [Copyright](#copyright)
23+
* [Copyright Notice](#copyright-notice)
24+
25+
<small><i>Table of contents generated with <a href='http://ecotrust-canada.github.io/markdown-toc/'>markdown-toc</a></i>.</small>
26+
927
## Features:
1028
- Run a full Debian installation on a Chromebook
1129
- Does not modify the firmware
@@ -95,36 +113,51 @@ PRs and contributions are welcome to help implement these features.
95113

96114
Note: If you are building for an ARM Chromebook, you need the `qemu-user-static` and `binfmt-support` packages.
97115

98-
#### Alternatively, you can run each of the steps manually:
99-
1. Grab a Chrome OS RMA Shim from somewhere. Most of them have already been leaked and aren't too difficult to find.
100-
2. Download a Chrome OS [recovery image](https://chromiumdash.appspot.com/serving-builds?deviceCategory=ChromeOS) for your board.
101-
3. Unzip the shim and the recovery image if you have not done so already.
102-
4. Run `mkdir -p data/rootfs` to create a directory to hold the rootfs.
103-
5. Run `sudo ./build_rootfs.sh data/rootfs bookworm` to build the base rootfs.
104-
6. Run `sudo ./patch_rootfs.sh path_to_shim path_to_reco data/rootfs` to patch the base rootfs and add any needed drivers.
105-
7. Run `sudo ./build.sh image.bin path_to_shim data/rootfs` to generate a disk image at `image.bin`.
106-
107116
[Prebuilt images](https://github.com/ading2210/shimboot/releases) are available if you don't have a suitable device to run the build on.
108117

118+
<details>
119+
<summary><b>Alternatively, you can run each of the steps manually:</b></summary>
120+
121+
1. Grab a Chrome OS RMA Shim from somewhere. Most of them have already been leaked and aren't too difficult to find.
122+
2. Download a Chrome OS [recovery image](https://chromiumdash.appspot.com/serving-builds?deviceCategory=ChromeOS) for your board.
123+
3. Unzip the shim and the recovery image if you have not done so already.
124+
4. Run `mkdir -p data/rootfs` to create a directory to hold the rootfs.
125+
5. Run `sudo ./build_rootfs.sh data/rootfs bookworm` to build the base rootfs.
126+
6. Run `sudo ./patch_rootfs.sh path_to_shim path_to_reco data/rootfs` to patch the base rootfs and add any needed drivers.
127+
7. Run `sudo ./build.sh image.bin path_to_shim data/rootfs` to generate a disk image at `image.bin`.
128+
</details>
129+
109130
### Booting the Image:
110131
1. Obtain a shimboot image by downloading a [prebuilt one](https://github.com/ading2210/shimboot/releases) or building it yourself.
111132
2. Flash the shimboot image to a USB drive or SD card. Use the [Chromebook Recovery Utility](https://chrome.google.com/webstore/detail/chromebook-recovery-utili/pocpnlppkickgojjlmhdmidojbmbodfm) or [dd](https://linux.die.net/man/1/dd) if you're on Linux.
112133
3. Enable developer mode on your Chromebook. If the Chromebook is enrolled, follow the instructions on the [sh1mmer website](https://sh1mmer.me) (see the "Executing on Chromebook" section).
113134
4. Plug the USB into your Chromebook and enter recovery mode. It should detect the USB and run the shimboot bootloader.
114135
5. Boot into Debian and log in with the username and password that you configured earlier. The default username/password for the prebuilt images is `user/user`.
115-
6. Expand the rootfs partition so that it fills up the entire disk by running `sudo growpart /dev/sdX 4` (replacing `sdX` with the block device corresponding to your disk) to expand the partition, then running `sudo resize2fs /dev/sdX4` to expand the filesystem.
116-
7. Change the user password by running `passwd user`. The root user is disabled by default.
136+
6. Expand the rootfs partition so that it fills up the entire disk by running `sudo expand_rootfs`.
137+
7. Change your own password by running `passwd user`. The root user is disabled by default.
117138

118139
## FAQ:
119140

120141
#### I want to use a different Linux distribution. How can I do that?
121142
Using any Linux distro is possible, provided that you apply the [proper patches](https://github.com/ading2210/chromeos-systemd) to systemd and recompile it. Most distros have some sort of bootstrapping tool that allows you to install it to a directory on your host PC. Then, you can just pass that rootfs directory into `patch_rootfs.sh` and `build.sh`.
122143

144+
Here is a list of distros that are supported out of the box:
145+
- Debian 12
146+
- Debian Unstable
147+
- Alpine Linux
148+
149+
PRs to enable support for other distros are welcome.
150+
123151
Debian Sid (the rolling release version of Debian) is also supported if you just want newer packages, and you can install it by passing an argument to `build_complete.sh`:
124152
```bash
125153
sudo ./build_complete.sh dedede release=unstable
126154
```
127155

156+
There is also experimental support for Alpine Linux. The Alpine disk image is about half the size compared to Debian, although some applications are missing. Pass the `distro=alpine` to use it:
157+
```bash
158+
sudo ./build_complete.sh dedede distro=alpine
159+
```
160+
128161
#### How can I install a desktop environment other than XFCE?
129162
You can pass the `desktop` argument to the `build_complete.sh` script, like this:
130163
```bash
@@ -138,10 +171,12 @@ Shimboot does not touch the internal storage at all, so you will be able to use
138171
#### Can I unplug the USB drive while using Debian?
139172
By default, this is not possible. However, you can simply copy your Debian rootfs onto your internal storage by first using `fdisk` to repartition it, using `dd` to copy the partition, and `resize2fs` to have it take up the entire drive. In the future, loading the OS to RAM may be supported, but this isn't a priority at the moment. You can also just blindly copy the contents of your Shimboot USB to the internal storage without bothering to repartition:
140173
```bash
141-
#assuming the usb drive is on sda and internal storage is on mmcblk1
142-
sudo dd if=/dev/sda of=/dev/mmcblk1 bs=1M oflag=direct status=progress
143-
sudo growpart /dev/mmcblk1 4
144-
sudo resize2fs /dev/mmcblk1p4
174+
#check the output of this to know what disk you're copying to and from
175+
fdisk -l
176+
177+
#run this from within the shimboot bootloader
178+
#this assumes the usb drive is on sda and internal storage is on mmcblk1
179+
dd if=/dev/sda of=/dev/mmcblk1 bs=1M oflag=direct status=progress
145180
```
146181

147182
#### GPU acceleration isn't working, how can I fix this?
@@ -174,6 +209,11 @@ $ nmcli connection edit <your connection name>
174209
> activate
175210
```
176211

212+
#### Steam doesn't work.
213+
Steam should be installed using the `sudo apt install steam` command, however it doesn't work out of the box due to security features in the shim kernel preventing the `bwrap` library from working. See [issue #12](https://github.com/ading2210/shimboot/issues/26#issuecomment-2151893062) for more info.
214+
215+
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.
216+
177217
## Copyright:
178218
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).
179219

bootloader/bin/bootstrap.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#set -x
1313
set +x
1414

15+
SHIMBOOT_VERSION="v1.2.0"
16+
1517
invoke_terminal() {
1618
local tty="$1"
1719
local title="$2"
@@ -93,8 +95,11 @@ move_mounts() {
9395
}
9496

9597
print_license() {
98+
if [ -f "/opt/.shimboot_version_dev" ]; then
99+
suffix="-dev"
100+
fi
96101
cat << EOF
97-
Shimboot v1.1.1
102+
Shimboot ${SHIMBOOT_VERSION}${suffix}
98103
99104
ading2210/shimboot: Boot desktop Linux from a Chrome OS RMA shim.
100105
Copyright (C) 2023 ading2210
@@ -265,6 +270,12 @@ boot_target() {
265270
echo "moving mounts to newroot"
266271
mkdir /newroot
267272
mount $target /newroot
273+
#bind mount /dev/console to show systemd boot msgs
274+
if [ -f "/bin/frecon-lite" ]; then
275+
rm -f /dev/console
276+
touch /dev/console #this has to be a regular file otherwise the system crashes afterwards
277+
mount -o bind "$TTY1" /dev/console
278+
fi
268279
move_mounts /newroot
269280

270281
echo "switching root"

build.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ print_help() {
1111
echo "Valid named arguments (specify with 'key=value'):"
1212
echo " quiet - Don't use progress indicators which may clog up log files."
1313
echo " arch - Set this to 'arm64' to specify that the shim is for an ARM chromebook."
14+
echo " name - The name for the shimboot rootfs partition."
1415
}
1516

1617
assert_root
@@ -22,11 +23,15 @@ output_path=$(realpath -m "${1}")
2223
shim_path=$(realpath -m "${2}")
2324
rootfs_dir=$(realpath -m "${3}")
2425

26+
quiet="${args['quiet']}"
27+
arch="${args['arch']}"
28+
name="${args['name']}"
29+
2530
print_info "reading the shim image"
2631
initramfs_dir=/tmp/shim_initramfs
2732
kernel_img=/tmp/kernel.img
2833
rm -rf $initramfs_dir $kernel_img
29-
extract_initramfs_full $shim_path $initramfs_dir $kernel_img "${args['arch']}"
34+
extract_initramfs_full $shim_path $initramfs_dir $kernel_img "$arch"
3035

3136
print_info "patching initramfs"
3237
patch_initramfs $initramfs_dir
@@ -36,7 +41,7 @@ rootfs_size=$(du -sm $rootfs_dir | cut -f 1)
3641
rootfs_part_size=$(($rootfs_size * 12 / 10 + 5))
3742
#create a 20mb bootloader partition
3843
#rootfs partition is 20% larger than its contents
39-
create_image $output_path 20 $rootfs_part_size
44+
create_image $output_path 20 $rootfs_part_size $name
4045

4146
print_info "creating loop device for the image"
4247
image_loop=$(create_loop ${output_path})
@@ -45,7 +50,7 @@ print_info "creating partitions on the disk image"
4550
create_partitions $image_loop $kernel_img
4651

4752
print_info "copying data into the image"
48-
populate_partitions $image_loop $initramfs_dir $rootfs_dir "${args['quiet']}"
53+
populate_partitions $image_loop $initramfs_dir $rootfs_dir "$quiet"
4954
rm -rf $initramfs_dir $kernel_img
5055

5156
print_info "cleaning up loop devices"

build_complete.sh

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ print_help() {
1414
echo " data_dir - The working directory for the scripts. This defaults to ./data"
1515
echo " arch - The CPU architecture to build the shimboot image for. Set this to 'arm64' if you have an ARM Chromebook."
1616
echo " release - Set this to either 'bookworm' or 'unstable' to build for Debian stable/unstable."
17+
echo " distro - The Linux distro to use. This should be either 'debian', 'ubuntu', or 'alpine'."
1718
}
1819

1920
assert_root
@@ -29,7 +30,8 @@ quiet="${args['quiet']}"
2930
desktop="${args['desktop']-'xfce'}"
3031
data_dir="${args['data_dir']}"
3132
arch="${args['arch']-amd64}"
32-
release="${args['release']-bookworm}"
33+
release="${args['release']}"
34+
distro="${args['distro']-debian}"
3335

3436
#a list of all arm board names
3537
arm_boards="
@@ -102,7 +104,12 @@ reco_url="$(wget -qO- --show-progress $boards_url | python3 -c '
102104
import json, sys
103105
104106
all_builds = json.load(sys.stdin)
105-
board = all_builds["builds"][sys.argv[1]]
107+
board_name = sys.argv[1]
108+
if not board_name in all_builds["builds"]:
109+
print("Invalid board name: " + board_name, file=sys.stderr)
110+
sys.exit(1)
111+
112+
board = all_builds["builds"][board_name]
106113
if "models" in board:
107114
for device in board["models"].values():
108115
if device["pushRecoveries"]:
@@ -159,22 +166,46 @@ download_and_unzip $reco_url $reco_zip $reco_bin
159166
print_title "downloading shim image"
160167
download_and_unzip $shim_url $shim_zip $shim_bin
161168

169+
print_title "building $distro rootfs"
162170
if [ ! "$rootfs_dir" ]; then
163-
rootfs_dir="$(realpath -m data/rootfs_$board)"
164171
desktop_package="task-$desktop-desktop"
172+
rootfs_dir="$(realpath -m data/rootfs_$board)"
165173
if [ "$(findmnt -T "$rootfs_dir/dev")" ]; then
166174
sudo umount -l $rootfs_dir/* 2>/dev/null || true
167175
fi
168176
rm -rf $rootfs_dir
169177
mkdir -p $rootfs_dir
170178

171-
print_title "building debian rootfs"
179+
if [ "$distro" = "debian" ]; then
180+
release="${release:-bookworm}"
181+
elif [ "$distro" = "ubuntu" ]; then
182+
release="${release:-noble}"
183+
elif [ "$distro" = "alpine" ]; then
184+
release="${release:-edge}"
185+
else
186+
print_error "invalid distro selection"
187+
exit 1
188+
fi
189+
190+
#install a newer debootstrap version if needed
191+
if [ -f "/etc/debian_version" ] && [ "$distro" = "ubuntu" -o "$distro" = "debian" ]; then
192+
if [ ! -f "/usr/share/debootstrap/scripts/$release" ]; then
193+
print_info "installing newer debootstrap version"
194+
mirror_url="https://deb.debian.org/debian/pool/main/d/debootstrap/"
195+
deb_file="$(curl "https://deb.debian.org/debian/pool/main/d/debootstrap/" | pcregrep -o1 'href="(debootstrap_.+?\.deb)"' | tail -n1)"
196+
deb_url="${mirror_url}${deb_file}"
197+
wget -q --show-progress "$deb_url" -O "/tmp/$deb_file"
198+
apt-get install -y "/tmp/$deb_file"
199+
fi
200+
fi
201+
172202
./build_rootfs.sh $rootfs_dir $release \
173203
custom_packages=$desktop_package \
174204
hostname=shimboot-$board \
175205
username=user \
176206
user_passwd=user \
177-
arch=$arch
207+
arch=$arch \
208+
distro=$distro
178209
fi
179210

180211
print_title "patching debian rootfs"
@@ -183,7 +214,7 @@ retry_cmd ./patch_rootfs.sh $shim_bin $reco_bin $rootfs_dir "quiet=$quiet"
183214
print_title "building final disk image"
184215
final_image="$data_dir/shimboot_$board.bin"
185216
rm -rf $final_image
186-
retry_cmd ./build.sh $final_image $shim_bin $rootfs_dir "quiet=$quiet" "arch=$arch"
217+
retry_cmd ./build.sh $final_image $shim_bin $rootfs_dir "quiet=$quiet" "arch=$arch" "name=$distro"
187218
print_info "build complete! the final disk image is located at $final_image"
188219

189220
print_title "cleaning up"

0 commit comments

Comments
 (0)