Gentoo Archives: gentoo-user

From: Dale <rdalek1967@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] LVM: extending volume groups and logical volumes
Date: Fri, 16 Dec 2011 02:47:32
Message-Id: 4EEAB0F9.2000107@gmail.com
In Reply to: [gentoo-user] LVM: extending volume groups and logical volumes by Allan Gottlieb
1 Allan Gottlieb wrote:
2 > I need to add space to /var (thank you, libreoffice), which is on lvm.
3 > Since my one volume group vg is getting low, I thought this would be a
4 > good time to extend it as well.
5 >
6 > Alan (McKinnon) has posted very helpful lvm bits (reprinted below).
7 > Following alan's bottom up creation mandate I believe the idea is
8 >
9 > phy disk: /dev/sda my only drive
10 > phy part: fdisk create another partition of type LVM (/dev/sda8)
11 > phy vol: pvcreate /dev/sda8
12 > vol grp: vgextend vg /dev/sda8
13 > log vol: lvextend --size +10G /dev/vg/var
14 > file sys: resize2fs /dev/vg/var
15 > files/dirs: not relevant
16 >
17 > Questions
18 >
19 > 1. Apparently 2.6 (hence 3.x) kernels can expand mounted file systems
20 > (/var is mounted as ext3).
21 >
22 > Since I can't unmount /var because it is in use, I guess that, if I
23 > every need to shrink /var, I would need to boot off a CD. Is that
24 > correct?
25 >
26 > Back in the day, we had single user mode for this, but I don't see
27 > how to get the equivalent now.
28 >
29 > Is it really safe to extend /var (i.e., /dev/vg/var) while mounted
30 > as ext3? It sounds frightening since daemons could start running
31 > and access /var.
32 >
33 > 2. Since currently /var is entirely from /dev/sda7 (my original lvm
34 > partition) should I use the optional parameter to lvextend to
35 > force the new space for /var to come from there as well?
36 > lv extend --size +10G /dev/sda7
37 >
38 > thanks in advance
39 > allan
40
41 When I need to do something like this, I do a:
42
43 rc single
44
45 That stops all the services, including loggers which need /var, and on
46 my systems, umounts /var as well. I'm assuming you have upgraded to
47 baselayout2 and openrc. That may not work on the old setups. When you
48 go to single user mode, it umounts everything except / itself. May want
49 to recall that if you have notes in your user directory which would not
50 be mounted. I always put things like that in /root.
51
52 As for being safe, I did one of my file systems recently while
53 downloading a movie. It was being actively written to while it was
54 being expanded. The movie played fine when it was all done so I guess
55 it is safe if the file system can be expanded while mounted. Keep in
56 mind, some can't so check first.
57
58 I'd have to read on the rest as I am a bit new to this too. Maybe
59 someone who knows more will comment on the rest.
60
61 Dale
62
63 :-) :-)
64
65 --
66 I am only responsible for what I said ... Not for what you understood or how you interpreted my words!
67
68 Miss the compile output? Hint:
69 EMERGE_DEFAULT_OPTS="--quiet-build=n"