LVM lvreduce and lvextend

Posted on 2013-10-16
Medium Priority
Last Modified: 2013-10-28

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
Question by:Yann Shukor
  • 4
  • 4
LVL 62

Expert Comment

ID: 39577173
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.

Author Comment

by:Yann Shukor
ID: 39577803
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" ?

LVL 62

Expert Comment

ID: 39577964
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...
Free tool for managing users' photos in Office 365

Easily upload multiple users’ photos to Office 365. Manage them with an intuitive GUI and use handy built-in cropping and resizing options. Link photos with users based on Azure AD attributes. Free tool!


Author Comment

by:Yann Shukor
ID: 39579336
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 ?

LVL 62

Expert Comment

ID: 39579628
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....

Accepted Solution

Yann Shukor earned 0 total points
ID: 39594661
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

Author Closing Comment

by:Yann Shukor
ID: 39605094
Gheist though helpful didn't respond as accurately as did other respondents in other forums (LinuxForums and LinuxQuestions)
LVL 62

Expert Comment

ID: 39605656
I intentionally dont give dumb clickthrough guide. You have time and manualson your system...

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

This installment of Make It Better gives Media Temple customers the latest news, plugins, and tutorials to make their Grid shared hosting experience that much smoother.
Configure external lookups on for external mail flow on Exchange 2013 and Exchange 2016.
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…
To export Lotus Notes to Outlook PST or Exchange and Domino Server files to Exchange Server or PST files with ease, go for Kernel for Lotus Notes to Outlook conversion tool. Through the video, you can watch the conversion process. A common user with…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question