Created
July 21, 2021 17:59
-
-
Save MiniMeOSc/457c7adf2a62aab09e2d352818c3f8d7 to your computer and use it in GitHub Desktop.
Draft of a shell script to install raspios to an nvme ssd connected to a cm4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ $EUID -ne 0 ]] ; then | |
echo "Please run as root" | |
exit | |
fi | |
# exit immediately when a command fails | |
set -o errexit | |
# write the image to the nvme drive | |
echo "Writing image..." | |
dd if=/home/pi/Downloads/2021-05-07-raspios-buster-armhf-lite.img of=/dev/nvme0n1 | |
# resize partition and filesystem | |
echo "Resizing partition..." | |
parted /dev/nvme0n1 resizepart 2 100% | |
resize2fs -f /dev/nvme0n1p2 | |
# update firmware and kernel to the latest pre-release version | |
echo "Mounting partitions..." | |
mkdir -p mnt/fat32 | |
mkdir -p mnt/ext4 | |
mount /dev/nvme0n1p1 mnt/fat32 | |
mount /dev/nvme0n1p2 mnt/ext4 | |
echo "Running rpi-update..." | |
ROOT_PATH=mnt/ext4 BOOT_PATH=mnt/fat32 SKIP_WARNING=1 rpi-update | |
echo "Unmounting partitions..." | |
umount /dev/nvme0n1p1 | |
umount /dev/nvme0n1p2 | |
rmdir mnt/fat32 | |
rmdir mnt/ext4 | |
# note: not cleaning up the mnt directory because rpi-update creates a backup of the files of fat32 partition in there | |
echo "Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment