shell-scripte-code/raspberry_arch-install.sh

87 lines
1.2 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-06-26 14:34:15 +02:00
fdisk /dev/sdd <<EOF
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-06-26 14:34:15 +02:00
if ! [ -f "ArchLinuxARM-rpi-armv7-latest.tar.gz" ]; then
wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-armv7-latest.tar.gz
fi
bsdtar -xpf ArchLinuxARM-rpi-armv7-latest.tar.gz -C root
sync
echo "Move boot files to the first partition..."
sleep 5
mv root/boot/* boot
echo "Unmount the two partitions..."
sleep 5
umount boot root