Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

If a process wants to access a memory address that is not in physical memory, the OS outsources a page frame from physical memory to the hard drive for later use. Where on the hard drive is this data / instruction stored?

Is it stored on the swap partition?

share|improve this question
3  
Yes. Note that however, some other things are stored there, like hibernation state. –  BatchyX Mar 26 '13 at 14:11
    
But what if I do swapoff, where is it stored then? –  Ian Mar 26 '13 at 14:34
1  
Nowhere. Your OS will only run in memory, and if it gets full, future memory allocation will be denied and programs may get killed. –  BatchyX Mar 26 '13 at 14:41

2 Answers 2

You can run swapon -s to see what devices and files are being used for swap. For example, my scientific linux machine says:

[user@sl6.3 ~]$ swapon -s
Filename                Type        Size    Used    Priority
/dev/sda3                               partition   8388600 833408  -1

So I'm using /dev/sda3 for swap. Also note the priority field that can be used to adjust the order in which swap pages are allocated (see man 2 swapon).

As some folks have stated, if you run out of swap (or have zero swap) the OOM Killer may start killing processes when physical memory gets low.

share|improve this answer

Pages of process memory may be displaced from the RAM to the disk. This is called swapping or paging (the terms are essentially synonymous). The data is moved to the swap space, and loaded back from the swap space when it is needed. Linux supports both partitions (and other block devices) and files as swap space.

If the page in question contains data that's been loaded from a file, then the data is not written to swap space if the page is to be reclaimed: it is simply erased from RAM. When the process needs the page again, the data is loaded back from that file.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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