Solved

creating swapfile on Centos 5.9 linux

Posted on 2014-07-30
15
734 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
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 61

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
 
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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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 61

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 61

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 61

Expert Comment

by:gheist
ID: 40245176
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
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…
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…

863 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