24 lines
695 B
Bash
24 lines
695 B
Bash
#!/usr/bin/env bash
|
|
set -eux
|
|
|
|
readonly DISK="/dev/vda"
|
|
readonly BOOT="${DISK}2"
|
|
readonly ROOT="${DISK}3"
|
|
|
|
# Wipe the target disk of all partitions and filesystems
|
|
sgdisk --zap-all "${DISK}"
|
|
dd if=/dev/zero of="${DISK}" bs=512 count=2048
|
|
wipefs --all "${DISK}"
|
|
|
|
# Create /boot (512M) and / (100%)
|
|
sgdisk --new=1:0:+1M --typecode=0:ef02 --change-name=0:bios "${DISK}"
|
|
sgdisk --new=2:0:+512M --typecode=0:8300 --change-name=0:boot --attributes=0:set:1 "${DISK}"
|
|
sgdisk --new=3:0:0 --typecode=0:8300 --change-name=0:root "${DISK}"
|
|
|
|
mkfs.ext4 -e remount-ro -q -L boot ${BOOT}
|
|
mkfs.ext4 -e remount-ro -q ${ROOT}
|
|
|
|
mount -o noatime "${ROOT}" /mnt
|
|
mkdir -p /mnt/boot
|
|
mount -o noatime "${BOOT}" /mnt/boot
|