Removing unused physical volume from lvm

Issues related to hardware problems
Post Reply
Posts: 18
Joined: 2006/02/23 12:05:10

Removing unused physical volume from lvm

Post by IanWorthington » 2008/03/23 00:44:17

I've just added a new disk to my system and used vgextend and lvextend to expand the pv and lv before I discovered that I can't expand the fs because its ext2 (so can't be done online) and contains the root (so can't be umount-ed).

I now find I can't vgreduce the vg as the physical volume is now considered "in use".

What's the safest way to remove this disk so I can start again and create a different lv?


Posts: 77
Joined: 2007/03/19 10:12:59
Location: Belgium/brussels

Re: Removing unused physical volume from lvm

Post by markske » 2008/03/23 20:39:17

If you want to expand your root partition the easy way is to boot with your install cd/dvd and do a linux rescue
then you can resize your root offline,

if you want to remove the disk savely

first I don't give you a garantie so BACKUP YOUR DATA FIRST!!!!! (or take the risk for fun)
I dit this allot of times before and it always works fine but if you do a wrong thing you have a problem;

I will try to explane with a example with only 1 test lv partition

dont reduce your lv if the filesystem is using the whole space!!
if you want to make shure reboot with the dvd, do a linux rescue and reduce the ext2 first to somthing smaller you want to resize to,
then reduce the lv partition to the size you want and let the ext2 filesystem grow to the lv partition

I hope you understand the warning and the risk so BACKUP first

if I want to remove /dev/sdc
now, do a list with "pvs"
PV VG Fmt Attr PSize PFree
/dev/sdb VG0 lvm2 a- 1020.00M 0
/dev/sdc VG0 lvm2 a- 1020.00M 840.00M

As you can see in my example there is used space on my /dev/sdc

now reduce your root partition but be carefull with this if you reduce the lv smaller then your filesystem(ext2) you will lose data!!
LV VG Attr LSize Origin Snap% Move Log Copy%
lala VG0 -wi-a- 1.07G
lala2 VG0 -wi-a- 100.00M
lvreduce /dev/VG0/lala -L-200M
WARNING: Reducing active logical volume to 900.00 MB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lala? [y/n]: y
Reducing logical volume lala to 900.00 MB
Logical volume lala successfully resized

if you need to move a lv to another disk do
[code]pvmove /dev/sdc /dev/sdb
/dev/sdc: Moved: 100.0%

Posts: 18
Joined: 2006/02/23 12:05:10

Re: Removing unused physical volume from lvm

Post by IanWorthington » 2008/03/31 02:54:22

Thanks Mario, I'll give that a try.


Post Reply

Return to “CentOS 4 - Hardware Support”