TGViewer
Versatile Engineer Versatile Engineer @versatile_engineer · 2 subscribers
Post #46 453
⚙️ Swap File in NixOS

A swap file is extra space on your disk that helps when your computer runs out of memory.

1. create the swap file (e.g., 8GB)
1. sudo fallocate -l 8G /swapfile or(sudo dd if=/dev/zero of=/swapfile bs=1M count=8192)
2. sudo chmod 600 /swapfile
3. sudo mkswap /swapfile


2. add this to your /etc/nixos/configuration.nix
swapDevices = [
{
device = "/swapfile";
}
];


3. rebuild your NixOS system
sudo nixos-rebuild switch


4. activate the swap file immediately
sudo swapon /swapfile


It’s not recommended unless the drive is NVMe and not fast enough.
  • 👌 2
More from @versatile_engineer
  1. Oct 18, 2024Channel created
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →