Why swap space doesn't get filesystem check at boot time?
At boot time, swap doesn’t contain any data which would need to be recovered, so there’s no point in writing a tool to repair swap. If a swap partition or file is corrupted in such a way that swapon
can’t make use of it, the fix is to mkswap
it again — there’s no need for a separate fsck.swap
tool, so there isn’t one and /etc/fstab
isn’t set up to use one.
It might then seem nice for swapon
to automatically mkswap
if necessary, but that would mean that any mistake in the arguments to swapon
would be instantly fatal to the data stored in the given volume or file.
Sure. Swap is a dump. Everything within it is disposable. It's like a "scratch" file. Just a place to temporarily put things in, and later overwrite them without cause for worry. Technically it's only used when there's memory pressure (lots of active things in RAM).
Hope that helps clarify things a bit. :)