Fully automated UEFI-based O/S installation (Debian 10)


  • Hi all,

    First newbie post.

    I’ve managed to automate the installation of Debian 10 using FOG and the netboot installer on a UEFI system. I haven’t found complete documentation on this, so here are some notes on how I achieved this. I would love it if this process could be improved on. Is there a “FOGgier” way to do some of the hackier things?

    Disclaimer: I have only been using FOG for a few days!

    1. Unpack netboot.tar.gz into the TFTP server root (/tftpboot).

    2. Create a symbolic (must be relative, not absolute) to the UEFI kernel:

    cd /tftpboot
    ln -s debian-installer/amd64/grubx64.efi .
    
    1. Edit /tftpboot/debian-installer/amd64/grub/grub.cfg, adding the following before the first menuentry block:
    set default="autoinstall"
    set timeout=5
    menuentry "Fully automated installation" --id autoinstall {
         set background_color=black
         linux    /debian-installer/amd64/linux auto=true url=http://${pxe_default_server}/os/autoinstall/debian-10/preseed.cfg hostname=debian-10 domain=local interface=auto vga=788 noprompt --- quiet
         initrd   /debian-installer/amd64/initrd.gz
    }
    
    1. Create a preseed file and place it on the FOG webserver at /var/www/html/os/autoinstall/debian-10/preseed.cfg. (Double-check that path - I relocated my os/ directory and forget where it was originally! Think that’s right though.)

    2. Create a new iPXE Menu Entry:

    Menu item: os.Debian.10.7.UEFI
    Description: Install Debian 10.7 (UEFI)
    Parameters:
    kernel tftp://${fog-ip}/grubx64.efi
    boot || goto MENU
    Menu Show with: All hosts

    That’s all, I think. This is PXE booting for me perfectly. When I choose the FOG menu entry “Install Debian 10.7 (UEFI)” it loads the kernel/grub menu, waits 5 seconds and then performs a completely unattended installation (and finally reboots).

    What could be improved
    I’d rather not place the files exactly where there are in the /tftpboot folder. That approach is asking for trouble - one day I overwrite them with some other distro’s files… But grubx64.efi seems to have some hard-coded files it looks for, so I’m not sure where else to place them. Possibly there are some parameters i can use on the kernel line? Not sure.

    Also, how might this approach be generalised for other operating systems?

    Suggestions welcome!


  • @george1421 Done. 👍

  • Moderator

    @robpomeroy said in Fully automated UEFI-based O/S installation (Debian 10):

    I’m more than willing to write this up somewhere if useful for others

    Tutorials in the tutorial forum section is always appreciated. No one knows the entire IT picture so your work covers areas where others have not been. That is kind of why I started that huge tutorial on network booting, to give others a platform to start their projects with.



  • Yep, HTTP worked perfectly too, which means I could put the three required files in a single location under the web root. FOG menu parameters:

    kernel http://${fog-ip}/os/autoinstall/debian-10/debian-installer/amd64/linux auto=true url=http://${fog-ip}/os/autoinstall/debian-10/preseed.cfg interface=auto hostname=debian-10 domain=local initrd=initrd.gz vga=788 noprompt quiet
    imgfetch http://${fog-ip}/os/autoinstall/debian-10/debian-installer/amd64/initrd.gz
    boot || goto MENU
    

    This is clean & efficient. I like it. Probably not as quick as using a Live image, but I’m doing this over a fast internet connection and it’s a minimal install. So the whole thing is done in ten minutes or so.

    Again, I’m more than willing to write this up somewhere if useful for others.


  • @george1421 George, firstly thanks again for the all the work you’ve put into this!

    This steered me in exactly the right direction. The following are the parameters I used for a completely automated netboot install (no Live ISO required). This is the point I was hoping to get to. Brilliant.

    kernel tftp://${fog-ip}/debian-installer/amd64/linux auto=true url=http://${fog-ip}/os/autoinstall/debian-10/preseed.cfg interface=auto hostname=debian-10 domain=local initrd=initrd.gz vga=788 noprompt quiet
    imgfetch tftp://${fog-ip}/debian-installer/amd64/initrd.gz
    boot || goto MENU
    

    So this removes the need to mess around with grub.cfg or boot to an intermediate (grub) menu. All you need are the netboot.tar.gz files and a preseed.cfg. Next I’ll try doing this all via HTTP (rather than TFTP), to avoid polluting /tftpboot. I’m mindful that I would like to make the backup and restoration of FOG itself as straightforward as possible.

    I know I’ve said this a few times in this thread (!) but once more: thank you. If I can help by writing up a wiki page for this process, do point me in the right direction.

  • Moderator

    @robpomeroy Well I have a workable solution.

    kernel tftp://${fog-ip}/os/debian/Server10.7/linux loglevel=7 initrd=initrd.gz root=/dev/nfs boot=casper netboot=nfs nfsroot=${fog-ip}:/images/os/debian/Server10.7/ locale=en_US.UTF-8 keyboard-configuration/layoutcode=us quiet splash ip=dhcp rw
    imgfetch tftp://${fog-ip}/os/debian/Server10.7/initrd.gz
    boot || goto MENU
    

    After several itterations of try this, crash that… I found that the image args was missing this initrd=initrd.gz. Understand I did not push the installer past configuring the keyboard. But the kernel now boots. You will probably need to add in the link to the preseed file auto=true url=http://${fog-ip}/os/autoinstall/debian-10/preseed.cfg and anything else you want configured via image args.


  • @george1421 - okay, thanks George.

    This boots beautifully though:

    kernel tftp://${fog-ip}/grubx64.efi
    boot || goto MENU
    

    Is there no way to squirt additional parameters into that Grub EFI loader?

    Sorry - I figured that this might be simple. I should know better by now! 😂

  • Moderator

    @robpomeroy Ok so next plan I was going to try is to grab FOG’s bzImage from /var/www/html/fog/service/ipxe That is EFI capable I was thinking about sliding that in and replacing the “linux” kernel just to see if it would init the disk. Let me see what I can do on vmware I should be able to duplicate the error I was seeing in my home lab.


  • @george1421 It’s a physical server (Dell T40) that literally cannot boot BIOS-based OSes, I’m afraid. It has no internal legacy boot capability. I was amazed, but then I haven’t worked with physical hardware in a while.

  • Moderator

    @robpomeroy Switch the VM to bios and try it (just to test). I was having that issue with efi on proxmox. I thought it was just being proxmox being silly. Maybe not.

    The error is basically the kernel doesn’t understand the format of the virtual disk drive (initrd).


  • @george1421 - Thanks George. My problem is understanding all the options!

    Following your latest instructions unfortunately results in a kernel panic (presumably initram related?). The kernel and init disk both transferred correctly via TFTP. Incompatibility with UEFI perhaps?

    0e14b72c-a686-44ff-b804-16d972fa12eb-image.png

  • Moderator

    @robpomeroy Yes I have use tftp, http/https, nfs. The use of tftp was a conscious decision to keep the instructions consistent throughout the article. One of the issues is the http document root varies depending on the linux distribution.

    From a performance standpoint for the kernel and the initrd tftp transfer is fast enough, for the live boot OS’ its better to use http transfer because the squashfs files are usually several hundred MB in size.

    Actually looking at the tutorial for debian 10 server, the files are shared with the pxe booting computer over NFS, so the only thing transferred via tftp is just the kernel and init.

    imgargs linux root=/dev/nfs boot=casper netboot=nfs nfsroot=${fog-ip}:/images/os/debian/Server10.7/ locale=en_US.UTF-8 keyboard-configuration/layoutcode=us quiet splash ip=dhcp rw
    

    I guess the point here is there is no bad way to go about it. Whatever works for your environment is the right choice. FOG just give you the options to use whatever you need to get the job done.


  • kernel tftp://${fog-ip}/os/debian/Server10.7/linux
    initrd tftp://${fog-ip}/os/debian/Server10.7/initrd.gz
    

    Have you tried leaning on IPXE’s HTTP support here rather than TFTP? I’m just wondering if that would make it cleaner (keeping all installer files in one location under the web root).


  • @george1421 said in Fully automated UEFI-based O/S installation (Debian 10):

    @robpomeroy With the exception of testing the preceed file these instructions work as advertized: https://forums.fogproject.org/post/140720

    On UEFI? I’ll try that now! Thanks.

  • Moderator

    @robpomeroy With the exception of testing the preceed file these instructions work as advertized: https://forums.fogproject.org/post/140720

  • Moderator

    @robpomeroy said in Fully automated UEFI-based O/S installation (Debian 10):

    I did try an approach along these lines, but without any success,

    What were your results? Did you confirm that you can download the preseed file with a standard browser?


  • @george1421 - I took a lot of inspiration from that whole post of yours; you’ve clearly done a lot of work in this area, so thank you for that. In my approach, I wanted to achieve this using the lightweight network installer for Debian, rather than a Live CD/filesystem.squashfs approach.

    So this:

    kernel tftp://${fog-ip}/os/debian/Server10.7/linux
    initrd tftp://${fog-ip}/os/debian/Server10.7/initrd.gz
    imgargs linux auto=true url=http://${fog-ip}/os/autoinstall/debian-10/preseed.cfg hostname=debian-10 domain=local interface=auto vga=788 noprompt --- quiet
    boot || goto MENU
    

    …is closer to what I’d hope to achieve. I did try an approach along these lines, but without any success, hence resorting to the grub method. I’ll give it another try - thanks!


  • This post is deleted!
  • Moderator

    @robpomeroy said in Fully automated UEFI-based O/S installation (Debian 10):

    But grubx64.efi seems to have some hard-coded files it looks for, so I’m not sure where else to place them.

    Also be aware there are different flavors of grub. There is grubx64.efi and grubnetx64.efi depending on the distro where you get them from some distros don’t add networking support to grubx64.efi so it can only reference local storage.

    You can pxe boot with grub in the case of grub (grubnetx64.efi) from ubuntu’s repo on your tftp server create a grub directory mkdir -p /tftpboot/grub and place your grub.cfg file in there. That is hard coded into the grub binary as you noted.

385
Online

8.5k
Users

15.3k
Topics

143.4k
Posts