You are not logged in.

#1 2013-03-23 17:08:35

oskude
Member
From: Germany
Registered: 2010-05-19
Posts: 14
Website

minimal uefi bootable archlinux image

didn't bother to make a git repo for it, but it's so nicely small and simple, so at least here:

#!/usr/bin/bash
# minimal script to create uefi bootable archlinux image
# tip: modprobe nbd max_part=2
set -exv
PS4='>> '
lolformat=raw
lolsize=1G
lolname=boot.$lolformat
loldev=/dev/nbd0
lolmnt=/tmp/lolmnt
lolpkg='gummiboot filesystem linux sed systemd bash'

## create disk image and device
qemu-img create -f $lolformat $lolname $lolsize
qemu-nbd -c $loldev $lolname

## partition disk
sgdisk --zap-all $loldev
sgdisk -n 1:0:+40M -c 1:lolboot -t 1:EF00 $loldev
sgdisk -n 2:0:0    -c 2:lolroot -t 2:8300 $loldev

## format disk
mkfs.vfat ${loldev}p1
mkfs.ext4 ${loldev}p2

## mount partitions
[[ ! -d $lolmnt ]] && mkdir $lolmnt
mount ${loldev}p2 $lolmnt
mkdir $lolmnt/boot
mount ${loldev}p1 $lolmnt/boot

## install packages
pacstrap -c -M $lolmnt $lolpkg

## get mirrorlist
mkdir -p $lolmnt/etc/pacman.d
curl 'https://www.archlinux.org/mirrorlist/\
?country=all&protocol=http&ip_version=4&use_mirror_status=on'\
  | sed 's/^#Server/Server/g' \
  > $lolmnt/etc/pacman.d/mirrorlist

## create fstab
cat > $lolmnt/etc/fstab <<EOF
PARTLABEL=lolroot /     ext4 defaults 0 1
PARTLABEL=lolboot /boot vfat defaults 0 0
EOF

## setup bootloader
mkdir -p $lolmnt/boot/efi/boot
mkdir -p $lolmnt/boot/loader/entries
echo -e "default arch\ntimeout 0" > $lolmnt/boot/loader/loader.conf
cat > $lolmnt/boot/loader/entries/arch.conf <<EOF
title   Arch Linux
linux   /vmlinuz-linux
initrd  /initramfs-linux-fallback.img
options root=PARTLABEL=lolroot init=/usr/lib/systemd/systemd
EOF
cp $lolmnt/usr/lib/gummiboot/gummibootx64.efi\
  $lolmnt/boot/efi/boot/bootx64.efi

## unmount partitions
umount $lolmnt/boot
umount $lolmnt
qemu-nbd -d $loldev
## DONE

if you want to use the created image in qemu, you can use https://aur.archlinux.org/packages/ovmf-svn/ (note: the repo is almost 800mb) and then -bios /usr/share/ovmf/bios.bin option.

disclaimer: as it needs root rights, use at own risk. and the script is supposed to be small and simple, just to get archlinux booted, login and echo hello world. so like a starting point for anyone who wants to explore further.

ps. i would be curious to hear if the created image does not work on real uefi hardware, and possibly why.

Offline

#2 2013-03-24 20:37:07

oskude
Member
From: Germany
Registered: 2010-05-19
Posts: 14
Website

Re: minimal uefi bootable archlinux image

you can now also get ovmf-svn from my new unofficial binary repo:

[oskude]
SigLevel = Never
Server = http://osku.de/archlinux/$repo/os/$arch

Offline

Board footer

Powered by FluxBB