NixOS Installation Guide/ru: Difference between revisions
Created page with "TODO" |
Updating to match new version of source page |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
<languages/> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
This guide serves as a companion guide for the [https://nixos.org/nixos/manual/index.html#ch-installation official manual]. It describes installation of [[NixOS]] as a complete operating system. For instructions on installing [[Nix]] within an existing operating system, refer to the [[Nix Installation Guide]]. | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
In addition to covering the steps from the official manual, it provides known good instructions for common use cases. When there is a discrepancy between the manual and this guide, the supported case is the one described in the manual. | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
== Installation target == | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
NixOS can be installed on an increasing variety of hardware: | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
* regular (Intel or AMD) desktop computers, laptops or physically accessible servers, covered on this page | |||
* SBCs (like the Raspberry Pis) and other ARM boards, see [[NixOS on ARM]] | |||
* cloud and remote servers, see [[NixOS friendly hosters]] | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
== Installation method == | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
NixOS, as with most Linux-based operating systems, can be installed in different ways. | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
# The classic way, booting from the installation media. (Described below.) | |||
# [[Installing from Linux|Booting the media from an existing Linux installation]] | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
== Making the installation media == | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
Since NixOS 14.11 the installer ISO is hybrid. This means it is bootable on both CD and USB drives. It also boots on EFI systems, like most modern motherboards and apple systems. The following instructions will assume the standard way of copying the image to a USB drive. When using a CD or DVD, the usual methods to burn to disk should work with the iso. | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
=== "Burning" to USB drive === | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
First, download a [https://nixos.org/download.html#nixos-iso NixOS ISO image] or [[Creating a NixOS live CD|create a custom ISO]]. Then plug in a USB stick large enough to accommodate the image. Then follow the platform instructions: | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
==== From Linux ==== | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
# Find the right device with <code>lsblk</code> or <code>fdisk -l</code>. Replace <code><i>/dev/sdX</i></code> with the proper device in the following steps. | |||
# Copy to device: <code>cp nixos-xxx.iso <em>/dev/sdX</em></code> | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
{{note|do not use /dev/sdX1 or partitions of the disk, use the whole disk /dev/sdX.}} | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
Writing the disk image with <code>dd if=nixos.iso of=/dev/sdX bs=4M status=progress conv=fdatasync</code> also works. | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
==== From macOS ==== | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
# Find the right device with <code>diskutil list</code>, let's say <code><i>diskX</i></code>. | |||
# Unmount with <code>diskutil unmountDisk <i>diskX</i></code>. | |||
# Burn with: <code>sudo dd if=<b>path_to_nixos.iso</b> of=/dev/<i>diskX</i></code> | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
{{tip|Using <code>rdiskX</code> instead of <code>diskX</code> can makes a large speed difference. You can check the write speed with <code>iostat 2</code> in another terminal.}} | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
==== From Windows ==== | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
# Download [http://sourceforge.net/projects/usbwriter/ USBwriter]. | |||
# Start USBwriter. | |||
# Choose the downloaded ISO as 'Source' | |||
# Choose the USB drive as 'Target' | |||
# Click 'Write' | |||
# When USBwriter has finished writing, safely unplug the USB drive. | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
=== Alternative installation media instructions === | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
The previous methods are the supported methods of making the USB installation media. | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
Those methods are also documented, they can allow using the USB drive to boot multiple distributions. This is not supported, your mileage may vary. | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
* [[NixOS_Installation_Guide/Unetbootin|Using Unetbootin]] | |||
* [[NixOS_Installation_Guide/Manual USB Creation|Manual USB Creation]] | |||
* [[NixOS_Installation_Guide/multibootusb|multibootusb]] | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
== Booting the installation media == | |||
{{expansion|Troubleshooting steps, and details are lacking.}} | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
The installation media is hybrid and is capable of booting in both legacy BIOS mode and [[UEFI]] mode. | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
Whatever mode is used to boot the installation media, your motherboard or computer's configuration may need to be changed to allow booting from a Optical Disk Drive (for CD/DVD) or an external USB drive. | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
=== Legacy bios boot === | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
This is the only boot possible on machines lacking EFI/UEFI. | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
=== UEFI boot === | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
The EFI bootloader of the installation media is not signed and is not using a signed shim to boot. This means that Secure Boot will need to be disabled to boot. | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
== Connecting to the internet == | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
The installation will '''definitely''' need a working internet connection. It is possible to install without one, but the available set of packages is limited. | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
=== Wired === | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
For network interfaces supported by the kernel, DHCP resolution should already have happened once the shell is available. | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
==Tethered (Internet Sharing)== | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
If you can not connect to the internet via cable or wifi, you may use smartphone's tethering capability to share internet. Depending on your smartphones capabilities, only stock kernel drivers may be required which can help providing a working network connection. | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
=== Wireless === | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
[[NetworkManager]] is installed on the graphical ISO, meaning that it is possible to use <code>nmtui</code> on the command line to connect to a network. | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
Using the "Applications" tab at top | |||
left or the launcher bar at bottom, choose a terminal application and from there launch <code>nmtui</code>. This will allow you to 'activate' a (wireless) connection - your local SSIDs should be visible in the list, else you can add a new connection. When the wireless connection is active and you have tested it, it is likely the install app which launched on startup has not detected the new connection. Close down the install app, and reopen it from the launcher bar at the bottom of the screen. This should then find the new connection and proceed. | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
On the minimal ISO, or if you are more familiar with [[wpa_supplicant]] then you can also run <code>wpa_passphrase ESSID | sudo tee /etc/wpa_supplicant.conf</code>, then enter your password and <code>systemctl restart wpa_supplicant</code>. | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
== Partitioning == | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
To partition the persistent storage run <code>sudo fdisk /dev/diskX</code> and follow instructions for MBR or (U)EFI. To determine which mode you are booted into, run: | |||
</div> | |||
<syntaxhighlight lang="console"> | |||
$ [ -d /sys/firmware/efi/efivars ] && echo "UEFI" || echo "Legacy" | |||
</syntaxhighlight> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
A very simple example setup is given here. | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
=== Legacy Boot (MBR) === | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
* o (dos disk label) | |||
* n new | |||
* p primary (4 primary in total) | |||
* 1 (partition number [1/4]) | |||
* 2048 first sector (alignment for performance) | |||
* +500M last sector (boot sector size) | |||
* rm signature (Y), if ex. => warning of overwriting existing system, could use wipefs | |||
* n | |||
* p | |||
* 2 | |||
* default (fill up partition) | |||
* default (fill up partition) | |||
* w (write) | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
=== UEFI === | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
* g (gpt disk label) | |||
* n | |||
* 1 (partition number [1/128]) | |||
* 2048 first sector | |||
* +500M last sector (boot sector size) | |||
* t | |||
* 1 (EFI System) | |||
* n | |||
* 2 | |||
* default (fill up partition) | |||
* default (fill up partition) | |||
* w (write) | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
=== Format partitions === | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
The example below uses the [[ext4]] filesystem format. If you wish to use other filesystem formats such as [[Btrfs]] or [[ZFS]]: | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
* [[Bcachefs#NixOS installation on bcachefs]] | |||
* [[Btrfs#Installation of NixOS on btrfs]] | |||
* [[LVM#Basic Setup]] | |||
* [[ZFS#Simple NixOS ZFS on root installation]] | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
This is useful for having multiple setups and makes partitions easier to handle | |||
</div> | |||
<syntaxhighlight lang="console"> | |||
$ lsblk # lists current system block devices | |||
# mkfs.fat -F 32 -n boot /dev/sdX1 | |||
# mkfs.ext4 /dev/sdX2 -L nixos | |||
# mount /dev/disk/by-label/nixos /mnt | |||
# mkdir -p /mnt/boot | |||
# mount /dev/disk/by-label/boot /mnt/boot | |||
</syntaxhighlight> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
== NixOS configuration == | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
NixOS is configured through a [[Overview of the NixOS Linux distribution#Declarative Configuration|declarative configuration]] file. To generate a default config file, run [[nixos-generate-config]]: | |||
</div> | |||
<syntaxhighlight lang="console"> | |||
# nixos-generate-config --root /mnt | |||
# nano /mnt/etc/nixos/configuration.nix | |||
</syntaxhighlight> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
For information on working with a system configuration, see [[NixOS system configuration]]. For desktop-specific configurations, see [[NixOS as a desktop]]. | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
Most essential changes: | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
* keyboard layout, ie <code>[[Keyboard Layout Customization|services.xserver.xkb.layout]]</code> | |||
* [[networking]] (wifi), see below for fix if it breaks | |||
* install [[:Category:Text Editor|editor]] to edit the configuration | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
The self-documenting NixOS options can be searched with [https://search.nixos.org/options NixOS options search]. | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
=== Swap file === | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
For additional methods of configuring swap, see [[Swap]]. The following example demonstrates how to create and enable a [[Swap#Swap file|swap file]]: | |||
</div> | |||
{{file|/mnt/etc/nixos/configuration.nix|nix| | |||
<nowiki> | |||
swapDevices = [{ | |||
device = "/var/lib/swapfile"; | |||
size = 16*1024; # 16 GB | |||
}]; | |||
</nowiki> | |||
}} | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
=== Bootloader === | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
NixOS supports multiple [[Bootloader|bootloaders]] such as [[GNU GRUB]] and [[Systemd/boot]]. | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
Systemd-boot is the recommended bootloader. The following example demonstrates how to enable systemd-boot in your configuration: | |||
</div> | |||
{{file|/mnt/etc/nixos/configuration.nix|nix| | |||
<nowiki> | |||
boot.loader.systemd-boot.enable = true; | |||
</nowiki> | |||
}} | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
You may also wish to configure [[Secure Boot]]. | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
=== Users === | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
For information on creating and managing users, see [[User management]] and the {{NixOS Manual|name=NixOS Manual: Chapter - Package Management|anchor=#sec-user-management}}. See an example below: | |||
</div> | |||
{{file|/mnt/etc/nixos/configuration.nix|nix| | |||
<nowiki> | |||
users.users.alice = { | |||
isNormalUser = true; | |||
initialPassword = "pw123"; | |||
}; | |||
</nowiki> | |||
}} | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
== NixOS installation == | |||
</div> | |||
<syntaxhighlight lang="console"> | |||
# cd /mnt | |||
# nixos-install | |||
</syntaxhighlight> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
after installation: Run <code>passwd</code> to change user password. | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
if internet broke/breaks, try one of the following: | |||
</div> | |||
<syntaxhighlight lang="console"> | |||
# nixos-rebuild switch --option substitute false # no downloads | |||
# nixos-rebuild switch --option binary-caches "" # no downloads | |||
</syntaxhighlight> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
* wpa_supplicant flags to connect to wifi | |||
</div> | |||
<hr /> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
== Additional notes for specific hardware == | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
These are collected notes or links for specific hardware issues. | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
* Blog post how to install NixOS on a [http://grahamc.com/blog/nixos-on-dell-9560 Dell 9560] | |||
* Brand servers may require extra kernel modules be included into initrd (<code>boot.initrd.extraKernelModules</code> in configuration.nix) For example HP Proliant needs "hpsa" module to see the disk drive. | |||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
[[Category:Guide]] | |||
[[Category:Deployment]] | |||
[[Category:NixOS]] | |||
</div> |