# NOTE: First check that the disk driver is set to virtio!

fdisk /dev/sda
	o
	n p <enter> <enter> +1G
		# boot partition
	n p <enter> <enter> <enter>
		# LVM partition
	a 1
		# set bootable
	w

# Boot partition
mkfs.ext4 -L boot /dev/sda1

# LVM partition
pvcreate /dev/sda2
vgcreate vg_main /dev/sda2
lvcreate -L 2GB -n lv_swap vg_main
lvcreate -l 100%FREE -n lv_root vg_main

mkswap -L swap /dev/vg_main/lv_swap
swapon /dev/vg_main/lv_swap

mkfs.ext4 -L nixos /dev/vg_main/lv_root

mount /dev/vg_main/lv_root /mnt
mkdir /mnt/boot
mount /dev/sda1 /mnt/boot

# NixOS installation
nixos-generate-config --root /mnt
curl https://git.cryto.net/joepie91/morph-rc/raw/master/data/dummy-configuration.nix > /mnt/etc/nixos/configuration.nix
# NOTE: Potentially update configuration.nix at this point if the primary disk is not /dev/sda!

nixos-install

# NOTE: Don't forget to set a better root password over SSH after restarting
# NOTE: Don't forget to run ./deploy-secrets if needed!

#################################

# Resize LV to maximum available space:
lvresize --resizefs -l +100%FREE /dev/vg_main/lv_root
