1850578 Members
3771 Online
104054 Solutions
New Discussion

Re: Reduce LV

 
Rabel
Occasional Contributor

Reduce LV

At first I have a LV named A with 4096M size.
Then I use lvreduce to reduce it size to 3072M. After lvreduce, the lvdisplay show the size of LV A is 3072M but bdf still show LV A is 4096M.
Then I reboot the machine, the LV A cann't mount because the file system is larger than LV size.
How can I do now if I want to keep all the data in LV A.
6 REPLIES 6
Jdamian
Respected Contributor

Re: Reduce LV

If your FS is VxFS and Online JFS is installed on system, you can reduce a FS without unmounting, but you must reduce the FS prior to reduce the LV; not reduce LV prior to reduce FS... Why ?

Imagine FS data exist on blocks that you have removed from LV ... how can system access now to them ?. no way.

In other cases:

1) VxFS without OnlineJFS: you must unmount you FS and try to run 'fsadm -b newsize'... I'm not sure this command work.

2) HFS: you must unmount your FS and create again (newfs, mkfs)... that means losing data.

Jdamian
Respected Contributor

Re: Reduce LV

You can go back to the initial state if you extend back the LV and new logical extends match the logical extends removed by 'lvreduce' in the same order they were.
Then unmount FS and mount again.

I did some tests lot of time about this and it worked. My test was the following:

1) create a new LV
2) create a new FS on it
3) mount new FS
4) copy files on new FS
5) unmount FS
6) remove LV (--> release disk blocks)
7) create a new LV as large as removed LV (--> I'm sure disk blocks match the released disk blocks in step 6)
8) mount FS
9) read data files on FS.

Sunil Sharma_1
Honored Contributor

Re: Reduce LV

Hi,
lvreduce reduce he size of logical volume not FS and bdf shows the info about File systems not logical volumes. lvreduce will destry the data because after doing the lvreduce you have to run newfs to make system aware that FS size got changed.

So if you want to reduce size of a logical volume and you don't have Online JFS steps are below.
1. Take full backup of File system
2. umount FS
3. lvreduce logical volume
4. newfs
5. mount the FS and restore data.

but if you have online JFS
1. fsadm reduce the filesystem size
2. lvreduce reduce the logical volume size.

Sunil S
*** Dream as if you'll live forever. Live as if you'll die today ***
Ravi_8
Honored Contributor

Re: Reduce LV

Hi,

Sure you haven't umounted the file sysetm before using lvreduce command.

If you don't have Online JFS installed, then you have to unmount the lvol before reducing
(hope you have the backup)

Get into single user mode ,unmount the file system, use lvreduce and do fsck of that lvol and init 3
never give up
V. V. Ravi Kumar_1
Respected Contributor

Re: Reduce LV

hi,
I think u already lost the data if didn't have the backup. only thing u can do now is run newfs on new reduced LV, so that it will be recognised by LVM.

without onlin JFS u can not reduce the LV size, because you will loos the data. best option is copy the present contents onto tape, then reduce LV, then run newfs then copy the old contents to the new FS.

Regards

Never Say No
Ernesto Cappello
Trusted Contributor

Re: Reduce LV

Hi,
using the commands:

"lvextend" or "lvreduce"

to increase or decrease the dimension of your filesystem, it can happen that the space is seen as not modified when you try to mount the just-modified filesystem.

To avoid this, you have to execute the following command:

extendfs /dev/vg00/lvolXX

where XX is the number of your volume.

Regards.
Ernesto.