Operating System - Linux
1753335 Members
5325 Online
108792 Solutions
New Discussion юеВ

Re: Increase in swap space.

 
bhaski
Advisor

Increase in swap space.

Hello,

We are running a system with following detail,

Linux bwga090 2.6.16.21-0.8-bigsmp #1 SMP Mon Jul 3 18:25:39 UTC 2006 i686 i686 i386 GNU/Linux

The output of df -k is .

bwga090:/var/log # df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 20641788 5444456 14148692 28% /
udev 2011504 140 2011364 1% /dev
/dev/sda1 202219 7278 184501 4% /boot
/dev/mapper/system-SYSTEM_OPT
25803068 8709232 15783116 36% /opt
/dev/mapper/system-SYSTEM_VAR
20642428 16323104 3270748 84% /var
/dev/md0 34977152 23225264 9975116 70% /var/home
/var/ftp/pub/suse/ix86
20642428 16323104 3270748 84% /srv/ftp

I have attached the yast present partition scenario. can anyone help how to increase the swap space from 4GB to 8GB.
option 1) we can create partition in already existing LVM and add it to swap, but it will be end of disk which will result in reduced performance.

Is there way to increase the present swap from 4GB to 8GB.

Thanks & Regards,
Bhaski
5 REPLIES 5
Ivan Ferreira
Honored Contributor

Re: Increase in swap space.

You can increase only if you have free space in the system volume group. Post the output of:

vgdisplay -v system

If you don't have free PPs, you must reduce the size of another file system in 4 G and then extend the swap logical volume.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
bhaski
Advisor

Re: Increase in swap space.

Hello Ivan,

The output is as follows,

bwga090:/var/log # vgdisplay -v system
Using volume group(s) on command line
Finding volume group "system"
--- Volume group ---
VG Name system
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 112.52 GB
PE Size 4.00 MB
Total PE 28805
Alloc PE / Size 11520 / 45.00 GB
Free PE / Size 17285 / 67.52 GB
VG UUID Y9ohUC-LKzO-WeHs-gueK-tARz-M8qI-Hd7WcX

--- Logical volume ---
LV Name /dev/system/SYSTEM_OPT
VG Name system
LV UUID iQxxEJ-AdVy-6dvT-LUhJ-lJSH-Bk6z-ZNSZ27
LV Write Access read/write
LV Status available
# open 1
LV Size 25.00 GB
Current LE 6400
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 253:0

--- Logical volume ---
LV Name /dev/system/SYSTEM_VAR
VG Name system
LV UUID Eq75jD-ra2t-yC9J-YrJs-ALrY-yKgn-t8LcLK
LV Write Access read/write
LV Status available
# open 1
LV Size 20.00 GB
Current LE 5120
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 253:1

--- Physical volumes ---
PV Name /dev/sda4
PV UUID rc0kZT-Vqr3-o4WW-HaiP-l1Oi-rZpJ-DxHWju
PV Status allocatable
Total PE / Free PE 28805 / 17285

[1]+ Done yast2
bwga090:/var/log #

Thanks & Regards,
Bhaski
Ralph Grothe
Honored Contributor

Re: Increase in swap space.

Hi Bhaski,

from the output of your vgdisplay -v system
one can see that you have plenty of unused PEs (over 67 GB).
So you could well create a new volume of 4 GB that you could use for swap.
However, unless the developers of the block device and LVM code haven't fixed this yet,
the general consensus has been that it performance wise was a bad idea to pu a swap device on an LVM volume.
But nevertheless it does work.
We have forcedly done this because unlike you we really ran short of unused disk space.

So you could do this

# lvcreate -L 4g -n lv_secswap system

Btw, a bad name for a VG "system", or was that name chosen by the Yast installer?
They at least should have prepended something like "vg".
With Linux LVM you can change a VG's (and LV's) name a postiori (unlike with HP-UX LVM)
but this would also require you to adapt the entries in /etc/fstab (unless it is automatically updated at reboot by some HAL daemon).
Sorry, for disgressing.

After LV creation verify with

# lvdisplay /dev/system/lv_secswap

Then prepare it to be initialized as swap.
Be careful to not mix up with other volumes
because it renders any data on it useless!

# mkswap /dev/system/lv_secswap

Then add an entry for your new swap in fstab
(better use an editor like vi)

# echo "/dev/system/lv_secswap swap swap pri=10 0 0" >> /etc/fstab

I deliberately chose (an optional) lower priority (bigger number) to make the system first use your better performing primary swap that must have been a "raw" disk partition like /dev/sda?

Finally, activate the new swap device by

# swapon -a

And check it has been activated

# swapon -s

or

# cat /proc/swaps

That's it.
Now you should see 2 4 GB swap devices.

Since you presumably have free space somewhere else (i.e. not captured in an LVM PV)
I would however advise you to use this instead for swap.
You already have RAID devices.
How about creating a new one?

Check what you already got

# mdadm -QDs

or per device

# mdadm -QD /dev/md0

etc.

Also look at your disks if you have free space to create a further RAID partition.

# fdisk -l /dev/sd[ab]

The creation of swap is the same,
no matter if on an LVM volume, an MD RAID device, or a naked disk partition.









Madness, thy name is system administration
Stuart Browne
Honored Contributor

Re: Increase in swap space.

Something else to note is that when using multiple swap partitions (whether under LVM or not), the system will stipe across them to get better performance.

But if everythings on a hardware RAID platform anyway, it's kinda moot.. ;P
One long-haired git at your service...
bhaski
Advisor

Re: Increase in swap space.

Hi Ralph,

Thank you very much, for your detailed list.
If there is no other way, i will plan to do this on next weekend as i fear getting inoperable during week day.

And about the name of VG, it was done by former colleague,so dont know what stuck his mind to keep that name.

There is absoutely no additional space apart from that in LVM or we need to add an external disk.

I have following 3 doubts.
1) There is a discussion in group, that adding new logical volume in existing VG as SWAP will hinder performance and also it will be at end of disk. Is this true?
2) Can we decrease the size of VG(system) by 4GB and add that to SWAP???
3) this might sound stupid - can we decrease the size of /dev/sda3 ( / partition ) by 4GB and add it to swap? Is this possible?? if so recommendable??

Thanks & Regards,
Bhaski