Skip to content

Commit

Permalink
Partition with sgdisk, add swap
Browse files Browse the repository at this point in the history
  • Loading branch information
ners authored Apr 17, 2021
1 parent 7176b4a commit 4e0dcbb
Showing 1 changed file with 29 additions and 39 deletions.
68 changes: 29 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,33 @@ NixOS
# Installation

```sh
sudo sgdisk --zap-all /dev/nvme0n1
(
echo o # create a new empty GUID partition table (GPT)
echo y # This option deletes all partitions and creates a new protective MBR. Proceed? (Y/N)
echo n # Add a new partition
echo 1 # Partition number
echo # First sector (Accept default: 2048)
echo +1G # Last sector
echo EF00 # Partition type hex code
echo n # Add a new partition
echo 2 # Partition number
echo # First sector (Accept default)
echo # Last sector (Accept default: full disk)
echo # Partition type hex code (accept default: 8300)
echo c # change a partition's name
echo 1 # Partition number
echo EFI # Partition name
echo c # change a partition's name
echo 2 # Partition number
echo NixOS # Partition name
echo w # write table to disk and exit
echo y # confirm edit
) | sudo gdisk /dev/nvme0n1

sudo partprobe

sudo mkfs.fat -F32 -n EFI /dev/disk/by-partlabel/EFI
sudo mkfs.btrfs -f -L NixOS /dev/disk/by-partlabel/NixOS

sudo mount -o compress=zstd /dev/disk/by-partlabel/NixOS /mnt
sudo btrfs subvolume create /mnt/root
sudo btrfs subvolume create /mnt/home
# sudo btrfs subvolume create /mnt/swap
sudo umount /mnt

sudo mount -o subvol=root,compress=zstd /dev/disk/by-partlabel/NixOS /mnt
sudo mkdir -p /mnt/boot/efi /mnt/home
sudo mount /dev/disk/by-partlabel/EFI /mnt/boot/efi
sudo mount -o subvol=home,compress=zstd /dev/disk/by-partlabel/NixOS /mnt/home
sudo su

sgdisk --zap-all -o \
-n 1:0:+1G -t 1:EF00 -c 1:EFI \
-n 2:0:0 -t 1:8200 -c 2:NixOS \
/dev/nvme0n1

partprobe

mkfs.fat -F32 -n EFI /dev/disk/by-partlabel/EFI
mkfs.btrfs -f -L NixOS /dev/disk/by-partlabel/NixOS

mount /dev/disk/by-partlabel/NixOS /mnt
btrfs subvolume create /mnt/root
btrfs subvolume create /mnt/home
btrfs subvolume create /mnt/swap
umount /mnt

mount -o subvol=root,compress=zstd /dev/disk/by-partlabel/NixOS /mnt
mkdir -p /mnt/boot/efi /mnt/home /mnt/swap
mount /dev/disk/by-partlabel/EFI /mnt/boot/efi
mount -o subvol=home,compress=zstd /dev/disk/by-partlabel/NixOS /mnt/home
mount -o subvol=swap /dev/disk/by-partlabel/NixOS /mnt/swap

touch /mnt/swap/swapfile
chmod 600 /mnt/swap/swapfile
chattr +C /mnt/swap/swapfile
fallocate /mnt/swap/swapfile -l4g
mkswap /mnt/swap/swapfile
```

0 comments on commit 4e0dcbb

Please sign in to comment.