?
Solved

creating swapfile on Centos 5.9 linux

Posted on 2014-07-30
15
Medium Priority
?
824 Views
Last Modified: 2014-08-06
Hi,

I need more memory so I was reading this page:
https://www.linux.com/news/software/applications/8208-all-about-linux-swap-space

#free -m
             total       used       free     shared    buffers     cached
Mem:          1024       1024          0          0          0          0
-/+ buffers/cache:       1024          0
Swap:            0          0          0

Open in new window


A couple of questions:
(1)
I ran this:

dd if=/dev/zero of=/swapfile bs=1024 count=2048576

the above command ran fine.

But this command gives me a "command not found" error:
mkswap /swapfile

Also, I don't have the command:
swapon -s

(2)
If I create the swapfile then will it free my physical RAM?

(3)
Are there any other considerations I need to make so nothing breaks or happens?

Thank you and Father bless<><
0
Comment
Question by:Victor Kimura
[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
  • 6
  • 4
  • 3
  • +2
15 Comments
 
LVL 35

Assisted Solution

by:Seth Simmons
Seth Simmons earned 856 total points
ID: 40230885
i would add more physical memory rather than increase/add swap partitions as there is a performance hit
i once had a couple servers low on memory and were swapping a lot and performance was horrible since disk usage was higher from swapping and was affecting applications

does mkswap and swapon live under /sbin ?  ls -lh /sbin/mkswap
0
 
LVL 62

Assisted Solution

by:gheist
gheist earned 576 total points
ID: 40231026
You should not use swap file. When one installs RHEL5 it creates swap partition. So you actually need to check partitions and just enable swap on that swap partition.
0
 
LVL 18

Assisted Solution

by:TobiasHolm
TobiasHolm earned 284 total points
ID: 40231333
1. Locate the commands. You could use find to do this:
$ sudo find / -name mkswap
$ sudo find / -name swapon

2. Yes, but at cost of performance.

3. No, besides performance will be much lower compared to adding more physical RAM.
0
A new era in Cloud training has arrived.

A day that will go down in Cloud history.. But are you ready for it? Will you accept this Cloud challenge?

 
LVL 10

Assisted Solution

by:ssvl
ssvl earned 284 total points
ID: 40231426
I hope you are ruuning these commands as sudo.

./mkswap /swapfile" and "./swapon /swapfile" in /sbin directory so use the full path

some distributions su root has a different PATH than logging in as root. Thus the mkswap command might be found as root but not as su root. Try logging in as root to run mkswap. Or you can find mkswap and give the full path to the command in su root.
0
 

Author Comment

by:Victor Kimura
ID: 40233292
Ok, thank you all! =)

So I shouldn't use swap at all then? I was going to just test and see what the performance will be like. How do I undo the swapfile after the test? What are the commands to unswap the file or partition?

@gheist, just curious how do I find out how which device is the swap partition? I'm on a VDS from gd hosting. Currently, Centos 5.9.
0
 
LVL 35

Assisted Solution

by:Seth Simmons
Seth Simmons earned 856 total points
ID: 40233302
use swapoff <filename>

fdisk -l will show the partitions
on the right it will be listed as linux swap (id 82)
0
 

Author Comment

by:Victor Kimura
ID: 40233357
I get this with fdisk:


root@ip-184-168-116-73 [/home/myultrat/public_html/l4]# fdisk -l
bash: fdisk: command not found
root@ip-184-168-116-73 [/home/myultrat/public_html/l4]# /sbin/fdisk -l
cannot open /proc/partitions

Open in new window

0
 
LVL 35

Assisted Solution

by:Seth Simmons
Seth Simmons earned 856 total points
ID: 40233367
looks like you are using a hosted cloud service
they could have done something with the OS to behave that way
likely explains why your swap command aren't working either
0
 

Author Comment

by:Victor Kimura
ID: 40233379
yeah, it's a VDS with godaddy. Anyone suggest a better VDS that doesn't have restrictions? A friend recommended mochhosting.
0
 
LVL 62

Accepted Solution

by:
gheist earned 576 total points
ID: 40233620
You can choose from http://lowendbox.com/

At least in RHEL6 you can have compcache as an indication when you are running short in RAM, so you dont need the swap file for this purpose.
0
 

Author Comment

by:Victor Kimura
ID: 40242590
@gheist, wow, those are really cheap. Are there some good tutorials on compcache setup? Tried looking but there doesn't seem to be that much info on it. I'm running Centos 5.9 but RHEL is similar I would think.
0
 

Author Closing Comment

by:Victor Kimura
ID: 40242606
Bless you all! =)
0
 
LVL 62

Expert Comment

by:gheist
ID: 40242833
On RHEL6 you can use compcache as an indication when swapping occurs.
RHEL 5, CentOS 5 , Oracle Linux 5 , Scientific Linux Boron do not fall in RedHat v6 category by any means.
0
 

Author Comment

by:Victor Kimura
ID: 40242863
@gheist, ok, thanks! Are there tutorials on compcache? How does one view it and if there is something we need it make it active or does it come standard?
0
 
LVL 62

Expert Comment

by:gheist
ID: 40245176
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

1. Introduction As many people are interested in Linux but not as many are interested or knowledgeable (enough) to install Linux on their system, here is a safe way to try out Linux on your existing (Windows) system. The idea is that you insta…
Fine Tune your automatic Updates for Ubuntu / Debian
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.
Suggested Courses

777 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