Home Explore Blog CI



nixpkgs

5th chunk of `nixos/doc/manual/installation/installing.chapter.md`
ddc475d86f4f150a0fa260e29eec2f6b878ef0b96aee93e10000000100000fed
    # mkfs.ext4 -L nixos /dev/sda1
    ```

-   For creating swap partitions: `mkswap`. Again it's recommended to
    assign a label to the swap partition: `-L label`. For example:

    ```ShellSession
    # mkswap -L swap /dev/sda2
    ```

-   **UEFI systems**

    For creating boot partitions: `mkfs.fat`. Again it's recommended
    to assign a label to the boot partition: `-n label`. For
    example:

    ```ShellSession
    # mkfs.fat -F 32 -n boot /dev/sda3
    ```

-   For creating LVM volumes, the LVM commands, e.g., `pvcreate`,
    `vgcreate`, and `lvcreate`.

-   For creating software RAID devices, use `mdadm`.

### Installing {#sec-installation-manual-installing}
[]{#sec-installation-installing} <!-- legacy anchor -->

1.  Mount the target file system on which NixOS should be installed on
    `/mnt`, e.g.

    ```ShellSession
    # mount /dev/disk/by-label/nixos /mnt
    ```

2.  **UEFI systems**

    Mount the boot file system on `/mnt/boot`, e.g.

    ```ShellSession
    # mkdir -p /mnt/boot
    # mount -o umask=077 /dev/disk/by-label/boot /mnt/boot
    ```

3.  If your machine has a limited amount of memory, you may want to
    activate swap devices now (`swapon device`).
    The installer (or rather, the build actions that it
    may spawn) may need quite a bit of RAM, depending on your
    configuration.

    ```ShellSession
    # swapon /dev/sda2
    ```

4.  You now need to create a file `/mnt/etc/nixos/configuration.nix`
    that specifies the intended configuration of the system. This is
    because NixOS has a *declarative* configuration model: you create or
    edit a description of the desired configuration of your system, and
    then NixOS takes care of making it happen. The syntax of the NixOS
    configuration file is described in [](#sec-configuration-syntax),
    while a list of available configuration options appears in
    [](#ch-options). A minimal example is shown in
    [Example: NixOS Configuration](#ex-config).

    This command accepts an optional `--flake` option, to also generate a
    `flake.nix` file, if you want to set up a flake-based configuration.

    The command `nixos-generate-config` can generate an initial
    configuration file for you:

    ```ShellSession
    # nixos-generate-config --root /mnt
    ```

    You should then edit `/mnt/etc/nixos/configuration.nix` to suit your
    needs:

    ```ShellSession
    # nano /mnt/etc/nixos/configuration.nix
    ```

    If you're using the graphical ISO image, other editors may be
    available (such as `vim`). If you have network access, you can also
    install other editors -- for instance, you can install Emacs by
    running `nix-env -f '<nixpkgs>' -iA emacs`.

    BIOS systems

    :   You *must* set the option [](#opt-boot.loader.grub.device) to
        specify on which disk the GRUB boot loader is to be installed.
        Without it, NixOS cannot boot.

        If there are other operating systems running on the machine before
        installing NixOS, the [](#opt-boot.loader.grub.useOSProber)
        option can be set to `true` to automatically add them to the grub
        menu.

    UEFI systems

    :   You must select a boot-loader, either systemd-boot or GRUB. The recommended
        option is systemd-boot: set the option [](#opt-boot.loader.systemd-boot.enable)
        to `true`. `nixos-generate-config` should do this automatically
        for new configurations when booted in UEFI mode.

        You may want to look at the options starting with
        [`boot.loader.efi`](#opt-boot.loader.efi.canTouchEfiVariables) and
        [`boot.loader.systemd-boot`](#opt-boot.loader.systemd-boot.enable)
        as well.

        If you want to use GRUB, set [](#opt-boot.loader.grub.device) to `nodev` and
        [](#opt-boot.loader.grub.efiSupport) to `true`.

        With systemd-boot, you should not need any special configuration to detect
        other installed systems. With GRUB, set [](#opt-boot.loader.grub.useOSProber)
        to `true`, but this will only detect windows partitions, not other Linux

Title: Installing NixOS: Mounting Filesystems, Creating Configuration
Summary
This section describes how to mount the target filesystem and boot partition for NixOS installation, activate swap devices, and create a `/mnt/etc/nixos/configuration.nix` file that specifies the system's desired configuration. It highlights the use of the `nixos-generate-config` command to generate an initial configuration file and the need to edit it according to your needs. It also provides specific configuration advice for both BIOS and UEFI systems, focusing on bootloader settings and the detection of other operating systems.