alpine: add uefi support

This commit is contained in:
Nico Schottelius 2022-02-11 22:24:43 +01:00
commit 9c0beb18d3

View file

@ -1,9 +1,10 @@
#!/bin/sh
if [ $# -ne 2 ]; then
echo "$0 disk ssh-keyfile"
if [ $# -ne 3 ]; then
echo "$0 disk ssh-keyfile [efi|bios]"
echo " disk: which disk to install to"
echo " ssh-keyfile: ssh keys to add into the image"
echo " use efi or bios partitioning"
exit 1
fi
@ -12,8 +13,9 @@ set -x
DISK=$1; shift
SSH_KEYS=$1; shift
BOOT_VIA=$1; shift
MAJOR_VERSION=3.14
MAJOR_VERSION=3.15
MINOR_VERSION=0
IMAGE=alpine-minirootfs-$MAJOR_VERSION.$MINOR_VERSION-x86_64.tar.gz
@ -26,10 +28,12 @@ rootfs_url="http://dl-cdn.alpinelinux.org/alpine/v$MAJOR_VERSION/releases/x86_64
case $DISK in
/dev/sd*)
partition=${DISK}1
partition1=${DISK}1
partition2=${DISK}2
;;
/dev/mmcblk*|/dev/nvme*)
partition=${DISK}p1
partition1=${DISK}p1
partition2=${DISK}p2
;;
*)
echo "Unsupported disk - edit this script" >&2
@ -49,16 +53,34 @@ wget -c "$rootfs_url" -O "$IMAGE"
# in the gap and also the paritition table
dd if=/dev/zero of=${DISK} bs=1M count=2
# Partition disk with 1 Linux partition
sudo sfdisk "$DISK" <<EOF
case "$BOOT_VIA" in
bios)
sudo sfdisk "$DISK" <<EOF
label: dos
,,L
EOF
# For creation, if an existing filesystem is on the partitions
sudo mkfs.ext4 -F ${partition1}
sudo mount ${partition1} $rootfs_tmpdir
;;
efi)
sudo sfdisk "$DISK" <<EOF
label: gpt
,500MiB,U
,,L
EOF
sudo mkfs.vfat ${partition1}
sudo mkfs.ext4 -F ${partition2}
sudo mount ${partition2} "$rootfs_tmpdir"
sudo mkdir "${rootfs_tmpdir}/boot"
sudo mount ${partition1} "${rootfs_tmpdir}/boot"
;;
*)
echo "Unknown disk format, $BOOT_VIA" >&2
exit
;;
esac
# For creation, if an existing filesystem is on the partitions
sudo mkfs.ext4 -F ${partition}
sudo mount ${partition} $rootfs_tmpdir
# keep right permissions, use sudo
sudo tar xf $IMAGE -C $rootfs_tmpdir