imgname=anemos-test target=alpine #format="raw 4g msdos ext4" format="custom" # Sections # Core system # Provisioning reqs # Anemos reqs # Other packages=" alpine-base linux-virt syslinux e2fsprogs lsblk zstd curl openssh " services=" networking:boot sshd " # FIXME: this was copied from ne nameserver example # maybe change to fdisk? setup() { # Repartition, in case the disk das been reset to a vendor image parted -s -- /dev/vda mklabel msdos \ mkpart primary 2048s 256MiB \ mkpart primary 256MiB -1s \ set 1 boot on partprobe /dev/vda # wait for hotplug events to settle... sleep 1 && mdev -sf uuidr=$(uuidgen) uuidb=$(uuidgen) mkfs.ext2 -q -F -U "$uuidb" /dev/vda1 mkfs.ext4 -q -F -U "$uuidr" /dev/vda2 mount /dev/vda2 "${imgroot}" mkdir "${imgroot}/boot" mount /dev/vda1 "${imgroot}/boot" mkdir "${imgroot}/etc" opts=$(findmnt -no OPTIONS /dev/vda2) printf "UUID=%s\t/\t%s\t%s\t0 1\n" "${uuidr}" "ext4" "${opts}" > "${imgroot}/etc/fstab" # Keep b opts=$(findmnt -no OPTIONS /dev/vda1) printf "UUID=%s\t/boot\t%s\t%s\t0 2\n" "${uuidb}" "ext2" "${opts},noauto" >> "${imgroot}/etc/fstab" } cleanup() { umount "${imgroot}/boot" umount "${imgroot}" } provision() { # Bootloader uuid=$(lsblk -rno UUID /dev/vda2) sed -e "s|^root=|root=/dev/disk/by-uuid/${uuid}|" -i /etc/update-extlinux.conf dd bs=440 count=1 conv=notrunc if=/usr/share/syslinux/mbr.bin of="${BLKDEV}" extlinux --install /boot update-extlinux -v }