cancel
Showing results for 
Search instead for 
Did you mean: 

lvreduce

 
SOLVED
Go to solution
himacs
Super Advisor

lvreduce

Hi Admins,

B.11.23

What is the exact procedure of reducing LVs.I know we have to shrink FS before reducing the LV.No online JFS is available with me.

Thanks in advance
himacs
10 REPLIES 10
James R. Ferguson
Acclaimed Contributor
Solution

Re: lvreduce

Hi:

In the absence of OnlineJFS you need to backup your filesystem; lvreduce the logical volume's size; 'newfs' the filesystem; and restore the contents of the backup.

Regards!

...JRF...
himacs
Super Advisor

Re: lvreduce

Hi JRF,

Actually i don want to restore any data.M working in a test machine now.

1.Create 320 MB lv

/dev/vg02/test 327680 1812 305508 1% /test

2.umount /test

3.lvreduce -L 160 /dev/vg02/test
Warning: The Logical Volume has a file system larger than the reduced size.
Reducing the Logical Volume will cause filesystem corruption.
When a logical volume is reduced useful data might get lost;
do you really want the command to proceed (y/n) : y
Logical volume "/dev/vg02/test" has been successfully reduced.
Volume Group configuration for /dev/vg02 has been saved in /etc/lvmconf/vg02.conf

4. extendfs -F vxfs /dev/vg02/rtest
UX:vxfs extendfs: ERROR: V-3-20139: Only expansion allowed.

lvdisplay shows size reduced to 160MB.But not able to mount.

NO data resides in /test.

now i want to mount /test with new size.

Please suggest

Regards
himacs

Torsten.
Acclaimed Contributor

Re: lvreduce

You cannot shrink the file system, hence a lvreduce destroys the existing filesystem.

A newfs only makes it valid again.

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
himacs
Super Advisor

Re: lvreduce

Hi Torsten,

But long back i opened a case with HP regarding lvreduce.But their answer was we can reduce.

I am also read in all HP document that lvreduce will cause data loss.But i am very much sure that we can reduce raw file system without data loss.

So i cant mount /test with new size.

Regards
himacs
sarfaraj ahmad
Trusted Contributor

Re: lvreduce

Hi,

for that you required online JFS installed on your system.

please check with swlist command.
Torsten.
Acclaimed Contributor

Re: lvreduce

>> I am also read in all HP document that lvreduce will cause data loss



This is what you currently see.



You need to have online JFS to reduce the file system first. Otherwise you destroy it.

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
P Arumugavel
Respected Contributor

Re: lvreduce

hi,

yes, it will decrease the number of the logical extents of a logical volume to the desired value.

But LVM does not store any information about which physical extents within a logical volume contain useful data, therefore, reducing the space allocated to a logical volume without doing a prior backup of the data could lead to the loss of useful data. The lvreduce command on a logical volume containing a file system of greater length than the size being reduced to will cause data corruption.

Hence, it is recommended to decrease/increase filesystem size with online JFS installed.

Rgds...
Viktor Balogh
Honored Contributor

Re: lvreduce

Hi himacs,

If you don't decrease the filesystem first, you will end up with a corrupt filesystem after you decrease the logical volume. That's your case now. Thank god this is only a test system.

You can imagine a logical volume as a container to the filesystem. If the container is smaller then the filesystem itself, it will somehow corrupt the filesystem and you'll lose data.
****
Unix operates with beer.
Bill Hassell
Honored Contributor

Re: lvreduce

I am not sure what you mean about not restoring the data. You said it was a test machine. If you do not care about the data, then the task is quite simple and most of the steps you posted are correct:

> 1.Create 320 MB lv

1a. mount /dev/vg02/test /test

> /dev/vg02/test 327680 1812 305508 1% /test
> 2.umount /test
> 3.lvreduce -L 160 /dev/vg02/test
> Warning: ...

Go ahead and reduce the lvol.

> 4. extendfs -F vxfs /dev/vg02/rtest

Not correct. As the message states, this is used to extend the filesystem, not reduce it.

> lvdisplay shows size reduced to 160MB.But not able to mount. NO data resides in /test.

This is the part where I am confused. Are you saying that you don't want the data in the filesystem? If yes, then step 4 will be:

4. newfs /dev/vg02/rtest

and now you can mount the empty filesystem with the new size.

However, if you have data that you must keep on this filesystem, you MUST backup the data first. Then umount, lvreduce, newfs and mount the empty filesystem. Now restore your data.

Because you do not have Online JFS, reducing a filesystem will ALWAYS destroy (corrupt, scramble, etc) the data. That is why you must purchase the optional product.


Bill Hassell, sysadmin