?
Solved

creating swapfile on Centos 5.9 linux

Posted on 2014-07-30
15
Medium Priority
?
885 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
  • 6
  • 4
  • 3
  • +2
15 Comments
 
LVL 36

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 36

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 36

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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses
Course of the Month12 days, 19 hours left to enroll

579 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