4

As I was checking the /etc/fstab I noticed that the swap space has attr pass=0, which means its filesystem is not checked at boot time. Can anyone please tell me why is this behavior for?

  • 4
    There is no (filesystem) structure in a Swap file. Consequently there is no fsck. mkswp does not format a swap partition or file, it just writes a signature to make sure the kernel does not incidentally swapon any area which has useful data. – eckes Jun 15 at 14:35
  • 1
    @eckes Your comment looks very much like an answer (and pretty similar to the accepted one). Please don't post answers as comments. – TooTea Jun 15 at 19:53
15

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.

2

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. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.