2

I would like to understand the difference of MAC OS X "Virtual Memory" and Linux/Unix Swap.

I ask this because I observed that MAC OS X "Virtual Memory" seems to work way more efficient (in desktop use cases) than Linux/Unix Swap does.

In my understanding, MAC OS stores unused (RAM)Data in "Virtual Memory". In manner, it keeps the RAM free for current used Data/ current running Programs.
So for example, if I have watched a movie and then start to render some images, MAC OS will move the movie into the "Virtual Memory" and remove it into the RAM only when I re-access it.

Swap to the contray will only use the swap if the current running programs demand more RAM than available. And will immediately write the data stored in swap back to the RAM as soon as possible.

Harrys Kavan
  • 1,431
  • 1
    @garethTheRed It's not really a duplicate of that. His question is how he can put the swap area on an SSD instead of the system disk. – Barmar Nov 27 '14 at 08:52
  • 1
    Linux has "virtual memory", too. It's been a standard feature of Unix for decades. – Barmar Nov 27 '14 at 08:57
  • 1
    @Barmar - I read it as "Does Linux support Virtual Memory"? If the OP means "Does Virtual Memory work on Ubuntu and Fedora when using a SSD" then the question should be edited to say that (or similar). – garethTheRed Nov 27 '14 at 09:05
  • He explained what he's trying to accomplish, which is to achieve the VM performance on Linux that his friend demonstrated on the Mac. – Barmar Nov 27 '14 at 09:08
  • 1
    Ok, my fault I wrote the question wrong. Gonna edit it. – Harrys Kavan Nov 27 '14 at 10:00
  • @garethTheRed I rewrote the question. Do you feel like this time my point is more understandable then before? – Harrys Kavan Nov 27 '14 at 10:25
  • 1
    @derty - Indeed. I've voted to re-open the question. – garethTheRed Nov 27 '14 at 10:29
  • 1
    @derty - I might have been premature - there are a few answers already to this question: here, here and here. Your questions may not get enough votes to be re-opened. Read the links and see if they help. – garethTheRed Nov 27 '14 at 10:33
  • @garethTheRed well that is a beginning, I can work from there on. Thanks mate. – Harrys Kavan Nov 27 '14 at 10:36

1 Answers1

1

You can create a swap file on the SSD. An example for a 4GB swap file:

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

To make it permanent, add this to the fstab.

/swapfile   none    swap    sw    0   0

From: https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04?

  • I see that the SSD ref relates to the original version of the question. But I wonder if it's wise to use SSD for swap. Sure it's bound to be incredibly fast compared to using a magnetic disk, but it could also put a lot of wear & tear on the SSD. If I were doing this I'd be inclined to put the swap file (or partition) on a separate SSD, not my main drive. OTOH, modern SSDs do have a much longer reliable lifetime than earlier models, so I guess using SSD for swap is feasible these days. – PM 2Ring Nov 27 '14 at 11:06