set hostname when building the rootfs

This commit is contained in:
ading2210 2023-10-20 19:30:02 -07:00
parent bff62cdc23
commit 5132387ff7
7 changed files with 33 additions and 15 deletions

View File

@ -13,7 +13,7 @@ This is a set of scripts for patching a Chrome OS RMA shim to serve as a bootloa
- ~~host repo for patched systemd packages~~
- ~~use debootstrap to install debian~~
- ~~prompt user for hostname and account when creating the rootfs~~
- auto load iwlmvm
- ~~auto load iwlmvm~~
- get wifi fully working
- host prebuilt images
- write detailed documentation
@ -26,7 +26,7 @@ This is a set of scripts for patching a Chrome OS RMA shim to serve as a bootloa
## Usage:
### Prerequisites:
- A seperate Linux PC for the build process (preferably something Debian-based)
- A separate 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
@ -35,7 +35,7 @@ This is a set of scripts for patching a Chrome OS RMA shim to serve as a bootloa
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.
4. Run `mkdir -P data/rootfs` to make a directory for the rootfs.
4. Run `mkdir -p data/rootfs` to make a directory for the rootfs.
5. Run `sudo ./build_rootfs.sh data/rootfs bookworm` to build the base rootfs.
6. Run `sudo ./patch_rootfs.sh path_to_shim path_to_reco data/rootfs` to patch the base rootfs and add any needed drivers.
7. Run `sudo ./build.sh image.bin path_to_shim data/rootfs` to generate a disk image at `image.bin`.

0
build.sh Executable file → Normal file
View File

11
build_image.sh Executable file → Normal file
View File

@ -127,13 +127,4 @@ create_image() {
fallocate -l "${total_size}M" "${image_path}"
partition_disk $image_path $bootloader_size
}
#for testing only
if [ $0 == "./build_image.sh" ]; then
create_image ./test.bin 20 200
image_loop=$(create_loop ./test.bin)
create_partitions $image_loop /tmp/shim_kernel/kernel.bin
populate_partitions $image_loop ./tmp/shim_initramfs ./lib
losetup -d $image_loop
fi
}

11
build_rootfs.sh Executable file → Normal file
View File

@ -43,7 +43,18 @@ release_name="${2}"
debootstrap $release_name $rootfs_dir http://deb.debian.org/debian/
cp -r rootfs/* $rootfs_dir
chroot_mounts="proc sys dev run"
for mountpoint in $chroot_mounts; do
mount --make-rslave --rbind "/${mountpoint}" "${rootfs_dir}/$mountpoint"
done
chroot_command="DEBUG=${DEBUG} release_name=${release_name} /opt/setup_rootfs.sh"
chroot $rootfs_dir /bin/bash -c "${chroot_command}"
chroot_mounts="proc sys dev run"
for mountpoint in $chroot_mounts; do
umount "${rootfs_dir}/$mountpoint"
done
echo "rootfs has been created"

0
patch_initramfs.sh Executable file → Normal file
View File

2
patch_rootfs.sh Executable file → Normal file
View File

@ -43,7 +43,7 @@ copy_firmware() {
download_firmware $firmware_path
fi
cp -r --remove-destination "${firmware_path}/"* "${target_rootfs}/lib/modules/"
cp -r --remove-destination "${firmware_path}/"* "${target_rootfs}/lib/firmware/"
}
download_firmware() {

18
rootfs/opt/setup_rootfs.sh Executable file → Normal file
View File

@ -28,10 +28,26 @@ apt-get upgrade -y
#install desktop
apt-get install -y xfce4 xfce4-goodies network-manager blueman firefox-esr sudo
#set up hostname and username
read -p "Enter the hostname for the system: " hostname
echo "${hostname}" > /etc/hostname
tee -a /etc/hosts << END
127.0.0.1 localhost
127.0.1.1 ${hostname}
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
END
echo "Enter a root password:"
passwd root
read -p "Enter the username for the user account: " username
useradd -m -s /bin/bash -G sudo $username
echo "Enter the password for ${username}:"
passwd $username
passwd $username
#clean apt caches
apt-get clean