LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 12-01-2011, 08:51 AM   #1
citi
Member
 
Registered: Jan 2011
Location: Lithonia, GA
Distribution: Ubuntu,Fedora,puppy,CentOS
Posts: 36

Rep: Reputation: 6
Swap Folder?


Quote:
Originally posted by TobiSGD
For swap you can use a file instead of a partition
How do you create a swap folder? And why would you(other than to save partition space)?
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 12-01-2011, 08:58 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
you don't create a folder, where does is say that?? you can make a swap file by creating a block file (i.e. from dd) on an existing file system and using mkswap on that as opposed to a partition.

Not sure what you mean by "partition space" here, you won't save any space, you just use it elsewhere. Personally I've made them in the past when I've needed more swap but not been able to allocate real disk. You can also make an LVM volume a swap device too, amongst many other things.
 
Old 12-01-2011, 01:03 PM   #3
citi
Member
 
Registered: Jan 2011
Location: Lithonia, GA
Distribution: Ubuntu,Fedora,puppy,CentOS
Posts: 36

Original Poster
Rep: Reputation: 6
Quote:
Not sure what you mean by "partition space"
For a lack of a better or right word to call it. From what I understand, you can only create 4 Primary partitions, or 3 Primary and 1 Extended Partition. Does making swap a folder allow for an extra Primary partition.
 
Old 12-01-2011, 01:05 PM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
again, swap is never a folder.

you can make however many logical partitions you want under an extended partition, so that's not an issue, no. Generally you wouldn't want to go through a filesystem to get swap on to a disk, so you would avoid it.
 
1 members found this post helpful.
Old 12-01-2011, 03:48 PM   #5
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,130
Blog Entries: 2

Rep: Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825
Quote:
Originally Posted by acid_kewpie View Post
Generally you wouldn't want to go through a filesystem to get swap on to a disk, so you would avoid it.
Have a look here, the kernel won't use the file-system for a swap-file.
 
1 members found this post helpful.
Old 12-01-2011, 05:07 PM   #6
jefro
Moderator
 
Registered: Mar 2008
Posts: 15,374

Rep: Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198
"Note that I said swap spaces and not just swap device or swap partition. Linux allows you to create a swap file. Like any other file, a swap file exists on your filesystem and takes up space. The advantage is that you can add a swap file at any time, provide you have the space on the hard disk. You don't need to to repartition your hard disk or even reboot. "

From here. http://www.linux-tutorial.info/modul...ent&pageid=218

There may be other reasons that may have to do with managing partitions or hardware limits but that would be more rare.
 
1 members found this post helpful.
Old 12-01-2011, 05:24 PM   #7
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
First of all, let's get our terms straight. A "folder" is a (virtual) container for "files". But actually *nix prefers the term "directory" instead. "Folder" is the Dos/Windows word for it.

"swap" is not a file, or directory. It's a filesystem. It's essentially virtual RAM; hard disk space that can be used as a RAM substitute. It's mostly there for times when you don't have enough physical RAM memory to handle your requirements, but also for things like storing the current running image when suspending your session.

There are two options for creating a swap filesystem:

1) You can set up a dedicated partition for it. This option is better for performance, as the swap filesystem can be accessed directly by the kernel. But of course it's also a permanent allocation, as the disk space can't be made available for any other use.

2) Create a swap file. This is an image file of a swap filesystem sitting inside another file system. The advantage here is that you can create and delete swap files as needed, in any number and size. The disadvantage is that the kernel has to access it through the I/O of the containing partition, meaning it's not as efficient performance-wise.

Whichever solution you choose, or both, is up to you.


Note that the disk partition limits really have nothing to do with swap, which is just another kind of filesystem you can place on a partition. As you seem to understand, a disk with DOS-style partition allocation can only have 4 primary partitions. If you need more, then you can specify one of these partitions to be an "extended" partition, and then create a larger number of "logical" partitions inside of that. The Linux libata driver can currently handle up to 15 partitions on a drive, so for most people this is not a serious limitation.

But if you really need all of your partition space for other things, then yes, using a swap file means you don't have to dedicate a partition for it.
 
4 members found this post helpful.
Old 12-01-2011, 06:07 PM   #8
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,130
Blog Entries: 2

Rep: Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825
Quote:
Originally Posted by David the H. View Post
...

This option is better for performance, as the swap filesystem can be accessed directly by the kernel. But of course it's also a permanent allocation, as the disk space can't be made available for any other use.

2) Create a swap file. This is an image file of a swap filesystem sitting inside another file system. The advantage here is that you can create and delete swap files as needed, in any number and size. The disadvantage is that the kernel has to access it through the I/O of the containing partition, meaning it's not as efficient performance-wise.
As already stated above (post #5), the kernel will directly access swap files (if it is a 2.6 or newer kernel), not through the I/O of the partitions filesystem, so there should be no performance decrease when using swap files.
 
2 members found this post helpful.
Old 12-01-2011, 06:20 PM   #9
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
Quote:
Originally Posted by TobiSGD View Post
Have a look here, the kernel won't use the file-system for a swap-file.
Oh right, makes a lot of sense. Ta.
 
Old 12-01-2011, 07:30 PM   #10
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
Quote:
Originally Posted by TobiSGD View Post
As already stated above (post #5), the kernel will directly access swap files (if it is a 2.6 or newer kernel), not through the I/O of the partitions filesystem, so there should be no performance decrease when using swap files.
Yeah, but I could only clearly know that if I'd bothered to follow the link.

Seriously, thanks for the info. So are there any real disadvantages to using swap files now?

Last edited by David the H.; 12-01-2011 at 07:31 PM.
 
Old 12-01-2011, 11:43 PM   #11
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,130
Blog Entries: 2

Rep: Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825
Actually, i can't think of any, except may be if you create a swap file on a heavy fragmented drive. But since I always use a partition, just because I am used to it, I simply lack experience here.
 
Old 12-02-2011, 04:43 AM   #12
citi
Member
 
Registered: Jan 2011
Location: Lithonia, GA
Distribution: Ubuntu,Fedora,puppy,CentOS
Posts: 36

Original Poster
Rep: Reputation: 6
Thanks Guys, I originally post the question to find out if there was an advantage/disadvantage in creating a swap folder, over the usual swap partition.
Tobi mentioned it in another post, I'd never heard of a swap folder b4 then.

Last edited by citi; 12-02-2011 at 04:52 AM.
 
Old 12-02-2011, 06:02 AM   #13
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
there is *STILL* no such thing as a swap folder.
 
Old 12-02-2011, 06:13 AM   #14
citi
Member
 
Registered: Jan 2011
Location: Lithonia, GA
Distribution: Ubuntu,Fedora,puppy,CentOS
Posts: 36

Original Poster
Rep: Reputation: 6
Swap file, my bad.
 
  


Reply


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
How to swap out (to swap area) page frames a process use? entertainyou Linux - Kernel 3 03-23-2011 10:52 PM
Gparted says swap has 5 Gb, grep SwapTotal /proc/meminfo says swap has 800 Mb rickrandall Red Hat 3 02-24-2010 01:09 PM
SWAP - having trouble with swap auto mounting at boot lostdj Linux - General 2 08-05-2008 01:47 PM
Squid swap folder creation problem selvamporko Linux - Software 1 06-22-2005 09:56 PM
How to unmount actual swap and mount a new(bigger) swap space? isaac Linux - Newbie 1 06-06-2004 02:23 AM


All times are GMT -5. The time now is 10:13 AM.

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