Scientific Linux Forum.org



  Reply to this topicStart new topicStart Poll

> How to resize a logical volume
zeusys
 Posted: Jul 12 2011, 01:30 PM
Quote Post


SLF Newbie


Group: Members
Posts: 1
Member No.: 378
Joined: 4-July 11









Hi
I want to resize LogVol00 which is mounted as / partition.
I need to know if it's possible to resize it (-2GB) or not ? and if yes, how I can do that?

After that I want to use this released space as my swap.How I can access to that free space using fdisk?


CODE

[root@localhost ~]# lvdisplay
 --- Logical volume ---
 LV Name                /dev/VolGroup/LogVol00
 VG Name                VolGroup
 LV UUID                rW2Ayz-IGuE-9buy-G0B5-Eohr-TtVw-8TWT7e
 LV Write Access        read/write
 LV Status              available
 # open                 1
 LV Size                319.51 GiB
 Current LE             81794
 Segments               1
 Allocation             inherit
 Read ahead sectors     auto
 - currently set to     256
 Block device           253:0
PM
^
scottro
 Posted: Jul 12 2011, 07:52 PM
Quote Post


SLF Member
***

Group: Members
Posts: 70
Member No.: 49
Joined: 14-April 11









Reducing volumes always has a bit of risk. Not that much risk, but a bit...it also takes longer than enlarging.

http://tldp.org/HOWTO/LVM-HOWTO/reducelv.html

Has a reasonable writeup on it.
PM
^
spoovy
 Posted: Jul 12 2011, 08:18 PM
Quote Post


SLF Moderator
****

Group: Moderators
Posts: 258
Member No.: 5
Joined: 8-April 11









Doesn't system-config-lvm support shrinking volumes?


--------------------
PMIntegrity Messenger IM
^
scottro
 Posted: Jul 12 2011, 10:57 PM
Quote Post


SLF Member
***

Group: Members
Posts: 70
Member No.: 49
Joined: 14-April 11









Hrrm, probably does. I've never used it. To be honest, I haven't found myself, in a long time, having a need to shrink--usually, it's just been swap, where a default install made it too large, and I forgot until afterwards. When that happens, I just delete it, enlarge what I need to enlarge, then re-create.

It's a pity that disk druid, which is a pretty easy to use partitioning tool, is only available during install, as far as I know. Gparted doesn't handle LVM and the system-config-lvm tool is somewhat limited, not showing you if there's an existing non LVM partition that you'll wind up destroying.
PM
^
NeoAmsterdam
 Posted: Jul 13 2011, 05:05 AM
Quote Post


SLF Member
***

Group: Members
Posts: 142
Member No.: 181
Joined: 16-May 11









Last time I tried with system-config-lvm, it deleted the existing LVM and created a new one in its place. dry.gif

Since the drives comprising the LVM had no data, there was no risk*. But I'd prefer to use the command line as per the LVM How-To if there's anything that needs be kept on the LVM.

* Back up early, and back up often. http://th166.photobucket.com/albums/u117/rdshear/Smiley%20Faces/th_smiley-face-thumbs-up.gif
PM
^
helikaon
 Posted: Jul 13 2011, 08:00 AM
Quote Post


SLF Moderator
******

Group: Moderators
Posts: 603
Member No.: 4
Joined: 8-April 11









Hi,
is the volume filling up whole space of the VG or is there some space left there? Is this only volume you have in the volume group?

post here output of:
# vgdisplay

Anyway, i suppose, you have this scenario:
1. Whole HDD taken by one VG (volume group) and the space of VG whole taken by one LV (logical volume).
2. you want to create new LV for swap entirely ... here comes to my mind big Question - where is your swap located now? Is there any? :-)

Basic law for playing with LVM:
1. to downsize (decrease, shrink) size of LV (logical volume) you need to FIRST UNMOUNT the FS that is created on the LV
2. to increase size of LV, you can SAFELY do it WHILE the FS is MOUNTED

Procedure:
1. reduce filesystem (suppose its ext3 FS, maybe ext4 right?) => unmounting REQUIRED => you need to boot from bootable CD so that your root FS is not active and mounted!
2. shrink LV LogVol00
3. create new LV in the freed space

NOTE: here we have problem - your only existing LV is mounted as root partition ("/"). Therefore you can not shrink it while system is booted - remember the FS has to be unmounted first - and unfortunatelly you can NOT unmount root FS (which makes sense ofc) smile.gif So you need to boot from bootable CD.

Commands to resize
CODE

e2fsck -f /dev/VolGroup/LogVol00 (to check the FS against errors)
resize2fs /dev/VolGroup/LogVol00 300000M
lvreduce /dev/VolGroup/LogVol00 -L 300010M


now you'd have roughly 20GB free space on VG - check it with
CODE

vgdisplay

Command to crate LV and tag it as swap
CODE

lvcreate -L 2G swaplv VolGroup
mkswap /dev/VolGroup/swaplv
swapon -a
reboot



Done. Remember, this is done while you're booted of the boot CD.

cheers,

This post has been edited by helikaon: Jul 13 2011, 09:03 AM


--------------------
PMEmail Poster
^
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll