Solved

Repartition swap

Posted on 2003-11-05
12
410 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
12 Comments
 
LVL 38

Expert Comment

by:yuzh
ID: 9692449
0
 
LVL 12

Accepted Solution

by:
paullamhkg earned 25 total points
ID: 9692460
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
ID: 9692472
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
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 

Assisted Solution

by:Omeger
Omeger earned 25 total points
ID: 9693418
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
ID: 9693432
You will probably first want to check if you have enough space on your harddisk.
0
 
LVL 12

Expert Comment

by:paullamhkg
ID: 9698284
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
ID: 9698769
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
ID: 9698770
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
ID: 9698853
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
ID: 9770655
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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

690 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