Solved

Repartition swap

Posted on 2003-11-05
12
401 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
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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

813 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

18 Experts available now in Live!

Get 1:1 Help Now