Solved

creating swapfile on Centos 5.9 linux

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

Assisted Solution

by:Seth Simmons
Seth Simmons earned 214 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 144 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 71 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 10

Assisted Solution

by:ssvl
ssvl earned 71 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 34

Assisted Solution

by:Seth Simmons
Seth Simmons earned 214 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 34

Assisted Solution

by:Seth Simmons
Seth Simmons earned 214 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 144 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you use Debian 6 Squeeze and you are tired of looking at the childish graphical GDM login screen that is used by default, here's an easy way to change it. If you've already tried to change it you've probably discovered that none of the old met…
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 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.:
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.

756 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