I need to add space to /var (thank you, libreoffice), which is on lvm.
Since my one volume group vg is getting low, I thought this would be a
good time to extend it as well.
Alan (McKinnon) has posted very helpful lvm bits (reprinted below).
Following alan's bottom up creation mandate I believe the idea is
phy disk: /dev/sda my only drive
phy part: fdisk create another partition of type LVM (/dev/sda8)
phy vol: pvcreate /dev/sda8
vol grp: vgextend vg /dev/sda8
log vol: lvextend --size +10G /dev/vg/var
file sys: resize2fs /dev/vg/var
files/dirs: not relevant
Questions
1. Apparently 2.6 (hence 3.x) kernels can expand mounted file systems
(/var is mounted as ext3).
Since I can't unmount /var because it is in use, I guess that, if I
every need to shrink /var, I would need to boot off a CD. Is that
correct?
Back in the day, we had single user mode for this, but I don't see
how to get the equivalent now.
Is it really safe to extend /var (i.e., /dev/vg/var) while mounted
as ext3? It sounds frightening since daemons could start running
and access /var.
2. Since currently /var is entirely from /dev/sda7 (my original lvm
partition) should I use the optional parameter to lvextend to
force the new space for /var to come from there as well?
lv extend --size +10G /dev/sda7
thanks in advance
allan
==================== from Alan McKinnon ==============================
Let's look first at the layers of stuff involved:
files & directories
file system
logical volume (LV)
volume group (VG)
physical volume (PV)
physical partition (i.e. /dev/sda1 etc)
physical disk (i.e. something Seagate etc made)
OK, there's a lot of stuff there. When you made the LV, you worked from
the bottom up
Nothing in that list can be bigger than the thing below it.
12-16-2011, 01:46 AM
Dale
LVM: extending volume groups and logical volumes
Allan Gottlieb wrote:
I need to add space to /var (thank you, libreoffice), which is on lvm.
Since my one volume group vg is getting low, I thought this would be a
good time to extend it as well.
Alan (McKinnon) has posted very helpful lvm bits (reprinted below).
Following alan's bottom up creation mandate I believe the idea is
phy disk: /dev/sda my only drive
phy part: fdisk create another partition of type LVM (/dev/sda8)
phy vol: pvcreate /dev/sda8
vol grp: vgextend vg /dev/sda8
log vol: lvextend --size +10G /dev/vg/var
file sys: resize2fs /dev/vg/var
files/dirs: not relevant
Questions
1. Apparently 2.6 (hence 3.x) kernels can expand mounted file systems
(/var is mounted as ext3).
Since I can't unmount /var because it is in use, I guess that, if I
every need to shrink /var, I would need to boot off a CD. Is that
correct?
Back in the day, we had single user mode for this, but I don't see
how to get the equivalent now.
Is it really safe to extend /var (i.e., /dev/vg/var) while mounted
as ext3? It sounds frightening since daemons could start running
and access /var.
2. Since currently /var is entirely from /dev/sda7 (my original lvm
partition) should I use the optional parameter to lvextend to
force the new space for /var to come from there as well?
lv extend --size +10G /dev/sda7
thanks in advance
allan
When I need to do something like this, I do a:
rc single
That stops all the services, including loggers which need /var, and on
my systems, umounts /var as well. I'm assuming you have upgraded to
baselayout2 and openrc. That may not work on the old setups. When you
go to single user mode, it umounts everything except / itself. May want
to recall that if you have notes in your user directory which would not
be mounted. I always put things like that in /root.
As for being safe, I did one of my file systems recently while
downloading a movie. It was being actively written to while it was
being expanded. The movie played fine when it was all done so I guess
it is safe if the file system can be expanded while mounted. Keep in
mind, some can't so check first.
I'd have to read on the rest as I am a bit new to this too. Maybe
someone who knows more will comment on the rest.
Dale
:-) :-)
--
I am only responsible for what I said ... Not for what you understood or how you interpreted my words!
Miss the compile output? Hint:
EMERGE_DEFAULT_OPTS="--quiet-build=n"
12-16-2011, 02:05 AM
Jens Müller
LVM: extending volume groups and logical volumes
Am 16.12.2011 03:18, schrieb Allan Gottlieb:
Questions
1. Apparently 2.6 (hence 3.x) kernels can expand mounted file systems
(/var is mounted as ext3).
Since I can't unmount /var because it is in use, I guess that, if I
every need to shrink /var, I would need to boot off a CD. Is that
correct?
Back in the day, we had single user mode for this, but I don't see
how to get the equivalent now.
Is it really safe to extend /var (i.e., /dev/vg/var) while mounted
as ext3? It sounds frightening since daemons could start running
and access /var.
Well, online resizing works online, hence the name.
It is of course supposed to be working. You should have a backup
nethertheless.
resize2fs also supports shrinking ext3 partitions, see
http://linux.die.net/man/8/resize2fs
Regards,
Jens
12-16-2011, 02:50 AM
Jens Müller
LVM: extending volume groups and logical volumes
Am 16.12.2011 04:05, schrieb Jens Müller:
resize2fs also supports shrinking ext3 partitions, see
http://linux.die.net/man/8/resize2fs
Sorry about that one - yes, the fs must be unmounted to do this.
- Jens
12-16-2011, 06:41 AM
"J. Roeleveld"
LVM: extending volume groups and logical volumes
On Friday 16 December 2011 03:18:16 Allan Gottlieb wrote:
> I need to add space to /var (thank you, libreoffice), which is on lvm.
> Since my one volume group vg is getting low, I thought this would be a
> good time to extend it as well.
Actually, you need space in /var/tmp/portage
> Alan (McKinnon) has posted very helpful lvm bits (reprinted below).
> Following alan's bottom up creation mandate I believe the idea is
>
> phy disk: /dev/sda my only drive
> phy part: fdisk create another partition of type LVM (/dev/sda8)
> phy vol: pvcreate /dev/sda8
> vol grp: vgextend vg /dev/sda8
> log vol: lvextend --size +10G /dev/vg/var
> file sys: resize2fs /dev/vg/var
> files/dirs: not relevant
>
> Questions
>
> 1. Apparently 2.6 (hence 3.x) kernels can expand mounted file systems
> (/var is mounted as ext3).
>
> Since I can't unmount /var because it is in use, I guess that, if I
> every need to shrink /var, I would need to boot off a CD. Is that
> correct?
For shrinking, you need to umount the partition first. Online-resizing only
works when increasing the size.
> Back in the day, we had single user mode for this, but I don't see
> how to get the equivalent now.
"rc single" (See Dales email)
> Is it really safe to extend /var (i.e., /dev/vg/var) while mounted
> as ext3? It sounds frightening since daemons could start running
> and access /var.
Yes, I regularly extend filesystems while already copying data to them.
> 2. Since currently /var is entirely from /dev/sda7 (my original lvm
> partition) should I use the optional parameter to lvextend to
> force the new space for /var to come from there as well?
> lv extend --size +10G /dev/sda7
No, LVM can assign space from any disk. It will know where to go when
accessing it.
If it's just temporary for LibreOffice, I'd suggest making a temporary LV, mount
it at /var/tmp/portage and then emerging the software.
Then when finished, umount and remove the LV.
I see no need to have /var really large for normal use and have never tried
shrinking filesystems myself.
> thanks in advance
Your welcome
HTH,
--
Joost
12-16-2011, 06:51 AM
Dale
LVM: extending volume groups and logical volumes
J. Roeleveld wrote:
If it's just temporary for LibreOffice, I'd suggest making a temporary
LV, mount it at /var/tmp/portage and then emerging the software. Then
when finished, umount and remove the LV. I see no need to have /var
really large for normal use and have never tried shrinking filesystems
myself.
Your welcome
HTH,
--
Joost
If he has enough memory, he could mount it on tmpfs too. That's how I
do mine. I got more ram than space on /var. lol
Dale
:-) :-)
--
I am only responsible for what I said ... Not for what you understood or how you interpreted my words!
Miss the compile output? Hint:
EMERGE_DEFAULT_OPTS="--quiet-build=n"
12-16-2011, 08:02 AM
Philip Webb
LVM: extending volume groups and logical volumes
111215 Allan Gottlieb wrote:
> I need to add space to /var -- thank you, libreoffice -- ,
> which is on lvm. Since my one volume group vg is getting low,
> I thought this would be a good time to extend it as well ...
> phy vol: pvcreate /dev/sda8
> ...
I have long had my own extra var-type dir, which i call '/z'
(it started out as "all the otherwise unassigned space on the disk").
Currently, it has 20 GB , of which 8 GB are used,
all temporary stuff, none of it for anything of lasting value.
That's where I do all my heavy-lifting, eg ISOs, testing packed archives
& esp /z/tmp , which is my Portage tempdir.
In your set-up, you might consider mounting /dev/sda8 as a similar big dir.
That would avoid all the problems of changing existing dir sizes
& also any need to alter LVM.
--
========================,,======================== ====================
SUPPORT ___________//___, Philip Webb
ELECTRIC /] [] [] [] [] []| Cities Centre, University of Toronto
TRANSIT `-O----------O---' purslowatchassdotutorontodotca
12-16-2011, 09:02 AM
Neil Bothwick
LVM: extending volume groups and logical volumes
On Fri, 16 Dec 2011 08:41:07 +0100, J. Roeleveld wrote:
> On Friday 16 December 2011 03:18:16 Allan Gottlieb wrote:
> > I need to add space to /var (thank you, libreoffice), which is on lvm.
> > Since my one volume group vg is getting low, I thought this would be a
> > good time to extend it as well.
>
> Actually, you need space in /var/tmp/portage
In fact, he needs space in wherever $PORTAGE_TMPDIR points to. Just set
this variable to somewhere with enough space before emerging libreoffice.
> > phy disk: /dev/sda my only drive
> > phy part: fdisk create another partition of type LVM (/dev/sda8)
> > phy vol: pvcreate /dev/sda8
> > vol grp: vgextend vg /dev/sda8
> > log vol: lvextend --size +10G /dev/vg/var
> > file sys: resize2fs /dev/vg/var
Did you say your existing PV is sda7? In that case, why mess with having
two adjacent partitions are separate PVs in the same VG. Delete sda8,
resize sda7 to fill the space and run pvresize /dev/sda7 to resize the PV
to fit. Then you can use lvresize and resize2fs to increase /var, or
create a separate space for PORT_TMPDIR.
I prefer to keep potentially huge temporary directories away from
critical filesystems like /var.
--
Neil Bothwick
If God can't help you, how about Mr. Coffee?
12-16-2011, 12:27 PM
Pandu Poluan
LVM: extending volume groups and logical volumes
On Dec 16, 2011 5:05 PM, "Neil Bothwick" <neil@digimed.co.uk> wrote:
>
> On Fri, 16 Dec 2011 08:41:07 +0100, J. Roeleveld wrote:
>
> > On Friday 16 December 2011 03:18:16 Allan Gottlieb wrote:
> > > I need to add space to /var (thank you, libreoffice), which is on lvm.
> > > Since my one volume group vg is getting low, I thought this would be a
> > > good time to extend it as well.
> >
> > Actually, you need space in /var/tmp/portage
>
> In fact, he needs space in wherever $PORTAGE_TMPDIR points to. Just set
> this variable to somewhere with enough space before emerging libreoffice.
>
> > > phy disk: * /dev/sda *my only drive
> > > phy part: * fdisk * create another partition of type LVM (/dev/sda8)
> Did you say your existing PV is sda7? In that case, why mess with having
> two adjacent partitions are separate PVs in the same VG. Delete sda8,
> resize sda7 to fill the space and run pvresize /dev/sda7 to resize the PV
> to fit. Then you can use lvresize and resize2fs to increase /var, or
> create a separate space for PORT_TMPDIR.
>
> I prefer to keep potentially huge temporary directories away from
> critical filesystems like /var.
>
Alternatively, mount sda8 under /mnt, create "shadow" directories in sda8, and bindmount them when needed.
E.g.:
mkdir /mnt/sparespace
mount /dev/sda8 /mnt/sparespace
mount -o bind /mnt/sparespace /var/tmp/portage
Of course, this assumes sda8 has enough space for heavy compiles (i.e., 10 GiB or more). Create a huge number of inodes or use a filesystem other than ext[2-4] for sda8, and you're covered.
Rgds,
12-17-2011, 12:37 AM
Allan Gottlieb
LVM: extending volume groups and logical volumes
On Thu, Dec 15 2011, Allan Gottlieb wrote:
> I need to add space to /var (thank you, libreoffice), which is on lvm.
> Since my one volume group vg is getting low, I thought this would be a
> good time to extend it as well.
>
> Alan (McKinnon) has posted very helpful lvm bits (reprinted below).
> Following alan's bottom up creation mandate I believe the idea is
[snip]
1. Thank you dale for "rc single". This looks like what I have wanted
for a while, namely a replacement for single-user mode.
2. Everyone seems to agree that you really can enlarge a mounted
ext3 file system. I was going to try it except ...
3. I decided to use another suggestion (from neil) to use
PORTAGE_TMPDIR, roeleveld's idea of just using temporary space, and
Webb suggested /z for extra space.
So I made a normal linux ext3 partition on sda8, created the mount point
/mnt/junk and when needed mount sda8 on /mnt/junk and set PORTAGE_TMPDIR
accordingly.
One more thing. Some readers were suggesting I need 8 or so GB for
libreoffice. The failures occurred with 13GB. Today's /mnt/junk
success required 16GB. Fortunately sda8 has 50GB.