Solved

creating swapfile on Centos 5.9 linux

Posted on 2014-07-30
15
727 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 34

Assisted Solution

by:Seth Simmons
Seth Simmons earned 214 total points
Comment Utility
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 61

Assisted Solution

by:gheist
gheist earned 144 total points
Comment Utility
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 71 total points
Comment Utility
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
 
LVL 10

Assisted Solution

by:ssvl
ssvl earned 71 total points
Comment Utility
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
Comment Utility
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 34

Assisted Solution

by:Seth Simmons
Seth Simmons earned 214 total points
Comment Utility
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
Comment Utility
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 34

Assisted Solution

by:Seth Simmons
Seth Simmons earned 214 total points
Comment Utility
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
Comment Utility
yeah, it's a VDS with godaddy. Anyone suggest a better VDS that doesn't have restrictions? A friend recommended mochhosting.
0
 
LVL 61

Accepted Solution

by:
gheist earned 144 total points
Comment Utility
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
Comment Utility
@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
Comment Utility
Bless you all! =)
0
 
LVL 61

Expert Comment

by:gheist
Comment Utility
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
Comment Utility
@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 61

Expert Comment

by:gheist
Comment Utility
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

The purpose of this article is to show how we can create Linux Mint virtual machine using Oracle Virtual Box. To install Linux Mint we have to download the ISO file from its website i.e. http://www.linuxmint.com. Once you open the link you will see …
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…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

763 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

11 Experts available now in Live!

Get 1:1 Help Now