#!/usr/bin/env bash # A quick and dirty script to a full disk setup this # script uses gdisk to create a GPT disk table and # create all basic partitions, THIS IS DESTRUCTIVE # filesystem="ext4" if echo "${1}" | grep -q "^--filesystem="; then filesystem=$(echo "${1}" | sed 's|^--filesystem=||') [ ! -f "/usr/sbin/mkfs.${filesystem}" ] && { filesystem="ext4" } shift fi disk=${1} # Create the GPT Partition table echo -e " o y w y " | gdisk "${disk}" # Create the EFI Partition echo -e " n +512M EF00 w y " | gdisk "${disk}" # Create the EXT4 Partition echo -e " n w y " | gdisk "${disk}" partx -u "/dev/$(lsblk -no PKNAME ${disk})" partprobe "/dev/$(lsblk -no PKNAME ${disk})" efi=$(lsblk -lnpo NAME "${1}" | grep -E "^${disk}(p)?1$") root=$(lsblk -lnpo NAME "${1}" | grep -E "^${disk}(p)?2$") echo y | mkfs.fat -F32 "${efi}" echo y | mkfs.${filesystem} "${root}"