Created
March 12, 2022 21:17
-
-
Save fersilva16/4633e1f5d91a8e9f4da45236bf55646a to your computer and use it in GitHub Desktop.
NixoOS setup on VirtualBox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo -i | |
loadkeys br-abnt2 # Setting the keyboard layout to Brazilian ABNT2 | |
setfont ter-v32n # Increase font | |
curl google.com # Check internet connection | |
parted /dev/sda -- mklabel gpt # use GPT partition table | |
parted /dev/sda -- mkpart primary 512MiB 100% # 16GiB partition for LVM and 512MiB boot partition | |
parted /dev/sda -- mkpart ESP fat32 1MiB 512MiB # Use ESP (EFI system partition) for boot partition | |
parted /dev/sda -- set 2 esp on # Enable ESP for the 2nd file system (the boot one) | |
# Create LUKS device | |
cryptsetup --hash sha512 --use-random --verify-passphrase -v luksFormat /dev/sda1 | |
cryptsetup open /dev/sda1 lvm | |
pvcreate /dev/mapper/lvm # Create physicial volume | |
vgcreate vg /dev/mapper/lvm # Create volume group | |
lvcreate -l 100%FREE vg -n root # Create root logical volume | |
mkfs.fat -F 32 -n boot /dev/sda2 # Init boot file system (sda2) with label "boot" | |
mkfs.btrfs /dev/vg/root | |
mount -t btrfs /dev/vg/root /mnt | |
btrfs subvolume create /mnt/root | |
btrfs subvolume create /mnt/home | |
umount /mnt | |
mount -o subvol=root,compress=lzo,noatime,autodefrag,discard,nodev,rw,space_cache /dev/vg/root /mnt # mount root | |
mkdir /mnt/home # create /home | |
mount -o subvol=home,compress=lzo,noatime,autodefrag,discard,nodev,rw,space_cache,nosuid /dev/vg/root /mnt/home # mount home | |
mkdir /mnt/boot # Create boot folder | |
mount /dev/disk/by-label/boot /mnt/boot # Mount boot file system | |
truncate -s 0 /mnt/swapfile | |
chattr +C /mnt/swapfile | |
btrfs property set /mnt/swapfile compression none | |
dd if=/dev/zero of=/mnt/swapfile bs=1M count=6144 status=progress # set swapfile size to 6GiB | |
sync | |
chmod 600 /mnt/swapfile | |
mkswap /mnt/swapfile | |
swapon /mnt/swapfile | |
nixos-generate-config --root /mnt # Generate config | |
nano /mnt/etc/nixos/configuration.nix # Edit config | |
# Modifications on config for VirtualBox | |
# boot.loader.systemd-boot.enable = true; | |
# boot.loader.efi.canTouchEfiVariables = true; | |
# | |
# boot.initrd.luks.devices."lvm" = | |
# { device = "/dev/sda1"; | |
# preLVM = true; | |
# allowDiscards = true; | |
# }; | |
# | |
# swapDevices = [ { device = "/swapfile"; size = 6144; } ]; | |
# boot.resumeDevice = "/swapfile"; | |
nixos-install | |
shutdown now # or reboot | |
# Remove NixOS Installation ISO and boot the virtual machine again |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment