2nd chunk of `nixos/doc/manual/installation/installing-from-other-distro.section.md`
c9c630538cdc7c36c0f0da5b47d99ec300158a72cb66777d0000000100000fcb
using GRUB and your existing distribution is running Ubuntu, you may
want to add something like this to your `configuration.nix`:
```nix
{
boot.loader.grub.extraEntries = ''
menuentry "Ubuntu" {
search --set=ubuntu --fs-uuid 3cc3e652-0c1f-4800-8451-033754f68e6e
configfile "($ubuntu)/boot/grub/grub.cfg"
}
'';
}
```
(You can find the appropriate UUID for your partition in
`/dev/disk/by-uuid`)
1. Create the `nixbld` group and user on your original distribution:
```ShellSession
$ sudo groupadd -g 30000 nixbld
$ sudo useradd -u 30000 -g nixbld -G nixbld nixbld
```
1. Download/build/install NixOS:
::: {.warning}
Once you complete this step, you might no longer be able to boot on
existing systems without the help of a rescue USB drive or similar.
:::
::: {.note}
On some distributions there are separate PATHS for programs intended
only for root. In order for the installation to succeed, you might
have to use `PATH="$PATH:/usr/sbin:/sbin"` in the following command.
:::
```ShellSession
$ sudo PATH="$PATH" `which nixos-install` --root /mnt
```
Again, please refer to the `nixos-install` step in
[](#sec-installation) for more information.
That should be it for installation to another partition!
1. Optionally, you may want to clean up your non-NixOS distribution:
```ShellSession
$ sudo userdel nixbld
$ sudo groupdel nixbld
```
If you do not wish to keep the Nix package manager installed either,
run something like `sudo rm -rv ~/.nix-* /nix` and remove the line
that the Nix installer added to your `~/.profile`.
1. ::: {.note}
The following steps are only for installing NixOS in place using
`NIXOS_LUSTRATE`:
:::
Generate your NixOS configuration:
```ShellSession
$ sudo `which nixos-generate-config`
```
Note that this will place the generated configuration files in
`/etc/nixos`. You'll probably want to edit the configuration files.
Refer to the `nixos-generate-config` step in
[](#sec-installation) for more information.
::: {.note}
On [UEFI](https://en.wikipedia.org/wiki/UEFI) systems, check that your `/etc/nixos/hardware-configuration.nix` did the right thing with the [EFI System Partition](https://en.wikipedia.org/wiki/EFI_system_partition).
In NixOS, by default, both [systemd-boot](https://systemd.io/BOOT/) and [grub](https://www.gnu.org/software/grub/index.html) expect it to be mounted on `/boot`.
However, the configuration generator bases its [](#opt-fileSystems) configuration on the current mount points at the time it is run.
If the current system and NixOS's bootloader configuration don't agree on where the [EFI System Partition](https://en.wikipedia.org/wiki/EFI_system_partition) is to be mounted, you'll need to manually alter the mount point in `hardware-configuration.nix` before building the system closure.
:::
::: {.note}
The lustrate process will not work if the [](#opt-boot.initrd.systemd.enable) option is set to `true`.
If you want to use this option, wait until after the first boot into the NixOS system to enable it and rebuild.
:::
You'll likely want to set a root password for your first boot using
the configuration files because you won't have a chance to enter a
password until after you reboot. You can initialize the root password
to an empty one with this line: (and of course don't forget to set
one once you've rebooted or to lock the account with
`sudo passwd -l root` if you use `sudo`)
```nix
{
users.users.root.initialHashedPassword = "";
}
```
1. Build the NixOS closure and install it in the `system` profile:
```ShellSession
$ nix-env -p /nix/var/nix/profiles/system -f '<nixpkgs/nixos>' -I nixos-config=/etc/nixos/configuration.nix -iA system
```
1. Change ownership of the `/nix` tree to root (since your Nix install