LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 10-03-2004, 03:36 PM   #1
Cyric
Member
 
Registered: Sep 2004
Location: NC, USA
Distribution: Slackware 10
Posts: 109

Rep: Reputation: 15
Swap File


I was wondering about the swap file. I did not create one when installing slack 10. I have 512 MB of ram, do I need a swap file? And if so, can one be created now, after I have already done my installation?
 
Old 10-03-2004, 03:39 PM   #2
xushi
Senior Member
 
Registered: Jun 2003
Location: UK
Distribution: Gentoo
Posts: 1,288

Rep: Reputation: 45
You don't really need one with the ammount of RAM you have, but if you scan & edit a huge image, or play an intensive game (like ut2k4), you're computer would slow down to a halt.

I have a gig of ram, and linux hardly ever uses it all, but just incase, i left a very small swap there for safety.
 
Old 10-03-2004, 03:44 PM   #3
Cyric
Member
 
Registered: Sep 2004
Location: NC, USA
Distribution: Slackware 10
Posts: 109

Original Poster
Rep: Reputation: 15
Well, I guess I dont need one, then. This comp is just for running my various servers and learning how to use linux and it's applications. I have a windows box set up specifically for all my gaming needs.
 
Old 10-03-2004, 03:54 PM   #4
xushi
Senior Member
 
Registered: Jun 2003
Location: UK
Distribution: Gentoo
Posts: 1,288

Rep: Reputation: 45
Yea, i wouldn't worry too much about it if i were you. Just for the fun of it, you could always see how much Total ram is being used in the System Monitor. This will give you reassurance.. =)

Enjoy
 
Old 10-03-2004, 04:05 PM   #5
sh1ft
Member
 
Registered: Feb 2004
Location: Ottawa, Ontario, Can
Distribution: Slackware, ubuntu
Posts: 391

Rep: Reputation: 32
For proper performance i'm pretty sure linux requires a swap file. The kernel expects it to be there and as such the mem management is built to take advantage of it. If it is not there, you may see performance losses, even if it doesn't look like swap is being used. Also, since your using your box as a server, you don't want some memory leak taking it down, you need a certain amount of redundancy that swapspace provides. It's not like it takes a whole lot of space, you only need like 250-500mb.

It's easy to make swap space after the install, the hard part is partitioning it. But once you have the partition and have made the entry into fstab for it just do:

Code:
mkswap /dev/hdax
swapon -a

Last edited by sh1ft; 10-03-2004 at 04:08 PM.
 
Old 10-03-2004, 04:45 PM   #6
Cyric
Member
 
Registered: Sep 2004
Location: NC, USA
Distribution: Slackware 10
Posts: 109

Original Poster
Rep: Reputation: 15
how would I go about making the partition?
 
Old 10-03-2004, 05:55 PM   #7
sh1ft
Member
 
Registered: Feb 2004
Location: Ottawa, Ontario, Can
Distribution: Slackware, ubuntu
Posts: 391

Rep: Reputation: 32
Well, that depends on alot of things, like what filesystem your using and how many partitions you have and where they are mounted.

For all intents and purposes you will likely have to delete a partition and split off a chunk for swap space, then recreate the partition. I have no clue about resizing partitions in linux, but it is highly dependant on what filesystem you use, and I think it is not very reliable/easy in any case. This question is enough for a whole seperate thread, it's a suprisingly difficult issue if you do not want to delete any of your partitions which you already have or lose data on them.
 
Old 10-03-2004, 06:10 PM   #8
Cyric
Member
 
Registered: Sep 2004
Location: NC, USA
Distribution: Slackware 10
Posts: 109

Original Poster
Rep: Reputation: 15
well, I only have one partition, so I dont think deleting it is an option, gonna have to resize....how hard is it gonna be?
 
Old 10-04-2004, 02:22 AM   #9
Cerbere
Member
 
Registered: Dec 2002
Location: California
Distribution: Slackware & LFS
Posts: 799

Rep: Reputation: 33
You can check out this project for info about resizing partitions.

But it would be much easier to simply set up a swap file. The performance is slightly less than with a dedicated partition, but since you have 512Megs of RAM and are seeing little swap use anyway, the only need for swap is for insurance in case your system should exhaust the actual memory.

You can set up a swap file with the following steps:

1) cd /
2) dd if=/dev/zero of=swap.file bs=1M count=512
3) mkswap swap.file
4) swapon swap.file

This will create a 512Mb swap file in your root directory. To check that it has worked, run the command 'free' and it should show your physical, as well as swap memory. To have this swap setup on each reboot, add the following line to /etc/fstab:
Code:
/swap.file    swap          swap     defaults             0   0
Enjoy!
--- Cerbere
 
Old 10-04-2004, 04:08 AM   #10
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
There is really no need for swap if you have enough physical RAM.

The kernel is now advanced enough that it can operate with or without a swap, and any programs that require swap to operate are fundamentally broken in the first place.

If you are just using this machine for testing purposes, I wouldn't bother even putting a swap file in, let alone a swap partition.
 
Old 10-04-2004, 10:49 AM   #11
Cyric
Member
 
Registered: Sep 2004
Location: NC, USA
Distribution: Slackware 10
Posts: 109

Original Poster
Rep: Reputation: 15
OK, thanks for your help guys. I am going to be using this box as a continuously running server soon, so I went ahead and added the swap file in just to be on the safe side.

Thanks AGAIN!
 
Old 10-04-2004, 12:56 PM   #12
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
sh1ft is absolutely right. Even if you have huge amounts of RAM, every nowand then the kernel will deem it prudent to swap out a few KB, or even less. If there is NO swap available, more time is lost looking for it than would be lost in doing it. You can always create a small SWAPFILE(not partition) in your /root dirlike this
dd if=/dev/zero of=/root/swapfile bs=512k count=1
mkswap /root/swapfile
swapon /root/swapfile
Then put:
/root/swapfile swap swap defaults 0 0
in your /etc/fstab and be done with it.
ZipSlack comes with a 512KB swapfile like this, and the install.zip installer has a 10MB swapfile.
It's worth noting that the minimum size of swap allowed is only 4K! Some machines will seize up without any swap at all.
 
Old 10-04-2004, 03:08 PM   #13
Sabicas
Member
 
Registered: Aug 2004
Distribution: Slackware 10
Posts: 110

Rep: Reputation: 15
Hmm, I have always read/heard that you should always have a swap partition thats twice the size as your computers ram.
 
Old 10-04-2004, 11:19 PM   #14
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
'twice the size of RAM' used to be recommended when the typical amount of RAM was 8-32MB.
 
  


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
what is a swap file...? zameer_india Linux - Newbie 8 01-09-2005 10:35 PM
swap file linuxhippy Linux - General 4 10-11-2004 04:07 PM
Swap file not being used...why? ganja_guru Linux - General 6 12-08-2003 03:41 AM
Swap file sparkplug55 Linux - Newbie 2 08-11-2003 09:09 AM
No Swap File tarballedtux Slackware 4 01-09-2003 02:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 06: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
Open Source Consulting | Domain Registration