Page 1 of 1

Removing unused physical volume from lvm

Posted: 2008/03/23 00:44:17
by IanWorthington
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?


Re: Removing unused physical volume from lvm

Posted: 2008/03/23 20:39:17
by markske
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%

Re: Removing unused physical volume from lvm

Posted: 2008/03/31 02:54:22
by IanWorthington
Thanks Mario, I'll give that a try.