nix-community / disko

Declarative disk partitioning and formatting using nix [maintainers=@Lassulus @Enzime @iFreilicht]
MIT License
1.88k stars 200 forks source link

Generate an .iso unattended install image #606

Open bam80 opened 7 months ago

bam80 commented 7 months ago

Could we produce a solution for unattended install?

Lassulus commented 7 months ago

yes, there a multiple solutions. like a modification of https://github.com/nix-community/disko/blob/master/docs/disko-install.md#using-disko-install-in-an-offline-installer or https://github.com/nix-community/nixos-anywhere

bam80 commented 7 months ago

Thanks.

Few questions:

nixos-discourse commented 7 months ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/cloud-init-unattended-install/39149/5

bam80 commented 7 months ago

Any help?

Mic92 commented 7 months ago

Can you please clarify what you mean by unattended installer? The code here does install NixOS onto a system when the installer is booted: https://github.com/nix-community/disko/blob/master/docs/disko-install.md#using-disko-install-in-an-offline-installer

bam80 commented 7 months ago

OK, as I mentioned above, I do not quite understand how to exactly use these code snippets. It also was other question, could you look? https://github.com/nix-community/disko/issues/606#issuecomment-2067365962

Mic92 commented 7 months ago

You include those in a configuration that generates an image i.e. using nixos-generators: https://github.com/nix-community/nixos-generators?tab=readme-ov-file#supported-formats

bam80 commented 7 months ago

Sorry, it's still not clear to me how to embed that snippets. Could you provide complete files please, not just snippets? And the commands to run after.

Please note I don't have Nix/NixOS yet.

bam80 commented 7 months ago

You include those in a configuration that generates an image i.e. using nixos-generators: https://github.com/nix-community/nixos-generators?tab=readme-ov-file#supported-formats

@Mic92 so I installed Nix package manager to the system. But further steps are unclear to me.

I would be appreciate for your support.

cowboyai commented 6 months ago

I have "a" solution to this... it's still a bit hacky, but everything is building, it's just not booting. https://github.com/cowboyai/cim-start/blob/main/vhosts/x86/readme.md that builds an x86 system with libvirtd and specifically with 2 nvme drives and loads 3 containers. it builds correctly and deploys properly, then hangs at reboot because it won't load the disko config. it is specified here: https://github.com/cowboyai/cim-start/blob/main/vhosts/x86/vhost-dev/configuration.nix I have tried every attempt I have seen documented and cannot get the bootloader to configure correctly. The ISO works fine... create the ISO, boot the system... I have to usually restart wpa_supplicant and then install.service once I have an IP. then the system auto-builds correctly, exits disko-install correctly with no errors. on reboot, it hangs ALWAYS waiting for /dev/disk/by-partlabel/disk-sys-nixos rebooting into the ISO and getting a console reveals lsblk to show nvme0n1 does indeed contain two partitions, nvme0n1p1: disk-sys-boot nvme0n1p2: disk-sys-nixos nvme1n1p1: disk-data-data

cowboyai commented 6 months ago

![Uploading 20240502_091147.jpg…]()

bam80 commented 6 months ago

on reboot, it hangs ALWAYS waiting for /dev/disk/by-partlabel/disk-sys-nixos rebooting into the ISO and getting a console reveals lsblk to show nvme0n1 does indeed contain two partitions, nvme0n1p1: disk-sys-boot nvme0n1p2: disk-sys-nixos nvme1n1p1: disk-data-data

My efforts are still ongoing, but seems I passed the stage you stuck on, see: https://github.com/nix-community/disko/issues/613#issuecomment-2079307891

cowboyai commented 6 months ago

for auto-installation, I am using a systemd service that runs when the iso boots... https://github.com/cowboyai/cim-start/blob/main/vhosts/x86/builder.nix this is all working perfectly until reboot and then mounts all fail. I just don't see anywhere in the docs or the code that says I have to explicitly tell it to load something in the bootloader, in fact it specifically says NOT to and that utterly fails on grub... to even get grub to try to boot it needs grub.boot.device = ["some partition"]... ["nodev"] always fails on grub. systemd seems to work, but fails to mount root onto "/". I cannot see what is getting written to initrd so I can't tell if it is passing something incorrectly or not.

cowboyai commented 6 months ago

WhatsApp Image 2024-05-02 at 9 28 44 AM

bam80 commented 6 months ago

WFIW, for my configuration I linked above, I had to pass OVMF firmware file to Qemu (for UEFI to work), and it uses systemd-boot. I was able to boot the installed system then.

cowboyai commented 6 months ago

I don't see a link to your config for that... I will need to do some of that later like: boot.initrd.kernelModules = [ "vfio" "vfio_iommu_type1" "vfio_pci" "vfio_virqfd" ]; so I can pass through a GPU. but that shouldn't be needed to get the boot to work.

bam80 commented 6 months ago

I don't see a link to your config for that...

The config is embedded in the linked flake:

https://github.com/nix-community/disko/issues/613#issuecomment-2079307891

No more configs were used, search net for how to run Qemu with UEFI.

misuzu commented 3 months ago

This is how I did it: https://gitlab.com/misuzu/nixos-unattended-install-iso

ibizaman commented 3 months ago

And this is how I did it https://github.com/ibizaman/skarabox

iFreilicht commented 1 month ago

Linking to these examples might already be a win wrt the discoverability of this.