Operating System - Linux
1832009 Members
2932 Online
110034 Solutions
New Discussion

Re: Decrease the size of a logical volume without data loss

 
Chandrasekar_2
Occasional Advisor

Decrease the size of a logical volume without data loss

Hi everyone
I have a HP workstation running on HP-UX 10.x. I have a problem with reducing
the size of logical volumes. I created a volume group using one of the hard
disks . I got a new hard disk and assigned it to the same volume group as that
of the former. I increased the size of my logical volumes mounted on /home and
/usr to use the new hard disk. I want to revert back these changes i.e I want
to remove the physical extents of the new physical volume(new hard disk)
alloted to the logical volumes mounted on /home and /usr. In short I want
/home and /usr to be confined to my old hard disk. Is it possible to do it
without any data loss as this is a big requirement for me. Could you please
explain the steps in detail on how to go about doing this?
regards
chandrasekar
3 REPLIES 3
harry d brown jr
Honored Contributor

Re: Decrease the size of a logical volume without data loss

Two options,

(1) make a "make_recovery -Avi" tape - this only backs up vg00, so for other vg's you need to use another type of backup!

(2) see 1 - when doing the recovery, interactively change the sizes and locations of the filesystems.

live free or die
harry
Live Free or Die
harry d brown jr
Honored Contributor

Re: Decrease the size of a logical volume without data loss

Two options,

(1) make a "make_recovery -Avi" tape - this only backs up vg00, so for other vg's you need to use another type of backup!

(2) see 1 - when doing the recovery, interactively change the sizes and locations of the filesystems.

live free or die
harry


PS: Don't forget to assign points to your posts!
Live Free or Die
Kodjo Agbenu
Honored Contributor

Re: Decrease the size of a logical volume without data loss

Hello,

Don't forget that this discussion forum is dedicated to Linux.

Let's talk about your problem. If you are not at ease with LVM, I would recommend the "make_recovery", as it seems to be the safest method.

However, I would personnally do it another way :

* Boot single-user mode.
* mount -a
* lvcreate -L "desired_home_size" vg00
(let's suppose the automagically assigned name is lvol9)
* lvcreate -L "desired_usr_size" vg00
(let's suppose the automagically assigned name is lvol10)
* newfs /dev/vg00/rlvol9
* newfs /dev/vg00/rlvol10
* mkdir /newhome
* mkdir /newusr
* mount /dev/vg00/lvol9 /newhome
* mount /dev/vg00/lvol10 /newusr
* mount -oremount,ro /home
* mount -oremount,ro /usr
* cd /home
* find . -print | cpio -pdvmux /newhome
* cd /usr
* find . -print | cpio -pdvmux /newusr
* umount /newusr
* umount /newhome
* Edit /etc/fstab to make /home mounted as /dev/vg00/lvol9 and /usr mounted as /dev/vg00/lvol10
* umount /home
* umount /usr
* mount /home
* mount /usr

AT THIS POINT, it would probably be a good idea to reboot the system in normal mode, to make sure that everything is OK.

* Reboot again in single-user mode
* mount -a
* lvremove /dev/vg00/lvolX (lvolX is the lvol that corresponds to the old /home)
* lvremote /dev/vg00/lvolY (lvolY is the lvol that corresponds to the old /usr)
* pvmove source_physical_vol dest_physical_vol (source is the disk you want to get rid of, destination is the disk you want to keep !)
* vgreduce vg00

* Reboot

OF COURSE, DO THIS AT YOUR OWN RISK !
Read and re-read and re-re-read this procedure to make sure you agree with all the steps suggested, before doing anything.

Good luck :-)

Kodjo
Learn and explain...