!kyXJonZuBXCGzVwuSn:nixos.org

Systems Programming

175 Members
Kernel, stdenv, low-level hacking, patchelf, … 62 Servers

Load older messages


SenderMessageTime
29 May 2024
@netpleb:matrix.orgnetpleb joined the room.15:57:20
@netpleb:matrix.orgnetplebis this an ok place to ask about how pivot_root works in the context of nixos?15:59:47
@netpleb:matrix.orgnetpleb For educational purposes I followed this https://lord.re/en/posts/58-pivot_root-unmount-son-root/ and was able to get all the way through the pivot_root step, but after that all the commands I need (such as mount, and even ls, are missing). 16:01:40
@k900:0upti.meK900That is expected, yes16:07:04
@aloisw:kde.org@aloisw:kde.orgYou just made your entire Nix store unavailable, so no wonder nothing will be found any more.16:07:11
@k900:0upti.meK900You have not run the activation scripts16:07:12
@netpleb:matrix.orgnetpleb I think what I am missing is that I need to have a /ramroot/nix and /ramroot/nix/store, but how do I make sure that /ramroot/nix/store is only populated with the stuff I need? Can I, for example, some how pivot_root into a minimal nixos config such as the installer? 16:07:14
@k900:0upti.meK900Or anything like that16:07:14
@netpleb:matrix.orgnetplebYes, sorry, I am new to all of this. So after pivot_root, I need to run activation scripts it seems? But how do I keep the /ramroot/nix/store as small as possible?16:08:16
@aloisw:kde.org@aloisw:kde.org You can try nix copy to populate the Nix store in /ramroot with what you want. 16:09:14
@netpleb:matrix.orgnetpleb
In reply to @aloisw:kde.org
You can try nix copy to populate the Nix store in /ramroot with what you want.
Ok, that is exactly what I was thinking too. So I could find, for example nix copy the nixos installer somehow and, in theory, all the stuff I would need (and none of the stuff I do not) will make it over?
16:10:38
@netpleb:matrix.orgnetplebOr maybe better to copy over a config, not necessarily the installer config, which is minimal but has what I need (and has ssh running).16:12:12
@netpleb:matrix.orgnetpleb so after the "pivot root" step, if I did it all correctly (and say I am doing it over ssh), I should be able to systemctl restart sshd.service and login with a new session, and close my old one, right? 16:14:03
@netpleb:matrix.orgnetplebit's just fascinating that it even works at all...never experienced this low level magic of linux before 16:14:37
@aloisw:kde.org@aloisw:kde.org Well, whatever configuration you need. By the way, I'd recommend to do your experiments in a shell created by unshare -m so you don't mess up your main system. 16:15:01
@netpleb:matrix.orgnetpleb so long as /run is remounted properly to the new root, then things like systemctl restart ssshd.service should work, right? or is that where you are saying I need to run some activation scripts (I have never manually run any activation scripts before, so that is very new to me) 16:17:19
@netpleb:matrix.orgnetpleb * so long as /run is remounted properly to the new root, then things like systemctl restart ssshd.service should work, right? or is that where you are saying I need to run some activation scripts? (I have never manually run any activation scripts before, so that is very new to me) 16:17:26
@netpleb:matrix.orgnetpleb * so long as /run is remounted properly to the new root, then things like systemctl restart ssshd.service should work, right? or is that where you are saying I need to run some activation scripts first? (I have never manually run any activation scripts before, so that is very new to me) 16:17:58
@netpleb:matrix.orgnetpleb * Thanks so much for your help. So long as /run is remounted properly to the new root, then things like systemctl restart ssshd.service should work, right? or is that where you are saying I need to run some activation scripts first? (I have never manually run any activation scripts before, so that is very new to me) 16:18:14
@raitobezarius:matrix.orgraitobezarius changed their display name from raitobezarius to raitobezarius (DECT: 7248).17:08:28
30 May 2024
@netpleb:matrix.orgnetpleb so, long story short, I was able to follow the instructions for booting-via-kexec and then ssh'd into the machine which (now) has nixos running entirely in memory. Then I was able to make various changes to the file system, including converting to btrfs (because why not? -- this is all for education at the moment), but now I am stuck. 23:18:59
@netpleb:matrix.orgnetpleb usually when I change configuration for this system, I do so from my laptop/build system and run nixos-rebuild switch --flake .#<hostname> --target-host root@<target_ip>, but I don't think that will work properly now because the "system" has been hijacked (by me) using kexec. 23:21:41
@netpleb:matrix.orgnetpleb * usually when I change configuration for this target machine, I do so from my laptop/build machine and run nixos-rebuild switch --flake .#<hostname> --target-host root@<target_ip>, but I don't think that will work properly now because the target has been hijacked (by me) using kexec. 23:22:15
@netpleb:matrix.orgnetplebI updated the flake configuration for the target machine to reflect the changes to the file system, but when I then tried to deploy using the above command I got an "out of space" error -- which makes sense because the target machine is still running just an in-ram version of nixos. I know at least one of you has a trick up your sleeve which would get me out of this pickle.23:26:17
@netpleb:matrix.orgnetpleb right now in the target system, the only thing mounted is loop0 with mountpoint of /nix/.ro-store. Can I safely unmount that and mount the root and boot partitions and then run the nixos-rebuild switch ... comand from the build system? 23:31:07
31 May 2024
@netpleb:matrix.orgnetpleb * I updated the flake configuration for the target machine to reflect the changes to the file system, but when I then tried to deploy using the above command I got an "out of space" error -- which makes sense because the target machine is still running just an in-ram version of nixos. I hope at least one of you has a trick up your sleeve which would get me out of this pickle?03:03:07
@netpleb:matrix.orgnetpleb
In reply to @netpleb:matrix.org
right now in the target system, the only thing mounted is loop0 with mountpoint of /nix/.ro-store. Can I safely unmount that and mount the root and boot partitions and then run the nixos-rebuild switch ... comand from the build system?
Turns out that I was able to finally succeed. After kexec'ing into a simplified in-memory nixos, I was able to do the conversion to btrfs no problem. Then just followed the instructions in the manual to mount the old (but now converted) system into /mnt and do a nixos-install. Then, once that was completed, I was able to close the ssh connection and from my build machine do the nixos-rebuild switch ... to get things back operational.
17:03:39
@netpleb:matrix.orgnetpleb
In reply to @netpleb:matrix.org
right now in the target system, the only thing mounted is loop0 with mountpoint of /nix/.ro-store. Can I safely unmount that and mount the root and boot partitions and then run the nixos-rebuild switch ... comand from the build system?
* Turns out that I was able to finally succeed. After kexec'ing into a simplified in-memory nixos, I was able to do the conversion to btrfs no problem. Then just followed the instructions in the manual to mount the old (but now converted) system into /mnt and do a nixos-install. Then, once that was completed, I was able to close the ssh connection and from my build machine do the nixos-rebuild switch ... to get things back operational. The primary issue I ran into when doing all of this was some weird errors when running nixos-install which had to do with some sort of conflict between my (pre-existing) nix store at /mnt/nix/store. I finally just deleted it and let nixos-install rebuild it from scratch and all worked fine.
17:05:32
2 Jun 2024
@linus:schreibt.jetzt@linus:schreibt.jetzt Is there a good way to "just mount a whole system at a different root"? I'm using mount -T $fstab --target-prefix /mnt / followed by mount -T $fstab --target-prefix /mnt --all, which works alright for some cases, but breaks on bind mounts since those are still resolved in the host system's root and not the target prefix... 14:27:48
@linus:schreibt.jetzt@linus:schreibt.jetztalso, how can a process in the zombie state still be using CPU??16:53:24

Show newer messages


Back to Room ListRoom Version: 6