Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Would like to porpose a VirtualBox EFI support for Linux box. #1477

Open
rubisher opened this issue Feb 15, 2023 · 1 comment
Open

Would like to porpose a VirtualBox EFI support for Linux box. #1477

rubisher opened this issue Feb 15, 2023 · 1 comment
Labels
Triage: Feature Request Indicates an issue requesting new functionality. Type: Design Proposal Community survey of a proposal.

Comments

@rubisher
Copy link

Describe the Enhancement

Suggesting to add the build of EFI VirtualBox for Linux box.

Describe the Need

Searching on google, it seems that am I not the only one who is looking for this support.

Current Alternative

Create a customized template which will overwrite the vboxmanage variable.

Can We Help You Implement This

May be can you review this proposal and may be include it your next release?

Possible proposal:

diff --git a/packer_templates/pkr-sources.pkr.hcl b/packer_templates/pkr-sources.pkr.hcl
index c57e84a..fc0301a 100644
--- a/packer_templates/pkr-sources.pkr.hcl
+++ b/packer_templates/pkr-sources.pkr.hcl
@@ -199,6 +199,7 @@ source "qemu" "vm" {
   vm_name          = local.vm_name
 }
 source "virtualbox-iso" "vm" {
+  firmware                  = var.vbox_firmware
   gfx_controller            = local.vbox_gfx_controller
   gfx_vram_size             = local.vbox_gfx_vram_size
   guest_additions_path      = var.vbox_guest_additions_path
@@ -209,7 +210,7 @@ source "virtualbox-iso" "vm" {
   iso_interface             = var.vbox_iso_interface
   vboxmanage                = var.vboxmanage
   virtualbox_version_file   = var.virtualbox_version_file
-  boot_command              = var.boot_command
+  boot_command              = var.vbox_firmware == "bios" ? var.boot_command : var.boot_command_efi
   boot_wait                 = local.boot_wait
   cpus                      = var.cpus
   communicator              = local.communicator
diff --git a/packer_templates/pkr-variables.pkr.hcl b/packer_templates/pkr-variables.pkr.hcl
index 88d1a7b..b698d1e 100644
--- a/packer_templates/pkr-variables.pkr.hcl
+++ b/packer_templates/pkr-variables.pkr.hcl
@@ -110,6 +110,10 @@ variable "qemuargs" {
 }
 
 # virtualbox-iso
+variable "vbox_firmware" {
+  type    = string
+  default = "bios"
+}
 variable "vbox_gfx_controller" {
   type    = string
   default = null
@@ -204,6 +208,11 @@ variable "boot_command" {
   default     = null
   description = "Commands to pass to gui session to initiate automated install"
 }
+variable "boot_command_efi" {
+  type        = list(string)
+  default     = null
+  description = "Commands to pass to gui session to initiate automated efi install"
+}
 variable "boot_wait" {
   type    = string
   default = null
diff --git a/README.md b/README.md
index 9372d80..4803bd1 100644
--- a/README.md
+++ b/README.md
@@ -83,6 +83,35 @@ packer build -var-file=os_pkrvars/windows/windows-10gen2-x86_64.pkrvars.hcl ./pa
 
 If the build is successful, your box files will be in the `builds` directory at the root of the repository.
 
+#### VirtualBox efi support for Linux
+
+You can edit an existing template or create your own like 'os_pkrvars/centos/custom-cos7-efi-x86_64.pkrvars.hcl'
+
+```bash
+$ cd <path/to>/bento
+$ cat > os_pkrvars/centos/custom-cos7-efi-x86_64.pkrvars.hcl <<BENTO
+os_name                 = "centos"
+os_version              = "7.9"
+os_arch                 = "x86_64"
+iso_url                 = "http://mirrors.kernel.org/centos/7.9.2009/isos/x86_64/CentOS-7-x86_64-Minimal-2009.iso"
+iso_checksum            = "07b94e6b1a0b0260b94c83d6bb76b26bf7a310dc78d7a9c7432809fb9bc6194a"
+parallels_guest_os_type = "centos"
+vbox_guest_os_type      = "RedHat_64"
+vmware_guest_os_type    = "centos-64"
+vbox_firmware           = "efi"
+boot_command            = ["<up><wait><tab> inst.text inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/rhel/rudy-7ks.cfg<enter><wait>"]
+boot_command_efi        = ["<wait><up><wait>e<down><down><end><bs><bs><bs><bs><bs> inst.text inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/rhel/rudy-7ks.cfg<leftCtrlOn>x<leftCtrlOff>"]
+boot_command_hyperv     = ["<wait5><up><wait5><tab> text ks=hd:fd0:/ks.cfg<enter><wait5><esc>"]
+BENTO
+```
+
+Then build as above your 'centos-7.9-x86_64.virtualbox.box':
+ 
+```bash
+packer init -upgrade ./packer_templates
+packer build -only=virtualbox-iso.vm -var-file=os_pkrvars/centos/custom-cos7-efi-x86_64.pkrvars.hcl ./packer_templates
+```
+
 #### KVM/qemu support for Windows
 
 You must download [the iso image with the Windows drivers for paravirtualized KVM/qemu hardware](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso). You can do this from the command line: `wget -nv -nc https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso -O virtio-win.iso`.
@rubisher rubisher added the Status: Untriaged An issue that has yet to be triaged. label Feb 15, 2023
@Stromweld
Copy link
Collaborator

We are happy to review a PR. Everything in here looks good, I don't think we need another bootcommand variable though due to the bootcommand already being a variable that can be overridden in a pkrvars file. Eventually I see that as probably the way to go.

@Stromweld Stromweld added Triage: Feature Request Indicates an issue requesting new functionality. Type: Design Proposal Community survey of a proposal. and removed Status: Untriaged An issue that has yet to be triaged. labels Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Triage: Feature Request Indicates an issue requesting new functionality. Type: Design Proposal Community survey of a proposal.
Projects
None yet
Development

No branches or pull requests

2 participants