LinuxAnswers - the LQ Linux tutorial section.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-27-2012, 11:36 AM   #1
LQ Newbie
Registered: Jul 2012
Distribution: Redhat,Fedora,centos
Posts: 17

Rep: Reputation: Disabled
Question what the difference swap space and swap file


what the use of swap file ?,is swap file is necessary for while swap extend
Old 07-27-2012, 11:46 AM   #2
Senior Member
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 413Reputation: 413Reputation: 413Reputation: 413Reputation: 413

Thats got all the info you want. If you have any specific questions after reading over it let me know.
1 members found this post helpful.
Old 07-28-2012, 05:13 PM   #3
Karl Godt
Registered: Mar 2010
Location: Kiel , Germany
Distribution: once:SuSE6.2,Debian3.1, aurox9.2+3,Mandrake?,DSL? then:W7st,WVHB, #!8.10.02,PUPPY4.3.1 now:Macpup
Posts: 308

Rep: Reputation: 45
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
1 members found this post helpful.
Old 07-29-2012, 05:26 AM   #4
David the H.
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954
"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.
1 members found this post helpful.
Old 07-29-2012, 12:03 PM   #5
LQ Guru
Registered: Mar 2008
Posts: 13,516

Rep: Reputation: 1720Reputation: 1720Reputation: 1720Reputation: 1720Reputation: 1720Reputation: 1720Reputation: 1720Reputation: 1720Reputation: 1720Reputation: 1720Reputation: 1720
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.
1 members found this post helpful.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Difference between Swap and Paging space ?? vikas027 Linux - General 3 09-02-2008 12:00 AM
swap file or swap space? simonb1975uk Linux - General 11 08-15-2008 02:39 PM
swap space (or) swap file yusufs Linux - Newbie 8 07-17-2008 02:02 AM
How to unmount actual swap and mount a new(bigger) swap space? isaac Linux - Newbie 1 06-06-2004 01:23 AM
Difference between Swap Virtrual memory and Swap Parition Nappa Slackware 4 11-27-2003 07:58 PM

All times are GMT -5. The time now is 08:49 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration