From bff62cdc23075c85ee56658d32143276ae21ad38 Mon Sep 17 00:00:00 2001 From: ading2210 Date: Fri, 20 Oct 2023 20:51:56 +0000 Subject: [PATCH] build script fixes --- README.md | 16 +++++++++++++++- bootloader/bin/bootstrap.sh | 2 +- build.sh | 9 +++++---- build_image.sh | 7 ++++--- rootfs/etc/modules-load.d/wifi.conf | 1 + 5 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 rootfs/etc/modules-load.d/wifi.conf diff --git a/README.md b/README.md index 8c1becb..74a57bd 100644 --- a/README.md +++ b/README.md @@ -12,12 +12,26 @@ This is a set of scripts for patching a Chrome OS RMA shim to serve as a bootloa - ~~autostart X11~~ - ~~host repo for patched systemd packages~~ - ~~use debootstrap to install debian~~ -- prompt user for hostname and account when creating the rootfs +- ~~prompt user for hostname and account when creating the rootfs~~ - auto load iwlmvm +- get wifi fully working - host prebuilt images - write detailed documentation +### Long Term Goals: +- get zram to work +- eliminate binwalk dependency +- get audio to work + ## Usage: + +### Prerequisites: +- A seperate Linux PC for the build process (preferably something Debian-based) +- A USB that is at least 8GB in size +- At least 20GB of free disk space +- An x86-based Chromebook + +### Instructions: 1. Grab a Chrome OS RMA Shim from somewhere. Most of them have already been leaked and aren't too difficult to find. 2. Download a Chrome OS [recovery image](https://chromiumdash.appspot.com/serving-builds?deviceCategory=ChromeOS) for your board. 3. Clone this repository and cd into it. diff --git a/bootloader/bin/bootstrap.sh b/bootloader/bin/bootstrap.sh index 6635ee9..ec91617 100644 --- a/bootloader/bin/bootstrap.sh +++ b/bootloader/bin/bootstrap.sh @@ -127,7 +127,7 @@ boot_target() { mkdir -p /newroot/bootloader pivot_root /newroot /newroot/bootloader local tty="/dev/pts/0" - exec /sbin/init 5 < "$tty" >> "$tty" 2>&1 + exec /sbin/init < "$tty" >> "$tty" 2>&1 } main() { diff --git a/build.sh b/build.sh index 150cea9..d62440c 100755 --- a/build.sh +++ b/build.sh @@ -15,7 +15,7 @@ print_help() { } check_deps() { - local needed_commands="cpio binwalk pcregrep realpath cgpt mkfs.ext4 mkfs.ext2 fdisk" + local needed_commands="cpio binwalk pcregrep realpath cgpt mkfs.ext4 mkfs.ext2 fdisk rsync" for command in $needed_commands; do if ! command -v $command &> /dev/null; then echo $command @@ -89,9 +89,9 @@ patch_initramfs $initramfs_dir echo "creating disk image" rootfs_size=$(du -sm $rootfs_dir | cut -f 1) -rootfs_part_size=$(($rootfs_size * 11 / 10 + 50)) +rootfs_part_size=$(($rootfs_size * 11 / 10)) #create a 20mb bootloader partition -#rootfs partition is 10% larger than its contents +#rootfs partition is 20% larger than its contents create_image $output_path 20 $rootfs_part_size echo "creating loop device for the image" @@ -110,4 +110,5 @@ populate_partitions $image_loop $initramfs_dir $rootfs_dir echo "cleaning up loop devices" losetup -d $shim_loop -losetup -d $image_loop \ No newline at end of file +losetup -d $image_loop +echo "done" \ No newline at end of file diff --git a/build_image.sh b/build_image.sh index c19d613..a5c32aa 100755 --- a/build_image.sh +++ b/build_image.sh @@ -66,7 +66,7 @@ partition_disk() { #write changes echo w - ) | fdisk $image_path + ) | fdisk $image_path > /dev/null } safe_mount() { @@ -112,7 +112,7 @@ populate_partitions() { #write rootfs to image local rootfs_mount=/tmp/new_rootfs safe_mount "${image_loop}p4" $rootfs_mount - cp -r $rootfs_dir/* $rootfs_mount + rsync --archive --human-readable --hard-links --info=progress2 --sparse $rootfs_dir/ $rootfs_mount/ umount $rootfs_mount } @@ -123,7 +123,8 @@ create_image() { #stateful + kernel + bootloader + rootfs local total_size=$((1 + 32 + $bootloader_size + $rootfs_size)) - dd if=/dev/zero of=$image_path bs=1M oflag=sync count=$total_size status=progress + rm -rf "${image_path}" + fallocate -l "${total_size}M" "${image_path}" partition_disk $image_path $bootloader_size } diff --git a/rootfs/etc/modules-load.d/wifi.conf b/rootfs/etc/modules-load.d/wifi.conf new file mode 100644 index 0000000..640659f --- /dev/null +++ b/rootfs/etc/modules-load.d/wifi.conf @@ -0,0 +1 @@ +iwlmvm \ No newline at end of file