Skip to content

Commit

Permalink
UEFI
Browse files Browse the repository at this point in the history
Close #13
  • Loading branch information
amezin committed Dec 26, 2024
1 parent ab28e4b commit e9b1542
Show file tree
Hide file tree
Showing 22 changed files with 317 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ovmf/*.fd filter=lfs diff=lfs merge=lfs -text
6 changes: 6 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
BOX_DIR = File.dirname(File.expand_path(__FILE__))

Vagrant.configure(2) do |config|
config.vm.provider :libvirt do |libvirt|
libvirt.memory = 4096
Expand Down Expand Up @@ -31,6 +33,10 @@ Vagrant.configure(2) do |config|
libvirt.graphics_port = 0
end
end

libvirt.nvram = File.join(BOX_DIR, 'efivars.fd')
libvirt.loader = File.join(BOX_DIR, Dir.glob('OVMF_CODE*', base: BOX_DIR).first)
libvirt.machine_type = 'pc-q35-8.2'
end

config.vm.synced_folder '.', '/vagrant', disabled: true
Expand Down
16 changes: 16 additions & 0 deletions alpine-3.18.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ source "qemu" "alpine318" {
"setup-interfaces -a -r && ",
"setup-sshd -k 'http://{{ .HTTPIP }}:{{ .HTTPPort }}/vagrant.pub' openssh<enter>",
]
efi_firmware_code = "${path.root}/ovmf/OVMF_CODE.4m.fd"
efi_firmware_vars = "${path.root}/ovmf/OVMF_VARS.4m.fd"
qemuargs = [["-serial", "stdio"]]
machine_type = var.machine_type
}

build {
Expand All @@ -39,6 +42,13 @@ build {
}
}

provisioner "shell" {
inline = [
"apk add efibootmgr",
"efibootmgr -c -d /dev/vda -p 1 -L alpine -l '\\EFI\\alpine\\grubx64.efi'",
]
}

provisioner "shell" {
inline = ["reboot"]
expect_disconnect = true
Expand All @@ -64,6 +74,12 @@ build {
post-processors {
post-processor "vagrant" {
vagrantfile_template = "Vagrantfile"
include = [
"${path.root}/ovmf/OVMF_CODE.4m.fd",
"${path.root}/output-${source.name}/efivars.fd",
"${path.root}/ovmf/edk2.License.txt",
"${path.root}/ovmf/OvmfPkg.License.txt",
]
}

post-processor "vagrant-registry" {
Expand Down
16 changes: 16 additions & 0 deletions alpine-3.19.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ source "qemu" "alpine319" {
"setup-interfaces -a -r && ",
"setup-sshd -k 'http://{{ .HTTPIP }}:{{ .HTTPPort }}/vagrant.pub' openssh<enter>",
]
efi_firmware_code = "${path.root}/ovmf/OVMF_CODE.4m.fd"
efi_firmware_vars = "${path.root}/ovmf/OVMF_VARS.4m.fd"
qemuargs = [["-serial", "stdio"]]
machine_type = var.machine_type
}

build {
Expand All @@ -39,6 +42,13 @@ build {
}
}

provisioner "shell" {
inline = [
"apk add efibootmgr",
"efibootmgr -c -d /dev/vda -p 1 -L alpine -l '\\EFI\\alpine\\grubx64.efi'",
]
}

provisioner "shell" {
inline = ["reboot"]
expect_disconnect = true
Expand All @@ -64,6 +74,12 @@ build {
post-processors {
post-processor "vagrant" {
vagrantfile_template = "Vagrantfile"
include = [
"${path.root}/ovmf/OVMF_CODE.4m.fd",
"${path.root}/output-${source.name}/efivars.fd",
"${path.root}/ovmf/edk2.License.txt",
"${path.root}/ovmf/OvmfPkg.License.txt",
]
}

post-processor "vagrant-registry" {
Expand Down
16 changes: 16 additions & 0 deletions alpine-3.20.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ source "qemu" "alpine320" {
"setup-interfaces -a -r && ",
"setup-sshd -k 'http://{{ .HTTPIP }}:{{ .HTTPPort }}/vagrant.pub' openssh<enter>",
]
efi_firmware_code = "${path.root}/ovmf/OVMF_CODE.4m.fd"
efi_firmware_vars = "${path.root}/ovmf/OVMF_VARS.4m.fd"
qemuargs = [["-serial", "stdio"]]
machine_type = var.machine_type
}

build {
Expand All @@ -39,6 +42,13 @@ build {
}
}

provisioner "shell" {
inline = [
"apk add efibootmgr",
"efibootmgr -c -d /dev/vda -p 1 -L alpine -l '\\EFI\\alpine\\grubx64.efi'",
]
}

provisioner "shell" {
inline = ["reboot"]
expect_disconnect = true
Expand All @@ -64,6 +74,12 @@ build {
post-processors {
post-processor "vagrant" {
vagrantfile_template = "Vagrantfile"
include = [
"${path.root}/ovmf/OVMF_CODE.4m.fd",
"${path.root}/output-${source.name}/efivars.fd",
"${path.root}/ovmf/edk2.License.txt",
"${path.root}/ovmf/OvmfPkg.License.txt",
]
}

post-processor "vagrant-registry" {
Expand Down
16 changes: 16 additions & 0 deletions alpine-3.21.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ source "qemu" "alpine321" {
"setup-interfaces -a -r && ",
"setup-sshd -k 'http://{{ .HTTPIP }}:{{ .HTTPPort }}/vagrant.pub' openssh<enter>",
]
efi_firmware_code = "${path.root}/ovmf/OVMF_CODE.4m.fd"
efi_firmware_vars = "${path.root}/ovmf/OVMF_VARS.4m.fd"
qemuargs = [["-serial", "stdio"]]
machine_type = var.machine_type
}

build {
Expand All @@ -39,6 +42,13 @@ build {
}
}

provisioner "shell" {
inline = [
"apk add efibootmgr",
"efibootmgr -c -d /dev/vda -p 1 -L alpine -l '\\EFI\\alpine\\grubx64.efi'",
]
}

provisioner "shell" {
inline = ["reboot"]
expect_disconnect = true
Expand All @@ -64,6 +74,12 @@ build {
post-processors {
post-processor "vagrant" {
vagrantfile_template = "Vagrantfile"
include = [
"${path.root}/ovmf/OVMF_CODE.4m.fd",
"${path.root}/output-${source.name}/efivars.fd",
"${path.root}/ovmf/edk2.License.txt",
"${path.root}/ovmf/OvmfPkg.License.txt",
]
}

post-processor "vagrant-registry" {
Expand Down
2 changes: 1 addition & 1 deletion alpine-answer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ ROOTSSHKEY="${trimspace(file("${path.root}/keys/vagrant.pub"))}"

NTPOPTS="openntpd"

DISKOPTS="-k lts -m sys /dev/vda"
DISKOPTS="-v -k lts -m sys /dev/vda"
6 changes: 6 additions & 0 deletions common.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ variable "headless" {
description = "Build in headless mode"
}

variable "machine_type" {
type = string
default = "pc-q35-8.2"
description = "QEMU machine type"
}

data "external-raw" "git-describe" {
program = ["git", "describe", "--tags"]
}
Expand Down
24 changes: 16 additions & 8 deletions debian-12.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@ source "qemu" "debian12" {
ssh_username = "root"
ssh_password = "vagrant"
boot_command = [
"<esc><wait><esc><wait><esc><wait><esc><wait><esc><wait><esc><wait>",
"<esc><wait><esc><wait><esc><wait><esc><wait><esc><wait><esc><wait>",
"/install.amd/vmlinuz console=ttyS0 ",
"auto=true DEBIAN_FRONTEND=text TERM=dumb debconf/priority=critical ",
"keyboard-configuration/xkb-keymap=en ",
"initrd=/install.amd/initrd.gz --- ",
"preseed/url=http://{{.HTTPIP}}:{{.HTTPPort}}/debian-preseed.cfg ",
"<enter>"
"c<wait10>",
"set gfxpayload=keep<enter><wait>",
"linux /install.amd/vmlinuz console=ttyS0 ",
"auto=true DEBIAN_FRONTEND=text TERM=dumb priority=critical keymap=en ",
"url=http://{{.HTTPIP}}:{{.HTTPPort}}/debian-preseed.cfg --- <enter><wait>",
"initrd /install.amd/initrd.gz<enter><wait>",
"boot<enter>",
]
efi_firmware_code = "${path.root}/ovmf/OVMF_CODE.4m.fd"
efi_firmware_vars = "${path.root}/ovmf/OVMF_VARS.4m.fd"
qemuargs = [["-serial", "stdio"]]
machine_type = var.machine_type
}

build {
Expand Down Expand Up @@ -80,6 +82,12 @@ build {
post-processors {
post-processor "vagrant" {
vagrantfile_template = "Vagrantfile"
include = [
"${path.root}/ovmf/OVMF_CODE.4m.fd",
"${path.root}/output-${source.name}/efivars.fd",
"${path.root}/ovmf/edk2.License.txt",
"${path.root}/ovmf/OvmfPkg.License.txt",
]
}

post-processor "vagrant-registry" {
Expand Down
9 changes: 9 additions & 0 deletions fedora-40.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ source "qemu" "fedora40" {
"initrd /images/pxeboot/initrd.img<enter><wait10>",
"boot<enter>"
]
efi_firmware_code = "${path.root}/ovmf/OVMF_CODE.4m.fd"
efi_firmware_vars = "${path.root}/ovmf/OVMF_VARS.4m.fd"
qemuargs = [["-serial", "stdio"]]
machine_type = var.machine_type
}

build {
Expand All @@ -34,6 +37,12 @@ build {
post-processors {
post-processor "vagrant" {
vagrantfile_template = "Vagrantfile"
include = [
"${path.root}/ovmf/OVMF_CODE.4m.fd",
"${path.root}/output-${source.name}/efivars.fd",
"${path.root}/ovmf/edk2.License.txt",
"${path.root}/ovmf/OvmfPkg.License.txt",
]
}

post-processor "vagrant-registry" {
Expand Down
9 changes: 9 additions & 0 deletions fedora-41.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ source "qemu" "fedora41" {
"initrd /images/pxeboot/initrd.img<enter><wait10>",
"boot<enter>"
]
efi_firmware_code = "${path.root}/ovmf/OVMF_CODE.4m.fd"
efi_firmware_vars = "${path.root}/ovmf/OVMF_VARS.4m.fd"
qemuargs = [["-serial", "stdio"]]
machine_type = var.machine_type
}

build {
Expand All @@ -34,6 +37,12 @@ build {
post-processors {
post-processor "vagrant" {
vagrantfile_template = "Vagrantfile"
include = [
"${path.root}/ovmf/OVMF_CODE.4m.fd",
"${path.root}/output-${source.name}/efivars.fd",
"${path.root}/ovmf/edk2.License.txt",
"${path.root}/ovmf/OvmfPkg.License.txt",
]
}

post-processor "vagrant-registry" {
Expand Down
19 changes: 15 additions & 4 deletions opensuse-leap-15.6.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@ source "qemu" "opensuseleap156" {
ssh_username = "vagrant"
ssh_password = "vagrant"
boot_command = [
"<esc><enter><wait>",
"linux netsetup=dhcp lang=en_US textmode=1 ssh=0 sshd=0 linuxrc.log=/dev/ttyS0 <wait>",
"autoyast=http://{{ .HTTPIP }}:{{ .HTTPPort }}/opensuse.xml<wait>",
"<enter><wait>"
"c<wait10>",
"set gfxpayload=keep<enter><wait>",
"linux /boot/x86_64/loader/linux netsetup=dhcp lang=en_US textmode=1 ssh=0 sshd=0 linuxrc.log=/dev/ttyS0 <wait>",
"autoyast=http://{{ .HTTPIP }}:{{ .HTTPPort }}/opensuse.xml<enter><wait>",
"initrd /boot/x86_64/loader/initrd<enter><wait>",
"boot<enter>"
]
efi_firmware_code = "${path.root}/ovmf/OVMF_CODE.4m.fd"
efi_firmware_vars = "${path.root}/ovmf/OVMF_VARS.4m.fd"
qemuargs = [["-serial", "stdio"]]
machine_type = var.machine_type
}

build {
Expand All @@ -31,6 +36,12 @@ build {
post-processors {
post-processor "vagrant" {
vagrantfile_template = "Vagrantfile"
include = [
"${path.root}/ovmf/OVMF_CODE.4m.fd",
"${path.root}/output-${source.name}/efivars.fd",
"${path.root}/ovmf/edk2.License.txt",
"${path.root}/ovmf/OvmfPkg.License.txt",
]
}

post-processor "vagrant-registry" {
Expand Down
19 changes: 15 additions & 4 deletions opensuse-tumbleweed.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,17 @@ source "qemu" "opensusetumbleweed" {
ssh_username = "vagrant"
ssh_password = "vagrant"
boot_command = [
"<esc><enter><wait>",
"linux netsetup=dhcp lang=en_US textmode=1 ssh=0 sshd=0 linuxrc.log=/dev/ttyS0 <wait>",
"autoyast=http://{{ .HTTPIP }}:{{ .HTTPPort }}/opensuse.xml<wait>",
"<enter><wait>"
"c<wait10>",
"set gfxpayload=keep<enter><wait>",
"linux /boot/x86_64/loader/linux netsetup=dhcp lang=en_US textmode=1 ssh=0 sshd=0 linuxrc.log=/dev/ttyS0 <wait>",
"autoyast=http://{{ .HTTPIP }}:{{ .HTTPPort }}/opensuse.xml<enter><wait>",
"initrd /boot/x86_64/loader/initrd<enter><wait>",
"boot<enter>"
]
efi_firmware_code = "${path.root}/ovmf/OVMF_CODE.4m.fd"
efi_firmware_vars = "${path.root}/ovmf/OVMF_VARS.4m.fd"
qemuargs = [["-serial", "stdio"]]
machine_type = var.machine_type
}

build {
Expand All @@ -47,6 +52,12 @@ build {
post-processors {
post-processor "vagrant" {
vagrantfile_template = "Vagrantfile"
include = [
"${path.root}/ovmf/OVMF_CODE.4m.fd",
"${path.root}/output-${source.name}/efivars.fd",
"${path.root}/ovmf/edk2.License.txt",
"${path.root}/ovmf/OvmfPkg.License.txt",
]
}

post-processor "vagrant-registry" {
Expand Down
Binary file added ovmf/OVMF_CODE.4m.fd
Binary file not shown.
Binary file added ovmf/OVMF_VARS.4m.fd
Binary file not shown.
Loading

0 comments on commit e9b1542

Please sign in to comment.