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

Configurable boot and swap partitions #112

Open
asgeirn opened this issue Mar 24, 2024 · 3 comments
Open

Configurable boot and swap partitions #112

asgeirn opened this issue Mar 24, 2024 · 3 comments

Comments

@asgeirn
Copy link

asgeirn commented Mar 24, 2024

I've been running various versions of the 23.11 AMIs on t4g.micro instances and struggle with two issues:

  • /boot fills up after a while due to the number of kernels
  • Instance crashes in the midst of nixos-rebuild due to out of memory (micro has 1GB)

So: Would it be possible to specify the /boot partition size, as well as adding a swap partition?

The second can of course be worked around by adding a swap file (which I did) or adding a second EBS and partition it as swap.

@arianvp
Copy link
Member

arianvp commented Mar 24, 2024

How i've been personally tackling deploying to t4g.micro is by doing the evaluation and building outside of the instance. And have the instance pull the build on startup.

Instead of setting the user data to a nix configuration: that is built locally on the instance; I set the user data to a shell script that downloads the already built nixos configuration:
e.g. set the user data of the instance to:

  user_data = base64encode(<<-EOF
  #!/usr/bin/env bash
  set -e
  nix build '${var.nix_store_path}' \
    --profile /nix/var/nix/profiles/system \
    --experimental-features 'nix-command' \
    --extra-substituters '${local.nix_substituter}' \
    --extra-trusted-public-keys '${local.nix_trusted_public_key}'
  /nix/var/nix/profiles/system/bin/switch-to-configuration switch
  EOF
  )

And in CI:

nix copy --to my-cache .#nixosConfigurations.myserver.config.system.build.toplevel

Or if you're doing push based deploys:

nixos-rebuild switch --target-host  <the-ip-of-the-instance>

@arianvp
Copy link
Member

arianvp commented Mar 24, 2024

For the /boot problem I think we can try to make the /boot partition a bit larger. I'll look into it.

@asgeirn
Copy link
Author

asgeirn commented Mar 27, 2024

I was completely oblivious to the fact that you can remotely build configurations, I'll definitely look into this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants