Hey Guys,
I’m new to nixOS an try to install it on my virtual machine.
To do this I downloaded a live-image an boot from it.
I followed the instructions on NixOS Manual.
My partitions are as followed:
vda1 - ESP - fat32 - 1 GiB - Flags: boot, esp → /boot
vda2 - cryptedlvm (LUKS encrypted LVM)
- root - 10 GiB - btrfs → /
- home - 10 GiB - btrfs → /home
- swap - 1GiB - swap → swap
For this setup I used the following commands on the terminal:
sudo parted /dev/vda
(parted) mktable gpt
(parted) mkpart ESP fat32 1MiB 1001MiB
(parted) set 1 esp on
(parted) mkpart primary 1001MiB 100%
sudo cryptsetup luksFormat /dev/vda2
sudo cryptsetup open /dev/vda2 cryptlvm
sudo pvcreate /dev/mapper/cryptlvm
sudo vgcreate nix-vg /dev/mapper/cryptlvm
sudo lvcreate -L 10G -n root nix-vg
sudo lvcreate -L 100G -n home nix-vg
sudo lvcreate -l 100%FREE -n swap nix-vg
sudo mkswap /dev/nix-vg/swap
sudo mkfs.btrfs /dev/nix-vg/root
sudo mkfs.btrfs /dev/nix-vg/home
sudo mount /dev/nix-vg/root /mnt
sudo mkdir /mnt/home
sudo mount /dev/nix-vg/home /mnt/home
sudo swapon /dev/nix-vg/swap
sudo mkfs.vfat -F 32 /dev/vda1
sudo mkdir /mnt/boot
sudo mount /dev/vda1 /mnt/boot
After this steps I started the graphical installer an Install it on my machnie.
The installation was successfully, now I reboot.
At this time the error appears. The machine starts booting and then it should wait for the password input to decrypt the partition, but it don’t find any partition with the / - directory.
In the documentation below the partition section, there is a article for usage with LUKS.
{
boot.initrd.luks.devices.crypted.device = "/dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d";
fileSystems."/".device = "/dev/mapper/crypted";
}
But where should I enter this now? Or where is this directory located after installing the operating system?
When I restart, I cannot access configuration.nix because / is not found or is encrypted.
Thanks for help
So, I want to point out firstly that this is not what you said you wanted. This is a 10GiB root, a 100GiB home, and the entire rest of the disk is used for swap.
Anyway. I don’t see anything wrong with how you partitioned it.
This should be auto-generated, so it’s nothing you need to add.
I think this is a bug in the installer. I don’t think you can use the graphical installer after doing manual partitioning in the terminal. I think you’ll have to just run nixos-generate-config --root /mnt
and nixos-install
in the terminal if you do your partitioning yourself like that. i.e. Follow the “manual installation” steps in the nixos manual in full, rather than trying to also use the graphical installer. We should probably open a bug on the graphical installer’s repo about this though.
Thank you for your reply,
there was a mistake while I wrote the code, 10G instead of 100G, sorry.
sudo lvcreate -L 10G -n home nix-vg
I was able to solve the problem by my self.
Reading attentive the documentation can solve some issues.
I solved my problem with the following commands:
Partitioning:
sudo parted /dev/vda
(parted) mktable gpt
(parted) mkpart ESP fat32 1MiB 1001MiB
(parted) set 1 esp on
(parted) mkpart primary 1001MiB 100%
Setting up Encrypted Device:
sudo cryptsetup luksFormat /dev/vda2
sudo cryptsetup luksOpen /dev/vda2 cryptlvm
Create LVM:
sudo pvcreate /dev/mapper/cryptlvm
sudo vgcreate nix-vg /dev/mapper/cryptlvm
sudo lvcreate -L 10G -n root nix-vg
sudo lvcreate -L 10G -n home nix-vg
sudo lvcreate -l 100%FREE -n swap nix-vg
Setup Filesystems:
sudo mkfs.fat -F 32 -n BOOT /dev/vda1
sudo mkswap /dev/nix-vg/swap
sudo mkfs.btrfs /dev/nix-vg/root
sudo mkfs.btrfs /dev/nix-vg/home
Mounting:
sudo mount /dev/nix-vg/root /mnt
sudo swapon /dev/nix-vg/swap
sudo mkdir -p /mnt/home
sudo mount /dev/nix-vg/home /mnt/home
sudo mkdir -p /mnt/boot
sudo mount -o umask=077 /dev/vda1 /mnt/boot
Nix configuration:
sudo nixos-generate-config --root /mnt
sudo nano /mnt/etc/nixos/configuration.nix
// inside configuration.nix
boot.initrd.luks.devices.crypted.device = "/dev/disk/by-uuid/3f6b0024-3a44-4fde-a43a-767b872abe5d";
boot.initrd.services.lvm.enable = true;
fileSystems."/".device = "/dev/mapper/crypted";
nixos-install