Skip to content

Commit 92abc10

Browse files
committed
improve build scripts and documentation
1 parent cebe012 commit 92abc10

9 files changed

Lines changed: 102 additions & 85 deletions

File tree

README.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Driver support depends on the device you are using shimboot on. This list is for
3737
- Webcam
3838

3939
### What Doesn't Work:
40-
- Audio (due to a firmware bug)
40+
- Audio (due to a firmware bug on `dedede`, this works just fine on `octopus`)
4141
- Suspend (disabled by the kernel)
4242
- Swap (disabled by the kernel)
4343

@@ -59,8 +59,11 @@ Driver support depends on the device you are using shimboot on. This list is for
5959
- Finish Python TUI rewrite
6060

6161
### Long Term Goals:
62+
- Transparent disk compression
63+
- Full disk encryption
6264
- eliminate binwalk dependency
6365
- get audio to work
66+
- get kexec working
6467

6568
## Usage:
6669

@@ -71,37 +74,45 @@ Driver support depends on the device you are using shimboot on. This list is for
7174
- An x86-based Chromebook
7275

7376
### Build Instructions:
77+
1. Find the board name of your Chromebook. You can search for the model name on [chrome100.dev](https://chrome100.dev/).
78+
1. Clone this repository and cd into it.
79+
2. Run `sudo ./build_complete.sh <board_name>` to download the required data and build the disk image.
80+
81+
Alternatively, you can run each of the steps manually:
7482
1. Grab a Chrome OS RMA Shim from somewhere. Most of them have already been leaked and aren't too difficult to find.
7583
2. Download a Chrome OS [recovery image](https://chromiumdash.appspot.com/serving-builds?deviceCategory=ChromeOS) for your board.
76-
3. Unzip the recovery image and shim if you haven't done so already.
77-
4. Clone this repository and cd into it.
78-
5. Run `mkdir -p data/rootfs` to create a directory to hold the rootfs.
79-
6. Run `sudo ./build_rootfs.sh data/rootfs bookworm` to build the base rootfs.
80-
7. Run `sudo ./patch_rootfs.sh path_to_shim path_to_reco data/rootfs` to patch the base rootfs and add any needed drivers.
81-
8. Run `sudo ./build.sh image.bin path_to_shim data/rootfs` to generate a disk image at `image.bin`.
84+
3. Unzip the shim and the recovery image if you have not done so already.
85+
4. Run `mkdir -p data/rootfs` to create a directory to hold the rootfs.
86+
5. Run `sudo ./build_rootfs.sh data/rootfs bookworm` to build the base rootfs.
87+
6. Run `sudo ./patch_rootfs.sh path_to_shim path_to_reco data/rootfs` to patch the base rootfs and add any needed drivers.
88+
7. Run `sudo ./build.sh image.bin path_to_shim data/rootfs` to generate a disk image at `image.bin`.
8289

8390
### Booting the Image:
84-
1. Obtain a shimboot image by downloading a [prebuilt one](https://dl.ading.dev/shimboot/) or building it yourself.
91+
1. Obtain a shimboot image by downloading a [prebuilt one](https://github.com/ading2210/shimboot/actions) or building it yourself.
8592
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.
8693
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).
8794
4. Plug the USB into your Chromebook and enter recovery mode. It should detect the USB and run the shimboot bootloader.
8895
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`.
8996
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.
97+
7. Change the root password and regular user password by running `sudo passwd root` and `passwd user`.
9098

9199
## FAQ:
92100

93101
#### I want to use a different Linux distribution. How can I do that?
94102
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 dir into `build.sh`.
95103

96104
#### How can I install a desktop environment other than XFCE?
97-
You can pass another argument to the `build_rootfs.sh` script, like this: `sudo ./build_rootfs.sh data/rootfs bookworm "task-lxde-desktop"`. The third argument is a list of packages that will be installed in the place of XFCE.
105+
You can pass another argument to the `build_rootfs.sh` script, like this: `sudo ./build_rootfs.sh data/rootfs bookworm custom_packages=task-lxde-desktop`. The `custom_packages` argument is a list of packages that will be installed in the place of XFCE.
98106

99107
#### Will this prevent me from using Chrome OS normally?
100108
Shimboot does not touch the internal storage at all, so you will be able to use Chrome OS as if nothing happened. However, if you are on an enterprise enrolled device, booting Chrome OS again will force a powerwash due to the attempted switch into developer mode.
101109

102110
#### Can I unplug the USB drive while using Debian?
103111
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.
104112

113+
#### GPU acceleration isn't working, how can I fix this?
114+
If your kernel version is too old, the standard Mesa drivers will fail to load. Instead, you must download and install the `mesa-amber` drivers. Download this zip file (https://shimboot.ading.dev/mesa-amber.zip), extract it, and install all of the `.deb` files.
115+
105116
## Copyright:
106117
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).
107118

build.sh

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,17 @@
22

33
#build the bootloader image
44

5-
set -e
6-
if [ "$DEBUG" ]; then
7-
set -x
8-
fi
9-
5+
. ./common.sh
106
. ./image_utils.sh
117
. ./shim_utils.sh
128

139
print_help() {
1410
echo "Usage: ./build.sh output_path shim_path rootfs_dir"
1511
}
1612

17-
if [ "$EUID" -ne 0 ]; then
18-
echo "this needs to be run as root."
19-
exit 1
20-
fi
21-
22-
if [ -z "$3" ]; then
23-
print_help
24-
exit 1
25-
fi
26-
27-
. ./common.sh
13+
assert_root
2814
assert_deps "cpio binwalk pcregrep realpath cgpt mkfs.ext4 mkfs.ext2 fdisk rsync"
15+
assert_args "$3"
2916
parse_args "$@"
3017

3118
output_path=$(realpath -m "${1}")

build_complete.sh

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,19 @@
11
#!/bin/bash
22

3-
set -e
4-
if [ "$DEBUG" ]; then
5-
set -x
6-
export DEBUG=1
7-
fi
8-
93
. ./common.sh
104

11-
if [ "$EUID" -ne 0 ]; then
12-
echo "This script must be run as root."
13-
exit 1
14-
fi
15-
16-
if [ -z "$1" ]; then
5+
print_help() {
176
echo "Usage: ./build_complete.sh board_name"
187
echo "Valid named arguments (specify with 'key=value'):"
198
echo " compress_img - Compress the final disk image into a zip file. Set this to any value to enable this option."
209
echo " rootfs_dir - Use a different rootfs for the build. The directory you select will be copied before any patches are applied."
2110
echo " quiet - Don't use progress indicators which may clog up log files."
22-
exit 1
23-
fi
11+
}
2412

13+
assert_root
14+
assert_args "$1"
2515
parse_args "$@"
16+
2617
needed_deps="wget python3 unzip zip git debootstrap cpio binwalk pcregrep cgpt mkfs.ext4 mkfs.ext2 fdisk rsync"
2718
if [ "$(check_deps "$needed_deps")" ]; then
2819
#install deps automatically on debian and ubuntu

build_rootfs.sh

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@ fi
99

1010
. ./common.sh
1111

12-
if [ "$EUID" -ne 0 ]; then
13-
echo "This script must be run as root."
14-
exit 1
15-
fi
16-
17-
if [ -z "$2" ]; then
12+
print_help() {
1813
echo "Usage: ./build_rootfs.sh rootfs_path release_name"
1914
echo "Valid named arguments (specify with 'key=value'):"
2015
echo " custom_packages - The packages that will be installed in place of task-xfce-desktop."
@@ -23,10 +18,11 @@ if [ -z "$2" ]; then
2318
echo " username - The unprivileged user name for the new rootfs."
2419
echo " user_passwd - The password for the unprivileged user."
2520
echo "If you do not specify the hostname and credentials, you will be prompted for them later."
26-
exit 1
27-
fi
21+
}
2822

23+
assert_root
2924
assert_deps "realpath debootstrap"
25+
assert_args "$2"
3026
parse_args "$@"
3127

3228
rootfs_dir=$(realpath -m "${1}")

build_squashfs.sh

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,23 @@
55
# - FUSE kernel modules from the shim
66
# - unionfs-fuse statically compiled
77
# - the main squashfs, compressed with gzip
8-
#this script is currently incomplete
98

109
set -e
1110
if [ "$DEBUG" ]; then
1211
set -x
1312
fi
1413

14+
. ./common.sh
1515
. ./image_utils.sh
1616
. ./shim_utils.sh
1717

1818
print_help() {
1919
echo "Usage: ./build_squashfs.sh rootfs_dir uncompressed_rootfs_dir path_to_shim"
2020
}
2121

22-
if [ "$EUID" -ne 0 ]; then
23-
echo "this needs to be run as root."
24-
exit 1
25-
fi
26-
27-
if [ -z "$3" ]; then
28-
print_help
29-
exit 1
30-
fi
22+
assert_root
23+
assert_deps "git make gcc binwalk pcregrep"
24+
assert_args "$3"
3125

3226
compile_unionfs() {
3327
local out_path="$1"
@@ -41,7 +35,7 @@ compile_unionfs() {
4135
git clone $repo_url -b master --depth=1 $working_path
4236
cd $working_path
4337

44-
env LDFLAGS="-static" make -j$core_count
38+
env LDFLAGS="-static" CFLAGS="-O3" make -j$core_count
4539
local binary_path="$working_path/src/unionfs"
4640
cp $binary_path $out_path
4741
cd $original_dir
@@ -54,28 +48,15 @@ shim_path=$(realpath -m $3)
5448
shim_rootfs="/tmp/shim_rootfs"
5549
root_squashfs="$rootfs_dir/root.squashfs"
5650
modules_squashfs="$rootfs_dir/modules.squashfs"
57-
kernel_dir=/tmp/shim_kernel
5851
unionfs_dir="/tmp/unionfs-fuse"
5952

6053
echo "compiling unionfs-fuse"
6154
compile_unionfs $unionfs_dir/unionfs $unionfs_dir
6255

63-
echo "creating loop device for shim"
64-
shim_loop=$(create_loop "${shim_path}")
65-
kernel_loop="${shim_loop}p2" #KERN-A should always be p2
66-
67-
echo "copying shim kernel"
68-
rm -rf $kernel_dir
69-
mkdir $kernel_dir -p
70-
dd if=$kernel_loop of=$kernel_dir/kernel.bin bs=1M status=progress
71-
72-
echo "extracting initramfs from kernel (this may take a while)"
73-
extract_initramfs $kernel_dir/kernel.bin $kernel_dir $rootfs_dir
56+
echo "reading the shim image"
57+
extract_initramfs_full $shim_path $rootfs_dir
7458
rm -rf $rootfs_dir/init
7559

76-
echo "removeing shim loop device"
77-
losetup -d $shim_loop
78-
7960
echo "compressing old rootfs"
8061
mksquashfs $old_dir $root_squashfs -noappend -comp gzip
8162

common.sh

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
#!/bin/bash
22

3+
set -e
4+
if [ "$DEBUG" ]; then
5+
set -x
6+
export DEBUG=1
7+
fi
8+
39
check_deps() {
410
local needed_commands="$1"
511
for command in $needed_commands; do
612
if ! command -v $command &> /dev/null; then
7-
echo $command
13+
echo " - $command"
814
fi
915
done
1016
}
@@ -28,4 +34,18 @@ parse_args() {
2834
local value="${argument:$key_length+1}"
2935
args["$key"]="$value"
3036
done
31-
}
37+
}
38+
39+
assert_root() {
40+
if [ "$EUID" -ne 0 ]; then
41+
echo "this needs to be run as root."
42+
exit 1
43+
fi
44+
}
45+
46+
assert_args() {
47+
if [ -z "$1" ]; then
48+
print_help
49+
exit 1
50+
fi
51+
}

image_utils.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ safe_mount() {
6868
umount $2 2> /dev/null || /bin/true
6969
rm -rf $2
7070
mkdir -p $2
71-
#try to mount multiple times
7271
mount $1 $2
7372
}
7473

shim_utils.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#utilties for reading shim disk images
44

5+
#extract the initramfs from a kernel image
56
extract_initramfs() {
67
local kernel_bin="$1"
78
local working_dir="$2"
@@ -23,3 +24,30 @@ extract_initramfs() {
2324
rm -rf $output_dir
2425
cat $cpio_path | cpio -D $output_dir -imd --quiet
2526
}
27+
28+
copy_kernel() {
29+
local shim_path="$1"
30+
local kernel_dir="$2"
31+
32+
local shim_loop=$(create_loop "${shim_path}")
33+
local kernel_loop="${shim_loop}p2" #KERN-A should always be p2
34+
35+
dd if=$kernel_loop of=$kernel_dir/kernel.bin bs=1M status=progress
36+
losetup -d $shim_loop
37+
}
38+
39+
#copy the kernel image then extract the initramfs
40+
extract_initramfs_full() {
41+
local shim_path="$1"
42+
local rootfs_dir="$2"
43+
local kernel_dir=/tmp/shim_kernel
44+
45+
echo "copying the shim kernel"
46+
rm -rf $kernel_dir
47+
mkdir $kernel_dir -p
48+
copy_kernel $shim_path $kernel_dir
49+
50+
echo "extracting initramfs from kernel (this may take a while)"
51+
extract_initramfs $kernel_dir/kernel.bin $kernel_dir $rootfs_dir
52+
rm -rf $kernel_dir
53+
}

website/index.html

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,25 @@
6868
After copying all the firmware from the recovery image and shim to the rootfs, we're able to boot to a mostly working XFCE desktop.
6969

7070
<b id="prebuilt">Prebuilt Images:</b>
71-
Prebuilt images are available <a href="https://dl.ading.dev/shimboot/">here</a>. If there is not a prebuilt image for your board, you must manually build the shimboot image.
71+
Prebuilt images are available <a href="https://github.com/ading2210/shimboot/actions">here</a>. If there is not a prebuilt image for your board, you must manually build the shimboot image.
7272

7373
For these images, the root password is "root". The name of the default user is "user" and its password is "user" as well. You should change these credentials as soon as possible.
7474

7575
<b id="build">Build Instructions:</b>
76+
1. Find the board name of your Chromebook. You can search for the model name on <a href="https://chrome100.dev/">chrome100.dev</a>.
77+
1. Clone this repository and cd into it.
78+
2. Run `sudo ./build_complete.sh [board_name]` to download the required data and build the disk image.
79+
80+
Alternatively, you can run each of the steps manually:
7681
1. Grab a Chrome OS RMA Shim from somewhere. Most of them have already been leaked and aren't too difficult to find.
7782
2. Download a Chrome OS <a href="https://chromiumdash.appspot.com/serving-builds?deviceCategory=ChromeOS">recovery image</a> for your board.
78-
3. Clone this repository and cd into it.
79-
4. Run `mkdir -p data/rootfs` to create a directory to hold the rootfs.
80-
5. Run `sudo ./build_rootfs.sh data/rootfs bookworm` to build the base rootfs.
81-
6. Run `sudo ./patch_rootfs.sh path_to_shim path_to_reco data/rootfs` to patch the base rootfs and add any needed drivers.
82-
7. Run `sudo ./build.sh image.bin path_to_shim data/rootfs` to generate a disk image at `image.bin`.
83-
84-
<b id="usage">Usage:</b>
85-
1. Obtain a shimboot image by downloading a <a href="https://dl.ading.dev/shimboot/">prebuilt one</a> or building it yourself.
83+
3. Run `mkdir -p data/rootfs` to create a directory to hold the rootfs.
84+
4. Run `sudo ./build_rootfs.sh data/rootfs bookworm` to build the base rootfs.
85+
5. Run `sudo ./patch_rootfs.sh path_to_shim path_to_reco data/rootfs` to patch the base rootfs and add any needed drivers.
86+
6. Run `sudo ./build.sh image.bin path_to_shim data/rootfs` to generate a disk image at `image.bin`.
87+
88+
<b id="usage">Booting the Image:</b>
89+
1. Obtain a shimboot image by downloading a <a href="https://github.com/ading2210/shimboot/actions/">prebuilt one</a> or building it yourself.
8690
2. Flash the shimboot image to a USB drive or SD card. Use the <a href="https://chrome.google.com/webstore/detail/chromebook-recovery-utili/pocpnlppkickgojjlmhdmidojbmbodfm">Chromebook Recovery Utility</a> or <a href="https://linux.die.net/man/1/dd">dd</a> if you're on Linux.
8791
3. Enable developer mode on your Chromebook. If the Chromebook is enrolled, follow the instructions on the <a href="https://sh1mmer.me">sh1mmer website</a> (see the "Executing on Chromebook" section).
8892
4. Plug the USB into your Chromebook and enter recovery mode. It should detect the USB and run the shimboot bootloader.

0 commit comments

Comments
 (0)