Solved

Repartition swap

Posted on 2003-11-05
12
396 Views
Last Modified: 2013-12-16
My harddisk has 20GB, with 256MB ram.
Recently I added 256MB to it, so I want to increase the size of swap partition from 512MB to 1024MB. But i have partitioned all space in the harddisk. Any suggestions to achieve this?
0
Comment
Question by:takwing
12 Comments
 
LVL 38

Expert Comment

by:yuzh
Comment Utility
0
 
LVL 12

Accepted Solution

by:
paullamhkg earned 25 total points
Comment Utility
So do you have another Harddisk can add in? if no, you need to resize some of your existing partitions to get space for increase the swap. have a look here for repartition your harddisk without loosing the data http://www.europe.redhat.com/documentation/HOWTO/PLIP-Install-HOWTO-11.php3 (this is free), or you can use the partition magic or partition manager (those are not free). you can also using those to increase the size of you swap space.

if you have another harddisk, it's more easier, just add the extra harddisk into your linux box, after that, use the fdisk to create the swap partition, after that change your /etc/fstab

/dev/hda7               swap                    swap    defaults        0 0    <--- original entry

change to

/dev/hdc1               swap                    swap    defaults        0 0     <--- the new swap and I assume you have the new harddisk plug into seconday IDE slave

That it.
0
 
LVL 12

Expert Comment

by:paullamhkg
Comment Utility
yuzh, no offence, the link you show here is talking about someone didn't have the partition, and try to create one, but takwing already have the partition, just need to increase it. but takwing do need the mkswap to format the swap partition after the swap partition created of my second suggestion (using another harddisk)
0
 

Assisted Solution

by:Omeger
Omeger earned 25 total points
Comment Utility
It is possible to create a swapfile.
Example:
To create a swapfile in current dir of 512MB:
[root@ee /opt]# dd if=/dev/zero of=swapfile bs=1M count=512
(This has created the file /opt/swapfile)
To modify it so that it is not world-readable:
[root@ee /opt]# chmod 600 swapfile
Enabling the swap area:
[root@ee /opt]# mkswap swapfile
[root@ee /opt]# swapon swapfile

Now you can enable it at boot time by editing your /etc/fstab:
(adding something like this)
/opt/swapfile swap swap defaults 0 0

0
 

Expert Comment

by:Omeger
Comment Utility
You will probably first want to check if you have enough space on your harddisk.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 12

Expert Comment

by:paullamhkg
Comment Utility
Omeger no offence, takwing already said "But i have partitioned all space in the harddisk" most likely takwing got no space for the new partition, that why I suggest to use the repartition tools or add a new harddisk.

takwing, am I right? more info will help us to give out suggestion :)
0
 
LVL 9

Expert Comment

by:majorwoo
Comment Utility
paullamhkg

omeger's solution does not make a partion, but instead a swapfile inside of the file (filesystem inside a file)
so he could place it on whatever partiton he has space on
0
 

Author Comment

by:takwing
Comment Utility
paullamhkg is rite. I have no space left.
And thanks for suggesting repartition tools to resize my root partition and swap partition.
0
 
LVL 12

Expert Comment

by:paullamhkg
Comment Utility
Yes, I understand Omeger's solution after majorwoo comment, I'm sorry Omeger.

takwing, Omeger give you hint on instead of create a swap partition or resize your partition, this is another work around solution is create a swapfile and make use of the swapfile to become your swap. his example is assuming your partition of /opt have space for create a swapfile so create a swapfile inside /opt "dd if=/dev/zero of=swapfile bs=1M count=512" this will create a swapfile inside /opt called /opt/swapfile and the size is 512MB, afterward format the /opt/swapfile as swap 'mkswap /opt/swapfile', and make it alive 'swapon /opt/swapfile', up to this point you will have a new swap space and it is 512MB.

and Omeger also show you how to create the mount point at the /etc/fstab, so that everytime you reboot/restart the new swap space will mount up and turn on as swap.

the only difference is you will use up some of the diskspace of other partition.

Everything will be on your only choice. But sure this is good to learn :)
0
 
LVL 2

Expert Comment

by:sam_sunder
Comment Utility
Hello Takwing,

There is no need to create a new partition. You can use the existing partion provided there is free space by just creating a swap file.
follow the steps which omeger  gave. That will work fine. I  think it is not a must for you to create swap partition because
you have a very good RAM.  Go for it if you are using it as a heavy duty server.

regards,

sam
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now