Swap partition not active? Here's how to fix it fast

Linux & Unix Intermediate 👁 14 views 📅 Jun 18, 2026

Swap not active after boot? The culprit is usually a missing or wrong UUID in fstab. Here's the fix and why it happens.

The quick fix (this is almost always the issue)

You boot up, run swapon --show, and see nothing. Or free -h shows swap at 0. Don't panic. Nine times out of ten, the problem is that your swap partition's UUID in /etc/fstab doesn't match the actual partition anymore. This happens after a disk re-format, a partition table change, or a fresh install of a different distro that kept the old home partition.

Here's the fix:

  1. Identify your swap partition: lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTPOLICY — look for type part with fstype swap. Common names: /dev/sda2, /dev/nvme0n1p3, etc.
  2. Get the real UUID: sudo blkid /dev/sda2 (replace with your actual device). You'll see something like UUID="abc123..."
  3. Edit /etc/fstab: sudo nano /etc/fstab. Find the swap line — looks like UUID=abc123... none swap sw 0 0
  4. Replace the old UUID with the real one from step 2.
  5. Run sudo swapon -a to activate it.

That's it. You should see swap now with swapon --show. If swapon -a errors out, the most common message is swapon: /dev/sda2: swapon failed: Invalid argument — that almost always means you haven't run mkswap on it yet. If that's the case, sudo mkswap /dev/sda2 first, then repeat step 2-5.

Why this happens

Linux identifies partitions by their UUID, not by the device name like /dev/sda2. The UUID is generated when you create the filesystem — in this case, the swap signature with mkswap. If you reformat the partition (e.g., during a distro reinstall that didn't touch swap), or if you cloned a disk, the UUID changes. But /etc/fstab still has the old one. The system can't find it, so swap stays off.

You might also see the kernel drop a message like kernel: swap_init: unable to find device... in dmesg. That's the kernel saying the exact same thing in more boring words.

Less common variations that bite people

1. The partition is labeled, not UUID-referenced

Your /etc/fstab may use LABEL=swap instead of UUID=. That works too, but only if the partition actually has that label. Check with sudo blkid — if the label is missing or wrong, you'll need to either label it (sudo mkswap -L swap /dev/sda2) or switch to UUID method.

2. File system on the swap partition isn't swap

Yes, this happens. Someone accidentally ran mkfs.ext4 on the swap partition. Run sudo blkid — if it shows TYPE="ext4" instead of TYPE="swap", you need to reformat: sudo mkswap /dev/sda2. Then update the UUID in fstab.

3. Swap on LVM or encrypted volume

If you're using LVM, run sudo lvdisplay to find the logical volume name (e.g., /dev/vg01/swap). Then sudo blkid /dev/vg01/swap to get its UUID, and update fstab to point to that UUID. For LUKS-encrypted swap, you'd use the LUKS UUID (UUID= of the crypto device, not the inner filesystem). That's a deeper rabbit hole — for now, check with sudo dmsetup ls and cross-reference.

4. The swap file is missing or corrupt

Some distros use a swap file instead of a partition (Ubuntu does this by default since 2018-ish). If your fstab has a swap file entry like /swapfile none swap sw 0 0, but the file doesn't exist, you'll need to recreate it:

sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

Then check if swapon -a works now.

Prevention — don't let it happen again

After you fix it, do this one thing: document your UUIDs. Before any disk change, run sudo blkid > ~/partitions-backup.txt. Keep that file. If you clone a disk or reinstall, you'll have the old UUIDs to compare.

Also, if you're the kind of person who reinstalls distros often, consider using a swap file instead of a partition. Swap files don't have UUID issues — they're just files. Ubuntu's installer does this out of the box. The only downside is that swap files don't work with hibernation on some systems (check your kernel config).

Finally, when you edit /etc/fstab, always run sudo mount -a after saving. That checks all the filesystem entries and catches syntax errors before the next reboot. Do it for swap too — sudo swapon -a will tell you if you botched the swap line.

That's the whole deal. Swap not active? Check UUID. Fix UUID. Move on with your day.

Was this solution helpful?