Skip to content

Commit

Permalink
Debian uefi build
Browse files Browse the repository at this point in the history
  • Loading branch information
philnewm committed Oct 1, 2024
1 parent d2384a7 commit 60d03df
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 106 deletions.
19 changes: 10 additions & 9 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# Short Term
# Remaining Tasks

## Short Term

* vagrant cloud publish philnewm/debian12-gnome 0.1.1 virtualbox Debian.. --version-description "Fix non-opening terminal" --release
* Move reboots to handlers for one reboot at the end
* Fix broken gnome-terminal on debian
* Update debian12 + Ubuntu22.04 to use efi boot by default
* Add zstd to debian12 box for slightly faster package install process
* fix bidirectional clipboard for Ubuntu22.04 an debian12 box
* check for virtualbox guest additions version using `VBoxControl --version`
* Research [packer CI/CD integration](https://developer.hashicorp.com/packer/guides/packer-on-cicd/build-virtualbox-image)

## Long Term

# Long Term
* research how to manage static ip adresses for pre-made images
* research resonable defaults kickstart information for vbox dev VMs/libvirt VMs


# infos
*checksum (sha256sum): f7ea0469a4ff0fbfc4be7d013431fe839c3fdca3dc969dd7086c98d757e92389
* research how to manage static ip addresses for pre-made images
* research reasonable defaults kickstart information for vbox dev VMs/libvirt VMs
1 change: 1 addition & 0 deletions centosstream9-vagrant.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ source "virtualbox-iso" "centosstream-9" {
cpus = var.cpus
memory = var.memory
headless = var.headless
gfx_efi_resolution = "1280x720"
hard_drive_interface = "sata"
iso_interface = "sata"
output_directory = "output_vbox"
Expand Down
2 changes: 2 additions & 0 deletions debian12-vagrant.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ source "virtualbox-iso" "debian-12" {
ssh_timeout = var.ssh_timeout
boot_command = local.debian_vagrant_boot_command_12_x86_64
boot_wait = var.boot_wait
firmware = "efi"
disk_size = var.vagrant_disk_size
guest_os_type = "Debian_64"
cpus = var.cpus
memory = var.memory
headless = var.headless
gfx_efi_resolution = "1280x720"
hard_drive_interface = "sata"
iso_interface = "sata"
output_directory = "output_vbox"
Expand Down
7 changes: 5 additions & 2 deletions http/debian-12-vagrant-x86_64.preseed
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ d-i finish-install/reboot_in_progress note
# This is fairly safe to set, it makes grub install automatically to the MBR
# if no other operating system is detected on the machine.
d-i grub-installer/only_debian boolean true
d-i grub-installer/bootdev string /dev/sda
d-i grub-installer/bootdev string default
d-i grub-installer/efi/secure_boot boolean false
d-i grub-installer/with_other_os boolean true

# This one makes grub-installer install to the MBR if it also finds some other
# OS, which is less safe as it might not be able to boot that other OS.
Expand Down Expand Up @@ -50,6 +52,7 @@ d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i partman-efi/non_efi_system boolean true

### Account setup
d-i passwd/user-fullname string vagrant
Expand All @@ -69,7 +72,7 @@ popularity-contest popularity-contest/participate boolean false
apt-cdrom-setup apt-setup/cdrom/set-first boolean false
d-i pkgsel/run_tasksel boolean false
d-i pkgsel/install-recommends boolean false
d-i pkgsel/include string openssh-server build-essential python3
d-i pkgsel/include string openssh-server build-essential python3 locales-all
d-i pkgsel/install-language-support boolean false
d-i pkgsel/upgrade select full-upgrade

Expand Down
63 changes: 37 additions & 26 deletions http/user-data
Original file line number Diff line number Diff line change
@@ -1,44 +1,52 @@
#cloud-config
# https://gist.github.com/craig-m/eb4a0840fa03a82398423769676ef426
# preserve_hostname: false
#cloud-config
autoinstall:
# Hi there! If you are like me, and the ugly comment on line 1 is triggering your OCD, you might be wondering why
# it has not been removed. Well, let me indulge you. It needs to be there, or this entire autoinstall file will not
# be picked up it all. This is all very nicely documented by Ubuntu (NOT), so this took me an hour to find out,
# making me add this little comment do you don't have to!
# https://gist.github.com/craig-m/eb4a0840fa03a82398423769676ef426
version: 1
early-commands:
# We need to disable ssh during the autoinstall phase, or Packer will try to connect.
# After autoinstall, the VM will reboot, ssh will start up, and then Packer can continue.
- "systemctl stop sshd"
codecs:
install: false
drivers:
install: false
identity:
hostname: ubuntu2204
username: vagrant
realname: vagrant
# This password is "vagrant", use the command `openssl passwd -6` to generate a new hash if needed.
# This needs to match the "ssh_password" field in packer.json
password: "$6$CG/3wG6U6vagDFjC$WjSNjZaL/CqK/8SwMO0ARqvY614BG2LceS9ZEGr6K9PQhIDnNmlZVEG6z2LmoDYK0XYtP7emnR5Pte4j7DUoA0"
ssh:
allow-pw: true
install-server: true
realname: vagrant
kernel:
package: linux-generic
package_update: true
package_upgrade: true
keyboard:
layout: "us"
toggle: null
locale: "en_US.UTF-8"
ssh:
install-server: true
allow-pw: true
storage:
layout:
name: direct
packages:
- bzip2
- tar
- python3
- python3-pip
- curl
- vim
- git
user-data:
users:
- name: vagrant
gecos: Vagrant User
primary_group: sudo
groups: [sudo, adm]
lock_passwd: false
passwd: "$6$CG/3wG6U6vagDFjC$WjSNjZaL/CqK/8SwMO0ARqvY614BG2LceS9ZEGr6K9PQhIDnNmlZVEG6z2LmoDYK0XYtP7emnR5Pte4j7DUoA0"
package_update: true
package_upgrade: true
runcmd:
- echo 'vagrant ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/vagrant
# - sudo systemd-machine-id-setup
# - sudo systemctl restart systemd-networkd
- grub-pc
- open-vm-tools
runcmd:
- tasksel install server
- apt-get -y remove biosdevname dnf-plugin-spacewalk dracut-config-rescue iprutils
- apt-get -y remove '*-firmware' '*langpack-*' plymouth rh*
- apt-get -y autoremove
- update-initramfs -u
late-commands:
- "curtin in-target --target=/target -- rm -rf /var/lib/apt/lists"
- "curtin in-target --target=/target -- apt-get update"
Expand All @@ -49,5 +57,8 @@ autoinstall:
- "curtin in-target --target=/target -- apt-get clean"
- "curtin in-target --target=/target -- rm -rf /var/lib/apt/lists/*"
- "rm -rf /var/lib/apt/lists/*"
- "echo 'Defaults:vagrant !requiretty' > /target/etc/sudoers.d/vagrant"
- "echo 'vagrant ALL=(ALL) NOPASSWD: ALL' >> /target/etc/sudoers.d/vagrant"
- "chmod 440 /target/etc/sudoers.d/vagrant"
power_state:
mode: reboot
mode: reboot
61 changes: 0 additions & 61 deletions http/user-data_old

This file was deleted.

53 changes: 53 additions & 0 deletions http/user-data_ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#cloud-config
# https://gist.github.com/craig-m/eb4a0840fa03a82398423769676ef426
# preserve_hostname: false
autoinstall:
version: 1
identity:
hostname: ubuntu2204
username: vagrant
realname: vagrant
password: "$6$CG/3wG6U6vagDFjC$WjSNjZaL/CqK/8SwMO0ARqvY614BG2LceS9ZEGr6K9PQhIDnNmlZVEG6z2LmoDYK0XYtP7emnR5Pte4j7DUoA0"
ssh:
allow-pw: true
install-server: true
kernel:
package: linux-generic
keyboard:
layout: "us"
toggle: null
storage:
layout:
name: direct
packages:
- python3
- python3-pip
- curl
- vim
- git
user-data:
users:
- name: vagrant
gecos: Vagrant User
primary_group: sudo
groups: [sudo, adm]
lock_passwd: false
passwd: "$6$CG/3wG6U6vagDFjC$WjSNjZaL/CqK/8SwMO0ARqvY614BG2LceS9ZEGr6K9PQhIDnNmlZVEG6z2LmoDYK0XYtP7emnR5Pte4j7DUoA0"
package_update: true
package_upgrade: true
runcmd:
- echo 'vagrant ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/vagrant
# - sudo systemd-machine-id-setup
# - sudo systemctl restart systemd-networkd
late-commands:
- "curtin in-target --target=/target -- rm -rf /var/lib/apt/lists"
- "curtin in-target --target=/target -- apt-get update"
- "curtin in-target --target=/target -- apt-get -y upgrade"
- "curtin in-target --target=/target -- apt-get -y dist-upgrade"
- "curtin in-target --target=/target -- apt-get -y autoremove"
- "curtin in-target --target=/target -- apt-get autoclean"
- "curtin in-target --target=/target -- apt-get clean"
- "curtin in-target --target=/target -- rm -rf /var/lib/apt/lists/*"
- "rm -rf /var/lib/apt/lists/*"
power_state:
mode: reboot
8 changes: 4 additions & 4 deletions packer_test.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
rm Vagrantfile || true
rm -R .vagrant || true
vagrant box remove ubuntu || true
vagrant box remove debian12 || true

# Build vbox image
packer init .
packer build -on-error=ask -only=virtualbox-iso.ubuntu-2204 .
vagrant box add --name ubuntu Ubuntu-2204-Vagrant-virtualbox.x86_64.box
vagrant init ubuntu
packer build -on-error=ask -only=virtualbox-iso.debian-12 .
vagrant box add --name ubuntu Debian-12-Vagrant-virtualbox.x86_64.box
vagrant init debian12
vagrant up
2 changes: 2 additions & 0 deletions ubuntu2204-vagrant.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ source "virtualbox-iso" "ubuntu-2204" {
ssh_timeout = var.ssh_timeout
boot_command = local.ubuntu_vagrant_boot_command_2204_x86_64
boot_wait = var.boot_wait
firmware = "efi"
disk_size = var.vagrant_disk_size
guest_os_type = "Ubuntu_64"
cpus = var.cpus
memory = var.memory
headless = var.headless
gfx_efi_resolution = "1280x720"
hard_drive_interface = "sata"
iso_interface = "sata"
vboxmanage = [["modifyvm", "{{.Name}}", "--nat-localhostreachable1", "on"]]
Expand Down
10 changes: 6 additions & 4 deletions variables.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,19 @@ local "ubuntu_vagrant_boot_command_2204_x86_64" {
]
}

# https://forums.virtualbox.org/viewtopic.php?t=110897
local "debian_vagrant_boot_command_12_x86_64" {
expression = [
"<wait><wait><wait><esc><wait><wait><wait>",
"/install.amd/vmlinuz ",
"initrd=/install.amd/initrd.gz ",
"<wait>c<wait>",
"linux /install.amd/vmlinuz ",
"auto=true ",
"url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/debian-12-vagrant-x86_64.preseed ",
"hostname=debian12 ",
"domain='' ",
"interface=auto ",
"vga=788 noprompt quiet --<enter>"
"vga=788 noprompt fb=false quiet --<enter>",
"initrd /install.amd/initrd.gz<enter>",
"boot<enter>"
]
}

Expand Down

0 comments on commit 60d03df

Please sign in to comment.