User Tools

Site Tools


computing:preseed

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
computing:preseed [2024/02/17 17:52] oemb1905computing:preseed [2024/02/17 18:01] (current) oemb1905
Line 11: Line 11:
 ------------------------------------------- -------------------------------------------
  
-I created my own virtualization stack which is complete with version control, file backups, full image backups and moreAdditionally, because my client base and use-case does not require that I spin up VMs too oftenit was very easy to just keep a few VMs pre-configured generically and then virt-clone them upon need and then tweak a few settingsHowevermy use-cases and needs are expanding and so I wanted to be able to spin up a new VM with a shell script and have a super minimal and clean copy of Debian installed on it, with absolutely no network configuration, extra packages, etcSoI decided to dig deeper into both qemu and libvirt to see if there was something that could be developed. After working on qemu options for a bit, I decided that libvirt fit my needs better. After studying forums, I saw that Debian had an "auto-installer" feature and that you could pass configs to it through virsh by adding a few xml lines. After a little trial and error with using a remote site for the config vs. localhost, I developed the following recipe:+I created my own [[https://wiki.haacksnetworking.org/doku.php?id=computing:vmserver|virtualization stack]] about two and a half years agoAs I expanded and needed to spin up VMs, my first strategy was to create model VMs that fit particular use cases and then ''virt-clone'' those and then adapt to the new use caseOver timethis became cumbersome, and I started having use-cases that did not fit the templatesFor this reasonit came to time to automate fresh Debian installs on new VMs. After studying forums, I saw that Debian had an "auto-installer" feature and that you could pass configs to it through virsh by adding a few xml lines. After a little trial and error with using a remote site for the config vs. localhost, I learned that you could pass the preseed config file to virsh with the last line in this block:
  
   virt-install --name=domain.org.qcow2 \   virt-install --name=domain.org.qcow2 \
Line 24: Line 24:
    --initrd-inject /mnt/vms/cfgs/preseed.cfg    --initrd-inject /mnt/vms/cfgs/preseed.cfg
  
-Other resources online insisted that I needed to add something like --extra-args="ks=file:/mnt/vms/cfgs/preseed.cfg console=tty0 console=ttyS0,115200" to the recipe as well, but I found that was unnecessary through trial and error. I think that syntax is required for those desiring kickstarter and/or if they are not using standard X passthrough for the shellI'm not sure though. After I got the installer to recognize configuration file, I then began making a list as to which options worked automatically and which did not. One by one, I checked the stock configuration file here and adjusted my config until everything workedBelow, I've linked the stock configuration file I used as a jumping off point, and the one I developed for my use-case.+Other resources online insisted that I needed to add something like --extra-args="ks=file:/mnt/vms/cfgs/preseed.cfg console=tty0 console=ttyS0,115200" to the recipe as well, but I found that that was only required for those desiring kickstarter and/or if they are using a remote site to host the configs fromMy next task was to check the stock configuration file and create my own preseed config that would create machines as I desiredHere'the stock Debian config and the one I developed:
  
   * [[https://www.debian.org/releases/stable/example-preseed.txt|Stock Configuration]]   * [[https://www.debian.org/releases/stable/example-preseed.txt|Stock Configuration]]
   * [[https://repo.haacksnetworking.org/haacknet/haackingclub/-/blob/main/scripts/preseeds/external/preseed.cfg?ref_type=heads|My Use-Case]]   * [[https://repo.haacksnetworking.org/haacknet/haackingclub/-/blob/main/scripts/preseeds/external/preseed.cfg?ref_type=heads|My Use-Case]]
  
-After getting the virt-install recipe and config to perform the desired Debian install, my next task was to automate all of this with a simple script that would create a virtual hard disk of any desired size and a libvirt entry with my desired naming convention in my production VM directory. Here's what I came up with:+My next task was to automate all of this with a simple shell script. Here's what I came up with:
  
   #!/bin/bash   #!/bin/bash
Line 62: Line 62:
    --initrd-inject /mnt/vms/cfgs/external/${hostname}/preseed.cfg    --initrd-inject /mnt/vms/cfgs/external/${hostname}/preseed.cfg
  
-For now, I just need really simple Debian VMs as quickly as possibleHowever, as wrote this, I began to realize that I could easily expand this script to meet the needs of a variety of different use cases, could add conditionals to it, validation and more. Down the road, I plan to do that, and you can stay up to date with how I expand this script's functionality on the Hacking Club repository:+This script prompts me for domain name and size of the virtual hard disk. I will likely expand the script to add more parameters down the road, such as but not exclusive to networking, vdd location, ram, and so on. As I expand this, I will update the wiki here and also push my latest scripts and configs to the repository:
  
   * [[https://repo.haacksnetworking.org/haacknet/haackingclub/-/tree/main/scripts/preseeds?ref_type=heads|Preseed Project]]   * [[https://repo.haacksnetworking.org/haacknet/haackingclub/-/tree/main/scripts/preseeds?ref_type=heads|Preseed Project]]
  
- --- //[[jonathan@haacksnetworking.org|oemb1905]] 2024/02/17 17:42//+ --- //[[jonathan@haacksnetworking.org|oemb1905]] 2024/02/17 17:53//
computing/preseed.txt · Last modified: 2024/02/17 18:01 by oemb1905