Occasionally I'll have a system crash or be forced to do a cold reboot. Upon rebooting I will get a kernel crash. Get out a rescue disk, rebuild swap, then everything boots fine.

The thing is that I use mkswap to to rebuild swap, which I feel makes my job so much harder and more dangerous.

Is there a way to run a sanity check on swap space and clean it up similar to what mkfs does?

  • 2
    Do you encounter some error when you have to resort to rebuilding swap? In my 20+ years of using Linux I've never encountered anything remotely like what you're describing which makes me think perhaps something else is at play here.
    – slm
    Commented Jul 5, 2014 at 0:41

1 Answer 1


mkswap pretty much is the swap device version of what mkfs is for filesystems.

Did you mean to ask for something like an fsck for swap? I don't think that would be very useful. When a swap device is re-added after having been not in use (say, after a reboot), none of its former contents are preserved, unlike what you'd expect for a filesystem. Therefore I can't think of any reason why you would want to scan and repair its former contents.

I agree with slm that something else might be going on here because I've never seen a corrupt swap device crash a kernel. Is it perhaps trying to use your swap device for a hibernation restore upon reboot?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .