Gentoo Archives: gentoo-user

From: Josh Cepek <josh.cepek@×××.net>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Extending a partition with LVM on it
Date: Thu, 06 Sep 2007 06:35:05
Message-Id: 46DF9CB5.5070406@usa.net
1 Marc Joliet wrote:
2 > I recently did some rearranging of my partitions, so that everything
3 > except / and /boot (they're where my Windows used to be) is on a
4 > logical volume.
5
6 [cut]
7
8 > I wasn't sure how big I should make /var and /usr. /opt is that big in
9 > the event I install some more games. Otherwise /boot is on sda5, the VG
10 > maindisk on sda6 and the VG multimedia on sdb.
11
12 This is one way you can split up the OS from your data. Another method
13 that provides you more flexibility in the future is putting the
14 partitions on both sda and sdb into the same VG. A nifty feature of
15 lvcreate is that you can bind a LV to a particular PV, even if there are
16 multiple PV's in your VG. This can be used to allow growth of LV's
17 beyond the size of the PV they initially reside on.
18
19 > Now, since Windows was at the beginning of the hard drive, there is a
20 > huge gap (about 23 GB) between sda5 and sda6.
21 >
22 > What I want to know is, how would I go about filling the gap to have a
23 > single, large partition for maindisk? Gparted wouldn't do it and I
24 > didn't dare do anything with cfdisk.
25 >
26 > For the moment I added a new partition (via cfdisk, that I did dare do)
27 > that takes up the entire gap and extended maindisk to that. It's not
28 > what I wanted, but it works. So that puts the VG on both sda6 (new) and
29 > sda7 (old sda6). So it looks like this now:
30 >
31 >> marcec marcec # pvs
32 >> PV VG Fmt Attr PSize PFree
33 >> /dev/sda6 maindisk lvm2 a- 23,22G 23,22G
34 >> /dev/sda7 maindisk lvm2 a- 273,31G 233,38G
35 >> /dev/sdb1 multimedia lvm2 a- 149,05G 39,05G
36 >
37 >
38 > Of course, since I didn't do anything else to maindisk, I understand I
39 > can always remove the partition from LVM via vgreduce and pvremove.
40
41 As long as there is no used space between sda6 and the free space you
42 have you can expand sda6 to use the extra free space without loosing the
43 data on the partition. If you want to go this route, don't forget to
44 take sda7 out of the VG and pvremove it before deleting it (which is
45 required if you want to expand sda6 to use all the space)
46
47 Before doing this I'd recommend you save a copy of the following
48 information in the event that you make a typo and need to re-do the
49 partition sizes:
50 fdisk -l /dev/sda; fdisk -lu /dev/sda
51 Save a copy of that output somewhere safe (ie: NOT on the filesystem
52 using sda) in the event that you need it. You shouldn't need this, but
53 it is a good precaution anyway. In the event of a problem you can just
54 re-partition the disk to match this output.
55
56 To do this next part you can't be using the partition you wish to
57 resize, so you will need to boot a rescue environment, such as the
58 Gentoo Minimal Installation CD or Knoppix. Once booted, open up fdisk
59 and delete the sda6 partition (and sda7 if it's not already deleted.)
60 Then you re-create a new partition in that same location; be sure you
61 create the new partition with exactly the same starting cylinder as the
62 old partition, otherwise the data can't be read by LVM.
63
64 Next, you need to grow the PV to take advantage of this extra space. In
65 most live-CD environments you first need to activate the VG with a
66 `vgchange -a y VG_NAME` command. Then issue a `pvresize /dev/sda6` to
67 grow the PV to the full size if the new partition. You can confirm this
68 added the space by checking vgs and pvs for the expected readout. From
69 here you're free to grow or add LV's into the new space.
70
71
72 --
73 Josh

Attachments

File name MIME type
signature.asc application/pgp-signature