Skip to content

Instantly share code, notes, and snippets.

@unixabg
Created November 23, 2023 13:39
Show Gist options
  • Save unixabg/3b21f0c5cf86dde9ec132df81d6d3477 to your computer and use it in GitHub Desktop.
Save unixabg/3b21f0c5cf86dde9ec132df81d6d3477 to your computer and use it in GitHub Desktop.
Veyron Installer Script
#!/bin/bash
set -x
_VER='1.0.1-beta'
echo "Script version veyron-install: $_VER"
export TGTDEV=mmcblk0
sgdisk -Z /dev/$TGTDEV
sync
partprobe /dev/$TGTDEV
partprobe /dev/$TGTDEV
sgdisk -C -e -G /dev/$TGTDEV
partprobe /dev/$TGTDEV
cgpt create /dev/$TGTDEV
partprobe /dev/$TGTDEV
cgpt add -i 1 -t kernel -b 73728 -s 32768 -l KernelA -S 1 -T 2 -P 10 /dev/$TGTDEV
cgpt repair /dev/$TGTDEV
cgpt add -i 2 -t kernel -b 106496 -s 32768 -l KernelB -S 0 -T 2 -P 5 /dev/$TGTDEV
cgpt repair /dev/$TGTDEV
partprobe /dev/$TGTDEV
fdisk -l /dev/mmcblk0
fdisk /dev/$TGTDEV < gpt-partitions.txt
losetup --partscan /dev/loop0 chromebook_veyron-armv7l-bookworm.img
dd if=/dev/loop0p3 of=/dev/${TGTDEV}p3 bs=1024k status=progress
dd if=/dev/loop0p4 of=/dev/${TGTDEV}p4 bs=1024k status=progress
# clean up loop devices
losetup -d /dev/loop0
# copy in the uboot we need for eduGear M4
mkdir /tmp/p3
mount /dev/mmcblk0p3 /tmp/p3/
dd if=/tmp/p3/extra/uboot.kpart.cbr-minnie of=/dev/mmcblk0p1
# update the boot information to use emmc names
sed -i 's,bootpart,bootemmc,g;s,rootpart,rootemmc,g' /tmp/p3/extlinux/extlinux.conf
# clean up
sync
umount /tmp/p3
# do some tasks on the btrfs
mkdir /tmp/p4
mount /dev/mmcblk0p4 /tmp/p4
sed -i 's,bootpart,bootemmc,g;s,rootpart,rootemmc,g' /tmp/p4/etc/fstab
btrfs filesystem resize max /tmp/p4
sync
umount /tmp/p4
# run a filesystem check on p4
btrfs check /dev/mmcblk0p4
# update partition labels
btrfs filesystem label /dev/mmcblk0p4 rootemmc
e2label /dev/mmcblk0p3 bootemmc
# dump some output for sanity check
lsblk -o name,size,label
echo "Ready for reboot, or any extra changes you may want. Enjoy Linux on your emmc of $TGTDEV"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment