LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-14-2005, 10:38 PM   #1
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Rep: Reputation: 31
Change the swap size


I hv newly setup the RH linux , it use auto partition method to install , I didn't define the swap partition size , if I want to install its size , is it possible ? if yes , how to do it ? thx.
 
Old 06-15-2005, 12:29 AM   #2
seran
Member
 
Registered: Aug 2004
Location: Bangalore
Posts: 64

Rep: Reputation: 16
use fdisk to create the swap partition( command t will ask for swap-id, give 82 for linux swap ).
and then do
mkswap /dev/hda*
swapon /dev/hda*
 
Old 06-15-2005, 06:37 AM   #3
pvs
Member
 
Registered: Jan 2005
Location: Lviv, Ukraine
Distribution: Something self-made
Posts: 69

Rep: Reputation: 16
the seran's answer is correct only if there left some free space (i don't think it is!). If your harddisk is fully partitioned you need to find some way to resize(or simply delete) some partition. More easier way is to create swap file:

dd if=/dev/zero of=/swapfile bs=1K count=<desired size in Kb>
mkswap /swapfile
swapon /swapfile

if you don't wish to tell "swapon /swapfile" every time you boot modify your /etc/fstab file and add record similar to created by your setup program (in case of automatic partitioning it usually exists)
 
Old 06-15-2005, 07:24 AM   #4
seran
Member
 
Registered: Aug 2004
Location: Bangalore
Posts: 64

Rep: Reputation: 16
Creating a swapfile instead of using a partition on the disk, is a good idea.

I tried creating a swapfile on my machine. I had a swap partition on /dev/hda2. I deleted this partition and added the swapfile entry inside /etc/fstab. I rebooted the machine and I saw this error message on the terminal.

Enabling swap partitions: could not create swap partition /swapfile [ERROR]

In the shell prompt I gave
mkswap /swapfile
swapon /swapfile
and then rebooted again. Then I got

Enabling swap paritions: [OK]

This worked fine for me.

So, I can use my /dev/hda2 partition for other purposes. This will be helpful if there is not enough space to create a swap partition on the disk. Today I am happy, I learned a new thing.
 
Old 06-15-2005, 07:45 AM   #5
pvs
Member
 
Registered: Jan 2005
Location: Lviv, Ukraine
Distribution: Something self-made
Posts: 69

Rep: Reputation: 16
Quote:
Originally posted by seran
I rebooted the machine and I saw this error message on the terminal.

Enabling swap partitions: could not create swap partition /swapfile [ERROR]
That's right: you can't use swap without "mkswap" first. It initializes a file/device so it cat be used as swap.
 
Old 06-15-2005, 08:11 AM   #6
seran
Member
 
Registered: Aug 2004
Location: Bangalore
Posts: 64

Rep: Reputation: 16
I thought this will be useful. http://www.linux-tutorial.info/modul...ial&pageid=218
 
Old 06-15-2005, 02:51 PM   #7
marcosdumay
LQ Newbie
 
Registered: Jan 2005
Distribution: Debian, testing
Posts: 19

Rep: Reputation: 1
Quote:
Creating a swapfile instead of using a partition on the disk, is a good idea.
It depends. Keeping the swap on a file is slower than on a partition. You will note the difference if you start using it often.

If you almost never use the swap, otherwise, you may choose to lose some speed (and response time) on those rare occasions and get a simpler partition scheme.
 
Old 06-16-2005, 12:25 AM   #8
edong23
Member
 
Registered: Apr 2005
Distribution: Slackware
Posts: 350

Rep: Reputation: 30
so..... i dont get it. you had a swap partition, on /dev/hda2 made by redhat, and you switched to a swapfile which is slower cause it uses the filesystem of the partition it is on, i think,,, and so now what with your swap partition. that makes no sense.!?!? did i miss something. that is like putting your root partition on a cd so you can just have an unused root partition on the harddrive.
 
Old 06-16-2005, 01:11 AM   #9
pvs
Member
 
Registered: Jan 2005
Location: Lviv, Ukraine
Distribution: Something self-made
Posts: 69

Rep: Reputation: 16
Quote:
Originally posted by edong23
so now what with your swap partition. that makes no sense.!?!? did i miss something.
1) it still can be used as swap-space
2) it can be formatted and used as a place for other files (not neccessary swap)
3) if you have 256Mb or more RAM Linux as a rule uses swap very rarely, so there is almost no speedup when using partition instead of file
 
Old 06-16-2005, 02:23 AM   #10
edong23
Member
 
Registered: Apr 2005
Distribution: Slackware
Posts: 350

Rep: Reputation: 30
as a rule huh. you must not use your linux box for what it is intended for. looong uptime, free software to do extensive audio and video encoding and ripping, multitasking ( like me downloading movies, while ripping mp3s, while encoding another movie, while instant messaging, while checking the forums, while playing the linux version of doom3, while downloading the linux version of quake, while also using another peer2peer to download the crack to the windows version of quake so that i may use the linux version, and all the while compiling the new 2.6.11.12 kernel. this is what i am doing right this minute, and yes i am accessing my swap space... i have 768MB Rambus mem@800mhz and i always make sure that my linux systems have at least a gig of swap. you dont want to sell yourself short incase you actually want to do something memory intensive. but anyway i jsut didnt understand y you wanted to have a swap file in place of a swap space.

btw. my uptime is 72 days 17 hours 46 minutes can you imagine? my mother is bound to kick the bucket real soon with all i put it through.
 
Old 06-16-2005, 03:18 AM   #11
pvs
Member
 
Registered: Jan 2005
Location: Lviv, Ukraine
Distribution: Something self-made
Posts: 69

Rep: Reputation: 16
Quote:
Originally posted by edong23
but anyway i jsut didnt understand y you wanted to have a swap file in place of a swap space.
I just advised to create swap file instead of resizing partitions, because it is simplier.
 
Old 06-16-2005, 11:04 PM   #12
edong23
Member
 
Registered: Apr 2005
Distribution: Slackware
Posts: 350

Rep: Reputation: 30
well yeah. it is sound advice. it is easier, but like i said i was confused as to y the user that posted the question.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Why should you give the size of the swap disk as twice the size of RAM vmniza Linux - Newbie 3 09-17-2004 02:13 AM
HowTo Change swap file size gee Linux - Newbie 2 02-26-2004 08:40 PM
change swap partition size? jamaso Linux - General 4 07-03-2002 09:46 AM
swap size kodiakmook Linux - Software 6 01-05-2002 12:52 AM
Right size swap? jamaso Linux - Newbie 7 11-12-2001 12:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:10 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