shell-scripte-code/raspberry_arch-install.sh

88 lines
1.4 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
#
set -ex
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
sudo "${0}" "$@"
exit 0
fi
2022-06-26 14:34:15 +02:00
sfdisk -l
read -p "Welches Laufwerk soll beschrieben werden?: [/dev/sda|/dev/sdb] " device
2022-06-26 14:34:15 +02:00
[[ -z "${device}" ]] && echo "No device is set! Abort..." && exit 1
echo "Wipe Device ${device} ..."
sleep 5
wipefs -a -f ${device}
echo "Create new Partition type ..."
sleep 5
bootpartitionnummer=1
rootpartitionnummer=2
2022-12-31 01:42:59 +01:00
fdisk ${device} <<EOF
2022-06-26 14:34:15 +02:00
o
p
n
p
1
2048
+200M
J
t
c
n
p
2
J
w
EOF
echo "Create and mount the FAT filesystem..."
sleep 5
2022-06-26 13:30:19 +02:00
mkfs.vfat ${device}${bootpartitionnummer}
2022-06-26 14:34:15 +02:00
mkdir -p boot
2022-06-26 13:30:19 +02:00
mount ${device}${bootpartitionnummer} boot
echo "Create and mount the ext4 filesystem..."
sleep 5
2022-06-26 13:30:19 +02:00
mkfs.ext4 ${device}${rootpartitionnummer}
2022-06-26 14:34:15 +02:00
mkdir -p root
2022-06-26 13:30:19 +02:00
mount ${device}${rootpartitionnummer} root
echo "Download and extract the root filesystem..."
sleep 5
2022-12-30 23:33:12 +01:00
if ! [ -f "ArchLinuxARM-rpi-aarch64-latest.tar.gz" ]; then
wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-aarch64-latest.tar.gz
2022-06-26 14:34:15 +02:00
fi
2022-12-30 23:33:12 +01:00
bsdtar -xpf ArchLinuxARM-rpi-aarch64-latest.tar.gz -C root
sync
# Before unmounting the partitions, update /etc/fstab for the different SD block device compared to the Raspberry Pi 3
sed -i 's/mmcblk0/mmcblk1/g' root/etc/fstab
echo "Move boot files to the first partition..."
sleep 5
mv root/boot/* boot
2023-05-24 13:55:13 +02:00
sync
2023-05-24 13:55:13 +02:00
read -p "Weiter mit unmount..."
umount boot root