Skip to content

Instantly share code, notes, and snippets.

Created November 9, 2017 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2a1a23340a8b7ebb577669547ade5e53 to your computer and use it in GitHub Desktop.
Save anonymous/2a1a23340a8b7ebb577669547ade5e53 to your computer and use it in GitHub Desktop.
## Prepare partitions
fdisk -l
$ gdisk /dev/sda
n # new partition
<enter> # default partition #
<enter> # default start location
+512M # size 512MB
ef00 # type boot
n # new partition
<enter> # default partition #
<enter> # default start location
<enter> # size remaining space
<enter> # type default
w # write partitions
y # confirm
## Configure Encryption
root_partition=/dev/sda$PARTITION_NUMBER # e.g., /dev/sda5
cryptsetup luksFormat $root_partition
cryptsetup open --type luks $root_partition enc-pv
pvcreate /dev/mapper/enc-pv
vgcreate vg /dev/mapper/enc-pv
lvcreate -L 10G -n swap vg
lvcreate -l 100%VG -n root vg
## Format partitions
boot_partition=/dev/sda$PARTITION_NUMBER # e.g., /dev/sda4
mkfs.vfat $boot_partition
mkfs.ext4 -j -L root /dev/vg/root
mkswap -L swap /dev/vg/swap
## Mount partitions
mount /dev/vg/root /mnt
mkdir /mnt/boot
mount $boot_partition /mnt/boot
swapon /dev/vg/swap
# Revert (this not necceseary just in case you wan't revert back here)
cryptsetup open --type luks $root_partition
lvchange -ay vg
## Configure
nixos-generate-config --root /mnt
## Install
nixos-install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment