1820897 Members
4011 Online
109628 Solutions
New Discussion юеВ

Re: lvreduce vs lvremove

 
SOLVED
Go to solution
Chris Fadrowski
Super Advisor

lvreduce vs lvremove

I am trying to reduce lvol188 which is currently 30 gb down to 20 gb or so. When running the

lvreduce -L 10000 /dev/vgi18/lvol118

i get the following message.. corruption? why? this is a IA64 11.23v2 system with JFSonline.

I unmounted the filesystem and just wanted to reduce the size of lvol118 so i can create another filesystem out there under either swap2 or whatever. Is the best practice to just delete the entire lvol and recreate lvol118 at the right size? if so, why is lvreduce a valid command if it is going to cause corruption?



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) :
18 REPLIES 18
Pete Randall
Outstanding Contributor

Re: lvreduce vs lvremove

Chris,

This is perfectly logical - all it's telling you is that your 30GB file system is going to be trashed when you reduce the size of the container it lives in down to 20GB. Since you plan on creating a new file system anyway, you can just ignore the warning. You could also go the lvremove/lvcreate route, but that's one extra step.


Pete

Pete
Chris Fadrowski
Super Advisor

Re: lvreduce vs lvremove

actually i wanted to keep lvol118 operational, i just want it to be smaller. There is NO data on it now.. But will it be corrupt if i reduce it? or should i just blow it all away and recreate.. I guess that's what i am worried about.
Robert-Jan Goossens
Honored Contributor

Re: lvreduce vs lvremove

Hi Chris,

Reducing volumes is a pain even with online-jfs and full version of veritas. One of the problems is fragmentation. Since you don't have online-jfs the and you seem create a new volume anyway just ignore the warning and create a new filsystem.

# mkfs -F vxfs /dev/vgxx....

I often create a backup, remove the logical volume and recreate it with the correct size.

Hope this helps,
Robert-Jan
Alzhy
Honored Contributor

Re: lvreduce vs lvremove

Chris,

You need to reduce the filesystem first before you lvreduce the LVOL if you expect to have a cleanly reduced LVOL. If say the filesystem (or mount point) on TOP of that LVOL (/dev/vgi18/lvol118 is /data you need to reduce it first (assuming there is space):

fsadm -b 20480 /data

You do not even have to unmount the filesystem since you have Online JFS (aka Veritas Filesystem). (Note that this process will also attempt to defragment the filesystem)

Once that is done. You can now do your lvreduce command. NOTE THAT LVREDUCE WILL NOT SAFELY WARN YOU OF POSSIBLE CORRUPTION ON THE FILESYSTEM IF YOU DID NOT PERFORM YOUR FILESYSTEM REDUCTION FIRST AHEAD OF YOUR LVOL REDUCTION.

Robert, et al., VxVM (FULL or BASE) will allow you to resize volumes and their filesystems on the fly and somewhat safer than LVM. The key is actualy in the filesystem - you need to have Online JFS (a.k.a Full Veritas Filesystem). With VxVM + OnlineJFS - it is somewhat easier and is done in one command:

/etc/vx/bin/vxresize -g vgi18 lvol118 -10G

The above VxVM command will first fsadm the filesystem on top of the volume and reduce the filesystem. If there are no errors or if it senses there is space for the filesystem reduction - it then reduces the volum - all on the fly.
Hakuna Matata.
Pete Randall
Outstanding Contributor

Re: lvreduce vs lvremove

Chris,

The only corruption will be to the filesystem. It is not going to corrupt the logical volume. When you create the new filesystem you will be overwriting the corrupted one and everything will be fine.


Pete

Pete
Bharat Katkar
Honored Contributor

Re: lvreduce vs lvremove

Hi,
It is already explained better in previous replies. Just to add about lvreduce and lvremove...

Suppose you have 6 filesystems in a lv each of 5gb and are contiguous.
Now if you just want to get rid of last two filesystem and create nev LV in that space then you have to use "lvredcue" becuase lvremove will remove all filesystems. LVREDUCE keeps your data in first 4 FS intact provided they are contigous in nature.

LVREMOVE can be used if you don't bother about all the FS sitting in the LV. just remove it and recreate as per your requirement.

Regards,
You need to know a lot to actually know how little you know
Alzhy
Honored Contributor

Re: lvreduce vs lvremove


Again... if you wanted to preserve/keep the usability of your existing LVOL (that is IF it has a filesystem on top of it) - you should have done your filesystem reduction FIRST (via fsadm) before your LVREDUCE.

Since you have OnlineJFS - the proper way of freeing up space on an (LVOL WITH A FILESYSTEM ON TOP OF IT) is:

1. fsadm -b newsize_in_MB /mount_point

2. lvreduce .. the LVOL


HTH.
Hakuna Matata.
Pete Randall
Outstanding Contributor

Re: lvreduce vs lvremove

Nelson,

That may be nice for future reference, but, since he's already run the lvreduce, it's a little late now!


Pete

Pete
Chris Fadrowski
Super Advisor

Re: lvreduce vs lvremove

Actually i have not run any commands yet. i answered NO to the confirm on the lvreduce.
I have tried the fsadm and the vxresize commands.. NOne of these will work as i am getting errors.

/etc/vx/bin/vxresize -g vgi18 lvol118 -10G
vxvm:vxresize: ERROR: Problem running vxprint command for volume lvol118, in diskgroup vgi18

What i am getting out of reading this is, i need to reduce the filesystem first. then i can do a lvreduce.

fsadm didn't work either. here is the output from that.

fsadm -b 20500 /h18
fsadm: /etc/default/fs is used for determining the file system type
vxfs fsadm: sectors must be >= 23850 as they are currently in use.
Alzhy
Honored Contributor

Re: lvreduce vs lvremove

Chris

You cannot use vxrsize since you're obviously not using VxVM.

You're on the right path. The error message your seeing out of fsadm simply means you cannot reduce the filesystem to 20500 Mbytes and it actually is giving you a clue already!

"vxfs fsadm: sectors must be >= 23850 as they are currently in use" - means you can reduce /h18 (and the lvol) to no less than 23850 Mbytes.


bdf /h18 and whatever is your available space is the size that you can free up.

Hakuna Matata.
Pete Randall
Outstanding Contributor
Solution

Re: lvreduce vs lvremove

Chris,

You (and Nelson) are making this far too hard on yourself. Just run the lvreduce and then create your filesystem with newfs.


Pete

Pete
Patrick Wallek
Honored Contributor

Re: lvreduce vs lvremove

I agree with Pete. If there is not any data on this LV, just run the reduce and then newfs the thing.

Or barring that just lvremove and recreate the LV.
Alzhy
Honored Contributor

Re: lvreduce vs lvremove

Up to you Chris.

Personally I view this as an excellent opportunity for you to actually try this nice feature of Online JFS and the inner workings of LVM... AS YOU MAY BE FACING A REAL SITUATION in having to free up a space on a LIVE FILESYSTEM!


Hakuna Matata.
Chris Fadrowski
Super Advisor

Re: lvreduce vs lvremove

i just did a

lvreduce -L 20000 /dev/vgi18/lvol118
newfs -F vxfs -o largefiles /dev/vgi18/rlvol118

that worked just fine.

I have never had a box with JFSonline until this one. I am unfamiliar with the software. But the fsadm didn't seem to work, also, when i tried to reduce the lvol, i had to unmount it.. i thought that JFSonine was supposed to do this stuff while mounted. I don't know, thanks for all of your help.
Devender Khatana
Honored Contributor

Re: lvreduce vs lvremove

Hi,

As posted earlier also there are no doubts in the functioning of the product and it nodoubt do what it is indented for. The only mistake you did was to try lvreduce before running fsadm. As a file system resides on a logical volume, the file system should be reduced prior to reducing logical volume. You can still test it by running in proper order.
It is also recommended to defrag data before reducing file system. Your fasadm could have failed because you did not defragmented data. Another thing would be that contents of your file system should be less than the size you are reducing to.Try it this way.

Defrag : -
#fsadm -F vxfs -eE /mount_point

Reduce File System :-
#fsadm -F vxfs -b (Required size in Blocks) /mount_point

Reduce the lvol now :-
#lvreduce -L (New Size in MB) /dev/vgxx/lvolx

There should not be any problems once you do this this way. Defarmentation may take a long time depending upon the contents of your file system.

HTH,
Devender
Impossible itself mentions "I m possible"
Chris Fadrowski
Super Advisor

Re: lvreduce vs lvremove

i did a MAN on fsadm, and it doesn't give me many options or much info.

Pete Randall
Outstanding Contributor

Re: lvreduce vs lvremove

Chris,

Do a man on fsadm_vxfs.


Pete

Pete
Chris Fadrowski
Super Advisor

Re: lvreduce vs lvremove

Now that's more like it.. thank you..