mobile-nixos icon indicating copy to clipboard operation
mobile-nixos copied to clipboard

AutoResize runs on every boot

Open Thra11 opened this issue 5 years ago • 6 comments

Looking into it, I think this might actually be user error on my part. AutoResize runs on every boot, not just the first boot:

I, [2020-09-19T10:58:02.000136 #1]  INFO -- : Running Tasks::UDev...
Starting version 246
I, [2020-09-19T10:58:02.614037 #1]  INFO -- : Running Tasks::AutoResize...
I, [2020-09-19T10:58:02.614225 #1]  INFO -- : Resizing /dev/disk/by-label/NIXOS_SYSTEM...

I suspect this is because I'm importing <mobile-nixos/lib/configuration.nix>, and modules/rootfs.nix sets

  fileSystems = {
    "/" = lib.mkDefault {
      device = "/dev/disk/by-label/${rootfsLabel}";
      fsType = "ext4";
      autoResize = true;
    };
  };

It's different to nixpkgs, in that mobile-nixos' resize isn't guarded by the check for /nix-path-registration. Not sure if autoResize should magically turn off after the first boot, or if it's just up to the user to override it in their configuration.

Thra11 avatar Sep 19 '20 11:09 Thra11

Hmmm. Is this another setting which requires a boot-partition reflash to change?

Thra11 avatar Sep 19 '20 11:09 Thra11

Hmmm. Is this another setting which requires a boot-partition reflash to change?

What does this question mean? If you change this setting and do a nixos-rebuild, it should apply. However, if you don't have /boot mounted, then your boot menu won't be updated with the new generation, and so you'll just keep (re)booting old generations.

colemickens avatar Sep 19 '20 17:09 colemickens

See samueldr's reply to me here https://logs.nix.samueldr.com/nixos-aarch64/2020-09-18#3996885. I was asking about boot.kernelParams in that case, but was told to reflash the boot partition: when it didn't update, I assumed this might be similar. Not sure if mounting it on /boot during nixos-rebuild would do anything. Surely if it was going to write anything to /boot, it would end up writing it there regardless, even if it's just a directory (unless it actually checks whether /boot is a mounted partition?).

Thra11 avatar Sep 19 '20 17:09 Thra11

Yes, the option requires a rebuild of the boot partition.

This is one of those "loose ends", which I know there is a problem, but it's a low enough priority that at the current point in development it is only a (slow due to fsck) no-op.

I don't know where to go exactly from here. Probably the actual solution is not to ever have that in the boot phase, but rather have that be done as part of an "installation" step. Always note that the limitations of the more limited platforms are what guide the decisions.

samueldr avatar Sep 19 '20 18:09 samueldr

And about the "boot partition" which on the Pinephone turns our to be an ext4 partition should be treated as an implementation detail for the Mobile NixOS design.

What I mean here is that we cannot assume that on all devices targeted we can control the boot partition as discrete files. Most of them require an outright replacement of a "blackboxed" blob. Thus, for those platforms where we could do that, we still do the dumb thing of treating them as a "blackboxed" blob. This way the platforms are dumbed-down to the simplest level.

But! That doesn't stop an enterprising individual to produce an alternative method to boot. Mobile NixOS is not an absolute truth. It is only a specific opinion about making an abstraction over a diverse ecosystem of (most of the time) limited platforms.

For the Pinephone, it's simply a standard U-Boot-based AArch64 system. The Pinephone gains almost nothing from using Mobile NixOS over the usual U-Boot approach. The main thing it gains is the (limited) graphical boot menu, until U-Boot ends up having one.

Anything unclear you want me to elaborate on? I don't think it's been documented, so I'm sure there's more to be learned.

samueldr avatar Sep 19 '20 18:09 samueldr

I just did some more exploration about the topic, since I kinda need partition resize.

NixOS has different conflicting mechanisms for resizing the filesystem.

The one used here matches the implementation of autoResize 1:1 [for ext4]

  • https://github.com/NixOS/nixpkgs/blob/8527fb88b57d190d1e341c25d4c2e30d17e163a2/nixos/modules/system/boot/stage-1-init.sh#L367-L381

The other one being discussed gated behind nix-path-registration is a different one written from the sd image profile only:

  • https://github.com/NixOS/nixpkgs/blob/8527fb88b57d190d1e341c25d4c2e30d17e163a2/nixos/modules/installer/sd-card/sd-image.nix#L257-L260

samueldr avatar Oct 16 '22 21:10 samueldr