Skip to contentSkip to conversation

Automatically GROW an LV to max size

linux-lvm Tracy R Reed 8 participants 11 messages Jan 23, 2002 – Feb 21, 2002

lore
Share & tools
lore
#0 lore raw

I'm the system administrator for MP3.com. I talked to some Sistina developers who visited the office a year or so ago but don't recall their names now, sorry. One if the things I asked for in LVM (and would still like to see) is a switch to create an LV that is as big as the remaining disk space available.

We have a redhat based kickstart install that sets up a basic / and then creates an LV out of the rest of the disk. Currently we have hard coded the size of the remaining disk but it would be really slick if we could just pass an option to lvcreate which would just create an lv with the most space possible.

Right now if we ever install on anything other than one of our standard 36G disks we have to delete the lv that was made and resize it or if the disk is smaller than 36G the hard coded lvcreate size will fail due to lack of space.

There's got to be a cleaner way to do it.

Signature · 1 line
Tracy Reed      http://www.ultraviolet.org
#1 lore raw

I imagine this would be fairly easy to do with a script? Check the size with fdisk, then pass that along to the lvm tools.
Perl should be able to handle that?

This is a suggestion only, I'm no programmer!
8-)

Quoted 30 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Tracy R Reed
Sent: Thursday, 24 January 2002 2:24 p.m.
To: [email protected]
Subject: [linux-lvm] Automatically GROW an LV to max size

I'm the system administrator for MP3.com. I talked to some Sistina developers who visited the office a year or so ago but don't recall their names now, sorry. One if the things I asked for in LVM (and would still like to see) is a switch to create an LV that is as big as the remaining disk space available.

We have a redhat based kickstart install that sets up a basic / and then creates an LV out of the rest of the disk. Currently we have hard coded the size of the remaining disk but it would be really slick if we could just pass an option to lvcreate which would just create an lv with the most space possible.

Right now if we ever install on anything other than one of our standard 36G disks we have to delete the lv that was made and resize it or if the disk is smaller than 36G the hard coded lvcreate size will fail due to lack of space.

There's got to be a cleaner way to do it.

Signature · 1 line
Tracy Reed      http://www.ultraviolet.org
#2 lore raw
In reply to Tracy R Reed
Quoted 7 lines · Tracy R Reed

We have a redhat based kickstart install that sets up a basic / and then creates an LV out of the rest of the disk. Currently we have hard coded the size of the remaining disk but it would be really slick if we could just pass an option to lvcreate which would just create an lv with the most space possible.

[...]

Quoted 2 lines

There's got to be a cleaner way to do it.

Maybe not cleaner, but more flexible (and as it's only used for an installer, where the output of vgdisplay is kind of defined, maybe usable):

--- snip ---

#!/bin/bash

VG="vg0" # Name of the volume group
LV="data" # Name of the logical vol.

FREE_PEs=$(vgdisplay $VG|grep "^Free PE"|sed "s/^[a-zA-Z /]\+\([0-9]\+\).*/\\1/") lvcreate -l $FREE_PEs -n $LV $VG

--- snip ---

You may want to doublecheck the regex before using this. And yes, a switch in lvmcreate would be nicer, too. Just in case, you need a solution *now*.

Regards, Markus

Signature · 1 line
Free the Fluffy Bunny.
#3 lore raw

[linux-lvm] I/O Error removing a file

I encountered what I was able to diagnose as a hardware error on one of the hard drives in my system. In order to make sure my data was safe, I added an additional drive, and performed a pvmove of the data onto the healthy drive (moving all the PE's off the bad disk). That all went fairly well (except for taking forever).

However, I still have a few files which are giving me troubles.

root@vpn:/home/vpnwork# rm -R TestData2k
rm: cannot remove `TestData2k': Input/output error

Is there a way to remove these files so that I can recreate them? I'm using LVM version 1.0.1-rc4, on a Linux kernel 2.5.0.

Thanks,
-John Moser

#4 lore raw

Re: [linux-lvm] I/O Error removing a file

Quoted 10 lines · John Moser

I encountered what I was able to diagnose as a hardware error on one of the hard drives in my system. In order to make sure my data was safe, I added an additional drive, and performed a pvmove of the data onto the healthy drive (moving all the PE's off the bad disk). That all went fairly well (except for taking forever).

However, I still have a few files which are giving me troubles.

root@vpn:/home/vpnwork# rm -R TestData2k
rm: cannot remove `TestData2k': Input/output error

John,

so you don't have PEs allocated on the failed drive any longer? If so, this looks like you still have another hardware flaw (cables?) or a bug in 2.5.
What does "fsck -f" say about your filesystem?

Quoted 13 lines

Is there a way to remove these files so that I can recreate them? I'm using LVM version 1.0.1-rc4, on a Linux kernel 2.5.0.

Thanks,
-John Moser

_______________________________________________
linux-lvm mailing list
[email protected]
http://lists.sistina.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://www.sistina.com/lvm/Pages/howto.html

Signature · 15 lines
Regards,
Heinz    -- The LVM Guy --

*** Software bugs are stupid.
    Nevertheless it needs not so stupid people to solve them ***

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Heinz Mauelshagen                                 Sistina Software Inc.
Senior Consultant/Developer                       Am Sonnenhang 11
                                                  56242 Marienrachdorf
                                                  Germany
[email protected]                           +49 2626 141200
                                                       FAX 924446
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#5 lore raw

RE: [linux-lvm] I/O Error removing a file

Needless to say, I forgot to run fsck one last time. ;) That removed the illegal inodes, and the files along with it. Problem solved.

I guess in the IT field, writing emails to support lists sometimes is all you need to inspire the proper solution.

-John

-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Heinz J . Mauelshagen
Sent: Tuesday, February 05, 2002 3:59 AM
To: [email protected]
Subject: Re: [linux-lvm] I/O Error removing a file

Quoted 1 line · John Moser

I encountered what I was able to diagnose as a hardware error on one of

the

Quoted 9 lines

hard drives in my system. In order to make sure my data was safe, I added an additional drive, and performed a pvmove of the data onto the healthy drive (moving all the PE's off the bad disk). That all went fairly well (except for taking forever).

However, I still have a few files which are giving me troubles.

root@vpn:/home/vpnwork# rm -R TestData2k
rm: cannot remove `TestData2k': Input/output error

John,

so you don't have PEs allocated on the failed drive any longer? If so, this looks like you still have another hardware flaw (cables?) or a bug in 2.5.
What does "fsck -f" say about your filesystem?

Quoted 2 lines

Is there a way to remove these files so that I can recreate them? I'm

using

Quoted 11 lines

LVM version 1.0.1-rc4, on a Linux kernel 2.5.0.

Thanks,
-John Moser

_______________________________________________
linux-lvm mailing list
[email protected]
http://lists.sistina.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://www.sistina.com/lvm/Pages/howto.html

--

Regards,
Heinz -- The LVM Guy --

*** Software bugs are stupid.
Nevertheless it needs not so stupid people to solve them ***

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
=-

Heinz Mauelshagen Sistina Software Inc.
Senior Consultant/Developer Am Sonnenhang 11
56242 Marienrachdorf Germany
[email protected] +49 2626 141200

                                                       FAX 924446

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
=-

_______________________________________________
linux-lvm mailing list
[email protected]
http://lists.sistina.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://www.sistina.com/lvm/Pages/howto.html

#6 lore raw

[linux-lvm] Partition resizing and whatnot

So, after installation the ATA update patches that people recommended, I now have a linux system that recognizes the full 160 gigabytes of disk space on my disks. However, I'm not entirely sure as to how I should go about resizing my filesystem. I'm already well aquanted with adding disks to existing filesystems and growing them. However, what are the recommended steps for taking existing disk partitions, resizing them to fill the disks they reside on, and then resizing the LVM/e2fs filesystems that use those disks?

Any help would be appreciated (preferably step by step if you can manage).

Thanks,
-John Moser

--------------------------------
University of Wisconsin-Madison
Engine Research Center, Rm. 1011
Engineering Research
263-2761
Systems Administrator
[email protected]
--------------------------------

#7 lore raw

Re: [linux-lvm] Partition resizing and whatnot

Quoted 8 lines · John Moser

So, after installation the ATA update patches that people recommended, I now have a linux system that recognizes the full 160 gigabytes of disk space on my disks. However, I'm not entirely sure as to how I should go about resizing my filesystem. I'm already well aquanted with adding disks to existing filesystems and growing them. However, what are the recommended steps for taking existing disk partitions, resizing them to fill the disks they reside on, and then resizing the LVM/e2fs filesystems that use those disks?

With the current LVM setup, you are probably just as well off to create a new partition on the remaining space, make it a PV, and then use the PEs as you see fit. Anything else means binary editing of PV and VG structs at this point, so you probably don't want to do it...

Cheers, Andreas
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://www-mddsp.enel.ucalgary.ca/People/adilger/

#8 lore raw

Re: [linux-lvm] Partition resizing and whatnot

In reply to John Moser
Quoted 5 lines · John Moser

So, after installation the ATA update patches that people recommended, I now have a linux system that recognizes the full 160 gigabytes of disk space on my disks. However, I'm not entirely sure as to how I should go about resizing my filesystem. I'm already well aquanted with adding disks to existing filesystems and growing them.

??? You can't add a disk to a filesystem.

You can put a PV on a disk and add that to a VG.

(Or, possibly, you could add a disk to the end of a linear MD group, although this would be pointless with LVM.)

Quoted 2 lines

However, what are the recommended steps for taking existing disk partitions, resizing them to fill the disks they reside on,

I wouldn't recommend trying to go down this path:
Resizing the partitions would be no problem, just use fdisk to delete the existing partition and create a new one with the same start point, but with a higher end point. The problem would be resizing the PVs, which I don't think is supported. So I don't think it would be a good idea to go down this path.

Surely the obvious way to do it is:

(a) Using fdisk, create new partition(s) in the newly-usable tail end(s) of your disk(s)

(b) *** Re-boot. The kernel cannot re-interpret a partition table if any of the partitions are in use. In all probability you will have partitions in use on that/those disk(s) so you will need to re-boot to make the kernel re-interpret the partition table(s).

(b) create PVs in the new partitions (pvcreate)

(c) add the PVs to your VG(s) (vgextend)

Your VG will then be larger by the amount of PEs which could be fitted into the new PVs in the new partitions. You can then extend your LVs at your leisure.

You will probably lose a tiny bit at the end of the existing partitions, and you may be able to fit one less PE in your new partition(s), because the size of your existing partitions will probably not be exact multiples of the PE size, but it's not worth worrying about.

Quoted 1 line

and then resizing the LVM/e2fs filesystems that use those disks?

??? Unrelated ? This is all basic stuff to do with LV side. Just follow the documentation: umount ... / e2fsadm ... / mount ... . (Just make sure you have a suitably up-to-date version of ext2resize; I use version 1.1.17.)

Regards,

Bill

Signature · 4 lines
William H. Blunn - [email protected]
Tao
62/63 Suttons Business Park, Earley, READING, RG6 1AZ, United Kingdom
Tel: +44 118 901 2999 - Fax: +44 118 901 2963 - http://tao-group.com/
#9 lore raw
In reply to Tracy R Reed
Quoted 8 lines · Tracy R Reed

I'm the system administrator for MP3.com. I talked to some Sistina developers who visited the office a year or so ago but don't recall their
names now, sorry. One if the things I asked for in LVM (and would still like to see) is a switch to create an LV that is as big as the remaining disk space available.
We have a redhat based kickstart install that sets up a basic / and then creates an LV out of the rest of the disk. Currently we have hard coded

Quoted 8 lines

the size of the remaining disk but it would be really slick if we could just pass an option to lvcreate which would just create an lv with the most space possible.
Right now if we ever install on anything other than one of our standard 36G disks we have to delete the lv that was made and resize it or if the disk is smaller than 36G the hard coded lvcreate size will fail due to lack of space.
There's got to be a cleaner way to do it.

It's been almost a year since I was inside kickstart, but you should be able to customize the script to read the remaining disk space, then call lvcreate with a variable.

Signature · 1 line
Share and Enjoy. 
#10 lore raw
In reply to Tracy R Reed

Tracy,
here's a simple script with a CL check to cut what you want.

Regards,
Heinz -- The LVM Guy --

#!/bin/sh
cmd=basename $0
if [ $# -ne 1 ]; then
echo -e "$cmd -- please call with just one logical volume path\n" exit 1
fi
LVNAME=$1
VGNAME=echo $LVNAME|sed 's!/dev/!!;s!/.*$!!'

FREE_PE=vgdisplay $VGNAME|sed '/Free.*PE/!d;s!^.*Size !!;s!^ *!!;s! .*$!!' lvextend -l+$FREE_PE $LVNAME

Quoted 12 lines · Tracy R Reed

I'm the system administrator for MP3.com. I talked to some Sistina developers who visited the office a year or so ago but don't recall their names now, sorry. One if the things I asked for in LVM (and would still like to see) is a switch to create an LV that is as big as the remaining disk space available.

We have a redhat based kickstart install that sets up a basic / and then creates an LV out of the rest of the disk. Currently we have hard coded the size of the remaining disk but it would be really slick if we could just pass an option to lvcreate which would just create an lv with the most space possible.

Quoted 9 lines

Right now if we ever install on anything other than one of our standard 36G disks we have to delete the lv that was made and resize it or if the disk is smaller than 36G the hard coded lvcreate size will fail due to lack of space.

There's got to be a cleaner way to do it.

Signature · 1 line
Tracy Reed      http://www.ultraviolet.org

*** Software bugs are stupid.
Nevertheless it needs not so stupid people to solve them ***

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Heinz Mauelshagen Sistina Software Inc.
Senior Consultant/Developer Am Sonnenhang 11
56242 Marienrachdorf Germany
[email protected] +49 2626 141200

                                                       FAX 924446

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-