Need help with Extending Swap Partition.

General support questions
Post Reply
funkytechmonkey
Posts: 3
Joined: 2015/08/26 14:19:32

Need help with Extending Swap Partition.

Post by funkytechmonkey » 2015/08/26 15:17:11

Please excuse my terminology and lingo, for I am not very familiar with Linux.

We are running a Proxy CentOS 6server in a VM and I need to increase the Swapfile. This is a production machine so downtime has a critical impact on the company.

VM info:
CentOS 6.6
Memory 34 GB
HardDisk 1 - 50 GB
HardDisk 2 - 18GB

I just ran top cmd on this server and here are the results....
Mem: 34941356k total, 34575644k used, 365712k free, 310772k buffers
Swap: 5152764k total, 1500k used, 5151264k free, 10543844k cached

The SWAP was only set to 4 GB and I tried to increase it, but I was only allowed 5 GB of space.

This is where I need help. I am not too familiar swap, partitions, volumes, and volume groups in Linux (I will read up on this and get familiarized with it, but I need to resolve this asap so we do not have any issues)

So my question is: How do I increase the volume/partition(?) so I can extend the swapfile? and Can I do this during production hours?

Here is some information about these partitions/volumes ... Hopefully this will give you enough info to help me with the commands.

Code: Select all

#top
Mem:  34941356k total, 34575644k used,   365712k free,   310772k buffers
Swap:  5152764k total,     1500k used,  5151264k free, 10543844k cached
---------------------------
# swapon -s
Filename		Type		   Size	       Used	     Priority
/dev/dm-1        partition	   5152764	       1492	      -1
---------------------------
# fdisk -l

Disk /dev/sda: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00011967

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        3917    30944256   8e  Linux LVM
/dev/sda3            3917        6527    20970847+  8e  Linux LVM

Disk /dev/sdb: 19.3 GB, 19327352832 bytes
255 heads, 63 sectors/track, 2349 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xd569971e

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        2349    18868311   83  Linux

Disk /dev/mapper/vg_centostemplate-lv_root: 47.9 GB, 47857008640 bytes
255 heads, 63 sectors/track, 5818 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg_centostemplate-lv_swap: 5276 MB, 5276434432 bytes
255 heads, 63 sectors/track, 641 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
---------------------------
# df -m
Filesystem           1M-blocks   Used Available Use% Mounted on
/dev/mapper/vg_centostemplate-lv_root
                         44797  36496      6023  86% /
tmpfs                    17062      1     17061   1% /dev/shm
/dev/sda1                  477    116       336  26% /boot
//******01/****accounts
                        153469 141613     11857  93% /mnt/*****data/****accounts
//******303/****WorkingDir
                        204797 166487     38311  82% /mnt/*****303/****WorkingDir
//*****301/j****       524285 202339    321947  39% /mnt/*****301/j****
//*****01/Archive    511997 281207    230791  55% /mnt/*****01/Archive
//******201/***-data       204670 177616     27055  87% /mnt/*****201/***data


gerald_clark
Posts: 10642
Joined: 2005/08/05 15:19:54
Location: Northern Illinois, USA

Re: Need help with Extending Swap Partition.

Post by gerald_clark » 2015/08/26 16:08:35

You don't need more swap.
You are not using the swap you already have.
If you were you would be dead in the water, and more swap would only make it worse.

funkytechmonkey
Posts: 3
Joined: 2015/08/26 14:19:32

Re: Need help with Extending Swap Partition.

Post by funkytechmonkey » 2015/08/26 16:34:33

I read on CentOS' site that they recommend swap size should "equal 2x physical RAM for up to 2 GB of physical RAM, and then an additional 1x physical RAM for any amount above 2 GB, but never less than 32 MB."

Found here....

https://www.centos.org/docs/5/html/Depl ... space.html

funkytechmonkey
Posts: 3
Joined: 2015/08/26 14:19:32

Re: Need help with Extending Swap Partition.

Post by funkytechmonkey » 2015/08/26 16:36:26

If it is almost maxing out on physical memory shouldnt this be increased?

gerald_clark
Posts: 10642
Joined: 2005/08/05 15:19:54
Location: Northern Illinois, USA

Re: Need help with Extending Swap Partition.

Post by gerald_clark » 2015/08/26 16:37:13

That does not invalidate anything I said above.

aks
Posts: 3073
Joined: 2014/09/20 11:22:14

Re: Need help with Extending Swap Partition.

Post by aks » 2015/08/26 17:03:45

Hmph, if you're swapping, you've probably got bigger problems than the size of the swap partition!

jscarville
Posts: 135
Joined: 2014/06/17 21:50:37

Re: Need help with Extending Swap Partition.

Post by jscarville » 2015/08/26 19:57:51

1,500 K used of 5,152,764 K is nothing to worry about. If you are worried about RAM usage, cat /proc/meminfo is more useful than top.

MartinR
Posts: 714
Joined: 2015/05/11 07:53:27
Location: UK

Re: Need help with Extending Swap Partition.

Post by MartinR » 2015/08/27 14:13:26

Try using

Code: Select all

free -m
for a better view. The first line tells you about current memory usage but it is the second line that is the more important. It shows your memory usage if all buffers and caches were thrown away.

Linux tries to not throw away useful information. All file access passes through a buffer which the system will preserve as long as possible. If any data was modified the buffer is written out, but still retained. Should the data be needed again (write-close-read for example) it is available without the need for a disk access. An important part of this is the virtual filesystem. The kernel keeps track of the directory tree in memory so that files can be opened without the need to walk the tree. This information is "clean", that is available from elsewhere and can be deleted at a moment's notice if memory is needed for work. Therefore a running system should show memory nearly full, but typically a lot of that is this disposable cache. Hence the "do not worry" comments above.

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Need help with Extending Swap Partition.

Post by TrevorH » 2015/08/29 22:35:59

The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

Post Reply