Linux - Server This forum is for the discussion of Linux Software used in a server related context. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
10-16-2013, 09:28 AM
|
#1
|
LQ Newbie
Registered: Oct 2013
Posts: 14
Rep: 
|
LVM lvreduce and lvextend
Hi
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
volume
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
|
|
|
10-16-2013, 02:02 PM
|
#2
|
Member
Registered: Aug 2010
Location: Beaverton, Oregon, USA
Distribution: Pfsense, Ubuntu, Centos, Fedora, Redhat, Scientfic, MacOS
Posts: 76
Rep:
|
Hello,
I should warn you: I use the term "partition" to refer to the logical volume simply because that is how fsck looks at things. For all intents and purposes, close enough.
The big thing to realize is that fsck is only going to operate within the stated boundaries of the /dev/LVM/home partition. When you ran lvresize on /dev/LVM/home, you reduced the boundaries of the partition to somewhere within the filesystem. I would resize both partitions back to where they were, run fsck then restart resizing things.
By the way, resize2fs will ALWAYS require you to use the force option.
I recommend the following procedures:
If reducing a filesystem:
- unmount the partition
- shrink the filesystem more than you want to reduce the partition size. In your case, use resize2fs to reduce /dev/LVM/home by 21 or so gigabytes. Using the -M option will shrink the filesystem to the minimum size.
- reduce the partition size. In your case:
Code:
lvreduce -L-20G /dev/LVM/home
- resize the filesystem in /dev/LVM/home back up to the partition boundaries.
Code:
resize2fs -f /dev/LVM/home
- remount /home
if increasing the partition - unmount the partition
- increase the partition size (there is a -l option to use all of a Volume Group's free space too)
Code:
lvextend -L+20G /dev/LVM/var
- resize the filesystem
Code:
resize2fs -F /dev/LVM/var
- remount /var
|
|
|
10-16-2013, 02:24 PM
|
#3
|
LQ Newbie
Registered: Oct 2013
Posts: 14
Original Poster
Rep: 
|
Thanks for your detailed response Jason_not
I feel a sense of hope that the worse is not nigh
The only uncertitude lingering in my mind is how to
apply your recommendations in my present state
I haven't done anything more or less than what was
detailed in my post, and all in that order
This is purely a mail server (postfix/dovecot/roundcube)
and at present /var is still running fine and users
haven't endured any disruptions - I don't care about
/home it isn't in use
I'd like to follow your instructions but I'm not sure
how to move: forwards, or backwards as may be required
yann
|
|
|
10-16-2013, 03:20 PM
|
#4
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,361
|
You haven't done anything to the /var filesystem yet - apparently. If you haven't done a resize2fs on it, it is still the original size within the now larger lv. Safe to reduce that. But you have to be real careful reducing as you already found out - personally I never trust the space options on the command; you never know what rounding is being done. And in your case that is also true of the RAID controller. I always leave a bit extra to be on the safe side, but that might still overlap in your case.
So you should be ok to lvreduce the /var lv, lxextend the /home back to their original sizes and all will be well after the fscks. Seems to work most of the time from what users report here on LQ and elsewhere. Would have been better had the fsck not been run I suspect - it fixes filesystems, not necessarily taking care of the files within.
Note my sigline.
|
|
|
10-16-2013, 03:27 PM
|
#5
|
LQ Newbie
Registered: Oct 2013
Posts: 14
Original Poster
Rep: 
|
Thanks Syg, now at least I have a way forwards (or backwards as is the case)
yann
|
|
|
10-16-2013, 03:30 PM
|
#6
|
Member
Registered: Aug 2010
Location: Beaverton, Oregon, USA
Distribution: Pfsense, Ubuntu, Centos, Fedora, Redhat, Scientfic, MacOS
Posts: 76
Rep:
|
Hello,
I agree with Syg00: play it safe: try this:
1) reduce the /var filesyste by... 25 gigabytes if you can, using resize2fs
2) reduce the /var partition by about ... 40 gigabytes (you increased by 20, now go 20 more) with lvresize
3) resize2fs /var to the max it can go.
4) increase the /home parition by 21 gigabytes (1 gigabyte more than you reduced it before...) with lvresize
5) run fsck -f on /home
if that comes out clean,
6) reduce /home filesystem by 21 gigabytes (or whatever to get to your original target size) with resize2fs
7) reduce the /home parition by 20 gigabyte (leave some overlap so you don't cut off the end of your filesystem) with lvresize
8) resize2fs to the max on /home
9) increase /var's partition size to your target with lvresize
10) resize2fs /var
11) reboot.
|
|
|
10-16-2013, 03:53 PM
|
#7
|
LQ Newbie
Registered: Oct 2013
Posts: 14
Original Poster
Rep: 
|
Gosh Jason, seems a little excessive
I don't even have that much leeway to begin with
- anyway there was probably only 1MB of unused space
on the RAID volume. I don't see how specifying larger
LVs can work.
Someone recommended against shrinking, which at the
moment I'm inclined to agree with, lest I mess things
up any further
|
|
|
10-16-2013, 05:22 PM
|
#8
|
Member
Registered: Aug 2010
Location: Beaverton, Oregon, USA
Distribution: Pfsense, Ubuntu, Centos, Fedora, Redhat, Scientfic, MacOS
Posts: 76
Rep:
|
Well, I understand and partially agree. I chose arbitrary numbers based on how much space you moved around in the first place. If you use megabytes as your units, things will still work out.
Definitely adjust the numbers as necessary: it all relies on the following axioms I go by:
1) never reduce the partition below the filesystem size (partition size must be >= filesystem size)
2) always include wiggle-room between the filesystem limits and the partition (lv) size. it all depends on where someone rounded numbers off, and since lvresize and resize2fs are two different programs, I like to be safe.
3) As far as the filesystem is concerned (not in use, etc) resize2fs has options to let you reduce its size down to the current amount of space used. the -M option (I believe) is a decent thing as it allows you to reduce the size the most but still be safe.
So altering the size of /var was mostly to get a perfectly functional filesystem out of the way and give /home as much room to get fixed as possible. Just so long as you follow 1 and 2, things should be fine. After /home is fixed (or deleted...) you can then work on moving disk space around.
But then, what I deem reasonable, isn't necessarily in someone else's eyes...
I understand, and agree about your reluctance regarding shrinkage. I have tried using resize2fs to go smaller than the amount of data used in a filesystem and it wouldn't let me.
BTW: If you aren't already, I heartily suggest you do all of this in either single user mode, or via a rescue boot.
|
|
|
10-17-2013, 06:28 AM
|
#9
|
LQ Newbie
Registered: Oct 2013
Posts: 14
Original Poster
Rep: 
|
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 scenario
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 ?
thanks
yann
|
|
|
10-17-2013, 11:03 AM
|
#10
|
Member
Registered: Aug 2010
Location: Beaverton, Oregon, USA
Distribution: Pfsense, Ubuntu, Centos, Fedora, Redhat, Scientfic, MacOS
Posts: 76
Rep:
|
Ok, that really simplifies things: - lvremove /dev/LVM/home
- lvextend /dev/LVM/var (I think you already did this)
- resize2fs /dev/LVM/var (this will expand the filesystem to the partition size)
- mount /dev/LVM/var /var
All of the complications came about because /dev/LVM/home's partition was shrunk below the filesystem size. The part with /dev/LVM/var was just fine however. So once you have /var settled, create a new logical volume. My example below assumes you call it "home", the Volume Group is called "LVM", and that you wish to use 100% of the remaining unused space in the Volume Group.
Code:
lvcreate -l 100%FREE -n home LVM
--jason
|
|
|
10-17-2013, 12:15 PM
|
#11
|
Senior Member
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,813
|
You don't even need to to that much. You do need to run the "resize2fs /dev/LVM/var" to expand that filesystem to fill its enlarged container. Since you already have a volume for /home, you just need to run the appropriate "mkfs.ext{2,3,4} /dev/LVM/home" for the type of filesystem you want there, replacing the patched-up filesystem that fsck repaired.
Last edited by rknichols; 10-17-2013 at 12:18 PM.
|
|
|
10-17-2013, 01:13 PM
|
#12
|
Member
Registered: Aug 2010
Location: Beaverton, Oregon, USA
Distribution: Pfsense, Ubuntu, Centos, Fedora, Redhat, Scientfic, MacOS
Posts: 76
Rep:
|
yes, that's also true.
So, the answer to your last question Yann, is YES and no there is nothing wrong with that approach.
--jason
Last edited by jason_not; 10-17-2013 at 01:17 PM.
Reason: clarification.
|
|
|
All times are GMT -5. The time now is 05:32 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|