no swap on ext4?


Recommended Posts

well as im studying linux at my institute so in theory class today we had a question why does ext4 not use swap?

well i thought all ext used swap so whats the difference between swap in ext3 and swap if any in ext4 , i tried googling in but no luck so im asking all the linux masters down here to please try and help me with this.Thank you for reading and sorry for my bad engkish its not my mother tongue.

Link to comment
https://www.neowin.net/forum/topic/826664-no-swap-on-ext4/
Share on other sites

Swap is direct equivalent of windows pagefiles virtual memory, but in a separated and dedicated partition. You can use pagefiles too, but nobody seem to do it (swap is faster because it does not rely on the underling filesystem on every write operation. Hibernation also work better).

Your teacher should have teached the principal behind operating system memory management before talking about those things. Thats the physical application of that theory, the page handler of Linux.

  Elv13 said:
Swap is direct equivalent of windows pagefiles virtual memory, but in a separated and dedicated partition. You can use pagefiles too, but nobody seem to do it (swap is faster because it does not rely on the underling filesystem on every write operation. Hibernation also work better).

Since the 2.6 kernel, the swapfile isn't any slower/less efficient than the swap partition (Andrew Morton explains why). I've also found hibernation with a swapfile to work just as well on my particular laptop, although it does take a little bit more work to get it working.

  Volatile said:
Elv13 provided the exact purpose for swap. You can use a swap with ext4 as well. I however do not use swap because I have more than applicable memory.

You should consider adding a small swap to your system. Linux use two page managing different algorithm if a swap is present or not. The first one is more efficient and will increase performances, even if the swap is not used.

  Elv13 said:
You should consider adding a small swap to your system. Linux use two page managing different algorithm if a swap is present or not. The first one is more efficient and will increase performances, even if the swap is not used.

Which may be true, but I've run two separate installs with and without a swap and haven't noticed a difference.

Linux can either use swap as a partition or as a file like in Windows. A swap file can be created on ext4 and most filesystems.

As already stated, If the swap file is created when the filesystem is new (so there is no fragmentation) it will be just as fast as if it were a partition.

http://lkml.org/lkml/2005/7/7/326

  Quote
> 3. Does creating the swapfile on a journaled filesystem (e.g. ext3 or

> reiser) incur a significant performance hit?

None at all. The kernel generates a map of swap offset -> disk blocks at

swapon time and from then on uses that map to perform swap I/O directly

against the underlying disk queue, bypassing all caching, metadata and

filesystem code.

  Zapadlo said:
I was under an impression swap is not "on" any file system but an equivalence of a type of a file system itself.

You are correct, Linux Swap is in fact a different file system. If you look at any distro's "automatic" drive set up you will see they create a separate partition for the swap space. This is mainly due (but not limited) to the fact that it does not need to be journalized (as the regular file system is) thus keeping I/O speed as fast as possible.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.