Operating System - Linux
1820591 Members
2137 Online
109626 Solutions
New Discussion юеВ

extending swap space in LVM on a Linux RH 9

 
Ragni Singh
Super Advisor

extending swap space in LVM on a Linux RH 9

Hey all, I created a swap space of 3gig but in fact I need to create lvswap as a 4gig filesystem. Now that my swap space is created as 3gig, how can I increaase it to 4gig without blowing away my system. Any help is greatly appreciated.
2 REPLIES 2
Paulo A G Fessel
Trusted Contributor

Re: extending swap space in LVM on a Linux RH 9

This depends on how much space you have allocated on your file systems and which file system types you're using.

If you're using ReiserFS, you can reduce other file systems and associated LV's by 1 GB with resize_reiserfs; then, lvextend the swap space. Later, with the server in single-user mode, you can turn off swap, mkswap on the swap LV and swapon -a again.

If you're using ext3 - AFAIK, the standard of RH - then matters become more complicated. You'll need to put the server in single-user mode, as you'll need to:

* umount your ext3 file systems;
* remount them as ext2;
* umount them;
* ext2resize them in order to make space for the swap LV;
* resize and recreate the swap LV as described above;
* tune2fs -j them in order to make them ext3 again.

I don't know whether e2online is available on RH9; it's a bit risky to use it anyway.

HTH
Paulo Fessel
L'employ├Г┬й propose, le boss dispose.
Claudio Cilloni
Honored Contributor

Re: extending swap space in LVM on a Linux RH 9

I think you can add some temporary swap files on filesystems where there enough free space. example:

# dd if=/dev/zero of=/tmp/swap-file bs=1M count=1024
# mkswap /tmp/swap-file
# swapon /tmp/swap-file

this creates a 1 GB file in /tmp and mounts it as swap space. You can do this more than once with different files to get more additional swap space.

then you can unmount your lvswap volume (using swapoff), resize the volume and mount it again (with mkswap and swapon).

finally, unmount the swap-file (swapoff /tmp/swap-file) and delete it.

this should work.

P.S.: before umounting the lvswap volume verify that the swap space used can fit into the remaining swap-file. I there is a lot of used swap, this operation could take some time.

ciao
Claudio