Home Explore Blog Models CI



nixpkgs

4th chunk of `nixos/doc/manual/installation/installing.chapter.md`
2d765665a9fcc50660a6372d193ddd51c9dcbb3d4852912f0000000100000fa1
    system partition) as its */boot* partition. It uses the initially
    reserved 512MiB at the start of the disk.

    ```ShellSession
    # parted /dev/sda -- mkpart ESP fat32 1MB 512MB
    # parted /dev/sda -- set 3 esp on
    ```
    ::: {.note}
    In case you decided to not create a swap partition, replace `3` by `2`. To be sure of the id number of ESP, run `parted --list`.
    :::

Once complete, you can follow with
[](#sec-installation-manual-partitioning-formatting).

#### Legacy Boot (MBR) {#sec-installation-manual-partitioning-MBR}
[]{#sec-installation-partitioning-MBR} <!-- legacy anchor -->

Here's an example partition scheme for Legacy Boot, using `/dev/sda` as
the device.

::: {.note}
You can safely ignore `parted`'s informational message about needing to
update /etc/fstab.
:::

1.  Create a *MBR* partition table.

    ```ShellSession
    # parted /dev/sda -- mklabel msdos
    ```

2.  Add the *root* partition. This will fill the the disk except for the
    end part, where the swap will live.

    ```ShellSession
    # parted /dev/sda -- mkpart primary 1MB -8GB
    ```

3.  Set the root partition's boot flag to on. This allows the disk to be booted from.

    ```ShellSession
    # parted /dev/sda -- set 1 boot on
    ```

4.  Finally, add a *swap* partition. The size required will vary
    according to needs, here a 8GB one is created.

    ```ShellSession
    # parted /dev/sda -- mkpart primary linux-swap -8GB 100%
    ```

    ::: {.note}
    The swap partition size rules are no different than for other Linux
    distributions.
    :::

Once complete, you can follow with
[](#sec-installation-manual-partitioning-formatting).

#### Formatting {#sec-installation-manual-partitioning-formatting}
[]{#sec-installation-partitioning-formatting} <!-- legacy anchor -->

Use the following commands:

-   For initialising Ext4 partitions: `mkfs.ext4`. It is recommended
    that you assign a unique symbolic label to the file system using the
    option `-L label`, since this makes the file system configuration
    independent from device changes. For example:

    ```ShellSession
    # 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

Title: NixOS Manual Installation: MBR Partitioning, Formatting, and Initial Mounting
Summary
This chunk continues the NixOS manual installation guide, first completing the UEFI (GPT) partition scheme by detailing the creation of the EFI System Partition (ESP). It then provides a full example for Legacy Boot (MBR) systems, demonstrating how to create MBR, root, and swap partitions, and setting the boot flag using `parted`. Following partitioning, it outlines the formatting process for Ext4 (`mkfs.ext4`), swap (`mkswap`), and UEFI boot partitions (`mkfs.fat`), recommending labels for easier identification. Finally, the chunk details the initial steps of the installation, which include mounting the root filesystem to `/mnt`, mounting the boot filesystem to `/mnt/boot` (for UEFI), activating swap devices if necessary, and introduces the declarative `configuration.nix` file for system setup.