?
Solved

Repartition swap

Posted on 2003-11-05
12
Medium Priority
?
416 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
10 Comments
 
LVL 38

Expert Comment

by:yuzh
ID: 9692449
0
 
LVL 12

Accepted Solution

by:
paullamhkg earned 100 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
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 

Assisted Solution

by:Omeger
Omeger earned 100 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
This article will show you step-by-step instructions to build your own NTP CentOS server.  The network diagram shows the best practice to setup the NTP server farm for redundancy.  This article also serves as your NTP server documentation.
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.:
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month17 days, 4 hours left to enroll

862 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