-   Linux - Newbie (
-   -   what the difference swap space and swap file (

dundu 07-27-2012 12:36 PM

what the difference swap space and swap file

what the use of swap file ?,is swap file is necessary for while swap extend

Kustom42 07-27-2012 12:46 PM

Thats got all the info you want. If you have any specific questions after reading over it let me know.

Karl Godt 07-28-2012 06:13 PM

Windows uses one or two swap files inside the C:\ Drive while Linux uses normally a swap partition .

To create a swap-file from the bash terminal console :


dd if=/dev/zero of=${localSMNTPT}/pupswap.swp bs=1048576 count=$SWPSIZE
to create an empty file


mkswap ${localSMNTPT}/pupswap.swp
to create the swap file system;

where localSMNTPT could be something like localSMNTPT=/mnt/sda2

bs=1048576 Bytes =1024 KiloBytes KiB =1MiB

SWPSIZE=256 for 256 MiB if bs=1048576


To activate the swapfile :

swapon /mnt/sda2/pupswap.swp
NOTE : Code is from Puppy Linux 4 series /etc/rc.d/rc.shutdown

David the H. 07-29-2012 06:26 AM

"swap space" is simply an hdd-based filesystem that acts as virtual RAM memory, which the OS can fall back to using when it gets low on actual RAM.

You can choose to set up a swap filesystem on a dedicated partition of its own, or as a virtual partition in a file existing on a regular storage partition (a "swap file"). It's your choice which you want to use, although most *nix users appear to prefer partitions.

You can even have multiple swap spaces of either kind; all activated swap space is combined into one bank of virtual memory.

jefro 07-29-2012 01:03 PM

Originally a swap partition was the only way to extend ram. Ram was very expensive and using part of the hard drive helped save money.

Later it was discovered that a swap file could be used to help provide options to the admin. Those options may include ease of changing files, file location and size. About the single drawback is the ability to hibernate to a file.

Files and partitions can be added together to form a single space or used in some priority scheme to use one before the other.

All times are GMT -5. The time now is 09:34 AM.