LVM lvreduce and lvextend


On a Debian squeeze HP Proliant with Smartarray four disk RAID 1+0 135GB
my client's /var volume  was in the mid ninety percent full so I proposed that we reduce /home

I executed the following commands :

umount /home
lvreduce -L-20G /dev/LVM/home
lvextend -L+20G /dev/LVM/var
mount /home

the mount didn't go well and I realised that I had omitted a command, so I ran:

resize2fs /dev/LVM/home

Which requested that I run :

e2fsck -f /dev/LVM/home

which produced the following error:

Error reading block 2655233 (Invalid argument).  Ignore error<y>?

I ran through the various repair steps that this utility handles and yet the /home volume still won't mount - I get the same result if I run e2fsck again

I don't mind losing the /home volume, but I'd hate (ok worse than hate) to lose the /var

Is there any way to undo these commands or at least to cancel the lvextend on /var ?

I haven't rebooted the server yet.

thanks for your help
Yann ShukorOwnerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Short: Data has been lost - restore from backup.
there is no chance lvextend will allocate same blocks lvreduce freed in same order.

from "man lvreduce"

lvreduce allows you to reduce the size of a logical volume.  Be careful when reducing a logical volume’s size, because data in the reduced part is lost!!!
       You should therefore ensure that any filesystem on the volume is resized before running lvreduce so that the extents that are to be removed are not in use.
       Shrinking snapshot logical volumes (see lvcreate(8) for information to create snapshots) is supported as well.  But to change the number of copies in a mirrored logical volume  use
       Sizes  will be rounded if necessary - for example, the volume size must be an exact number of extents and the size of a striped segment must be a multiple of the number of stripes.
Yann ShukorOwnerAuthor Commented:
Gosh, way to go to kick a man who's already sprawled across the floor

In fact /var is still running fine. I'm a little afraid of what to expect when I next have to reboot the server

I haven't done anything else than what was specified in my post

My ultimate fear is losing /var which hasn't been backed up yet, for unpardonable reasons.

I guess I could plug a USB drive to run an ad'hoc backup
Any suggestions on this issue ?

Can I simply run:

lvextend -L-20G /dev/LVM/var

to put things back the way they were for /var ?

I don't care about /home since this is a mail server only and the user's mailboxes are on var

I do hope that there are some people with LVM experience lurking around, "des experts quoi" ?

1) dont do any LVM resizes
just uncomment filesystem you just broke in fstab and ysstem will boot fine and not touch the sectors where data still resides

now the tricky part....
boot a live USB (ubuntu can mount external LVM)
copy out healthy part of LV to a file (can be NFS)
with fsck (without f or y parameter!!!!) find the locations of expected superblocks
seek for superblocks in LVM's free space....
if they make logical order just add destroyed part to your image file
that is te fastest way....

if LVs are resized after installing system... it is not in order.... call data recovery company...
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

Yann ShukorOwnerAuthor Commented:
Ok, a final question and then I'm clear on the issue:

Let's just say that I don't care at all about /home and its contents

All I really want is to end up with a healthy functional /var

Would I be able to dismount /var and run [resize2fs /dev/LVM/]
in order for the added 20Go to be taken into account ?
Or is this categorically the wrong way to go ?

You have to resize2fs to minimal size and you can do it while it is running
lvreduce can resize some filesystems while they are mounted
best is to try tp extend by 1G first and check df after if resize2fs kicked in, reduce after.
check uname -r, i resized running lv minute ago on 12.04 LTS with kernel 3.8

i would still suggest at least backing up old size of /home starting from where ext2 of /home starts....
Yann ShukorOwnerAuthor Commented:
I finally decided that since I didn't care about the /home volume I will proceed ahead with the extention of the filesystem for /var, once I have backed it up with fsarchiver

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Yann ShukorOwnerAuthor Commented:
Gheist though helpful didn't respond as accurately as did other respondents in other forums (LinuxForums and LinuxQuestions)
I intentionally dont give dumb clickthrough guide. You have time and manualson your system...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.