Installing from Linux: Difference between revisions

imported>Chuangzhu
Chroot doesn't work for now, use pivot_root
imported>Chuangzhu
Remove template outdated
Line 1: Line 1:
{{outdated|The instructions have not been reviewed and confirmed to work for some time.}}
You already have a running linux with GRUB on your primary partition and you don't want to waste a CD-R?
You already have a running linux with GRUB on your primary partition and you don't want to waste a CD-R?
Right. We also assume that you have a spare partition where to install NixOS ready.
Right. We also assume that you have a spare partition where to install NixOS ready.
Line 28: Line 26:
# cd ~
# cd ~
# mkdir -p inst host/nix
# mkdir -p inst host/nix
# wget https://d3g5gsiof5omrk.cloudfront.net/nixos/17.03/nixos-17.03.1449.2e983f14f6/nixos-minimal-17.03.1449.2e983f14f6-x86_64-linux.iso
# wget https://channels.nixos.org/nixos-21.05/latest-nixos-minimal-x86_64-linux.iso
# modprobe loop
# modprobe loop
# mount -o loop nixos-minimal-17.03.1449.2e983f14f6-x86_64-linux.iso inst
# mount -o loop latest-nixos-minimal-x86_64-linux.iso inst
# unsquashfs -d host/nix/store inst/nix-store.squashfs '*'
# unsquashfs -d host/nix/store inst/nix-store.squashfs '*'
</syntaxhighlight>
</syntaxhighlight>
Line 65: Line 63:
Now we are able to chroot into the NixOS system used for installation. ''You may get several warnings and errors, but you can safely ignore them unless they are fatal.'' If you're installing from Arch, you may need to remove the mount call that tries to make / private in the same init script.
Now we are able to chroot into the NixOS system used for installation. ''You may get several warnings and errors, but you can safely ignore them unless they are fatal.'' If you're installing from Arch, you may need to remove the mount call that tries to make / private in the same init script.
<syntaxhighlight lang="console">
<syntaxhighlight lang="console">
# chroot . /$INIT
# mkdir old_root
# mount --make-rprivate /
# pivot_root . old_root
# $INIT
</syntaxhighlight>
</syntaxhighlight>
'''Further commands to be executed in the chrooted environment will be prefixed with "# (chroot)"'''.
'''Further commands to be executed in the chrooted environment will be prefixed with "# (chroot)"'''.
Line 78: Line 79:
Before executing nixos-install you might want to run nixos-checkout to obtain the most recent version of packages to be installed into your NixOS system. You might need to copy /etc/resolv.conf from the host to the target system.  
Before executing nixos-install you might want to run nixos-checkout to obtain the most recent version of packages to be installed into your NixOS system. You might need to copy /etc/resolv.conf from the host to the target system.  
<syntaxhighlight lang="console">
<syntaxhighlight lang="console">
# (chroot) nixos-checkout
# (chroot) NIX_PATH="nixpkgs=channel:nixos-21.05" nixos-install
# (chroot) nixos-install
</syntaxhighlight>
</syntaxhighlight>