I am interested in obtaining (or building myself) a version of the Linux kernel that has absolutely no virtual memory and none of its attendant overhead. No swap file, no nothing.

What are my options?

  • 3
    Virtual memory has NOTHING to do with swap. Nada. Zip. Zero. Two completely unrelated concepts. You could have a system that uses virtual addressing but no swap, and (theoretically) a system that uses swap and no virtual addressing. On linux, use of swap is optional, but virtual addressing -- which I am guessing you have significantly misunderstood the purpose of -- is integral, just as it is for every other widely used modern operating system. There may be some highly specialized ones out there that do not (in the embedded world) but they would be useless outside that. – goldilocks Sep 19 '13 at 23:08
  • 1
    @goldilocks "and (theoretically) a system that uses swap and no virtual addressing" More than theoretically. One example is Mac OS Classic (i.e., the stuff before Mac OS X) – derobert Sep 19 '13 at 23:11
  • 1
    @goldilocks Linux can work on systems which only have an MPU (memory protection unit: assigns permissions to hardware pages) and no MMU (no virtual addressing). An MPU is enough to enforce isolation between processes, but it makes some features such as fork nigh-impossible to implement, which puts a serious crimp in a unix system. – Gilles 'SO- stop being evil' Sep 20 '13 at 0:35

As far as I know, you cannot disable the concept of virtual memory in Linux, at least not without totally rewriting it. It's an integral part of the memory management and lots of stuff simply would cease to work if you could disable it.

The mmap call can be used to map a file or a device to a part of an application's virtual memory (every application has 4 GB virtual memory on 32 bit, and 16 EB on 64 bit). For example, an application could mmap several megabytes of the hard disk into its own virtual memory. It could then access this part of the hard disk just by accessing its own memory—the kernel will automatically fetch the required data from the hard disk, store it in the RAM and return this data to the application. If you could disable virtual memory, this application would now no longer work.

On the other hand, swap can be disabled very easily, just by running swapoff -a or not setting up swap partitions in /etc/fstab at all.


Any kernel can do this.

Simply do not assign any swap, then you are only left with "real" memory.

swapoff -a 

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