Re: [gentoo-user] Extending a partition with LVM on it
Marc Joliet wrote: I recently did some rearranging of my partitions, so that everything except / and /boot (they're where my Windows used to be) is on a logical volume. [cut] I wasn't sure how big I should make /var and /usr. /opt is that big in the event I install some more games. Otherwise /boot is on sda5, the VG maindisk on sda6 and the VG multimedia on sdb. This is one way you can split up the OS from your data. Another method that provides you more flexibility in the future is putting the partitions on both sda and sdb into the same VG. A nifty feature of lvcreate is that you can bind a LV to a particular PV, even if there are multiple PV's in your VG. This can be used to allow growth of LV's beyond the size of the PV they initially reside on. Now, since Windows was at the beginning of the hard drive, there is a huge gap (about 23 GB) between sda5 and sda6. What I want to know is, how would I go about filling the gap to have a single, large partition for maindisk? Gparted wouldn't do it and I didn't dare do anything with cfdisk. For the moment I added a new partition (via cfdisk, that I did dare do) that takes up the entire gap and extended maindisk to that. It's not what I wanted, but it works. So that puts the VG on both sda6 (new) and sda7 (old sda6). So it looks like this now: marcec marcec # pvs PV VG Fmt Attr PSize PFree /dev/sda6 maindisk lvm2 a-23,22G 23,22G /dev/sda7 maindisk lvm2 a- 273,31G 233,38G /dev/sdb1 multimedia lvm2 a- 149,05G 39,05G Of course, since I didn't do anything else to maindisk, I understand I can always remove the partition from LVM via vgreduce and pvremove. As long as there is no used space between sda6 and the free space you have you can expand sda6 to use the extra free space without loosing the data on the partition. If you want to go this route, don't forget to take sda7 out of the VG and pvremove it before deleting it (which is required if you want to expand sda6 to use all the space) Before doing this I'd recommend you save a copy of the following information in the event that you make a typo and need to re-do the partition sizes: fdisk -l /dev/sda; fdisk -lu /dev/sda Save a copy of that output somewhere safe (ie: NOT on the filesystem using sda) in the event that you need it. You shouldn't need this, but it is a good precaution anyway. In the event of a problem you can just re-partition the disk to match this output. To do this next part you can't be using the partition you wish to resize, so you will need to boot a rescue environment, such as the Gentoo Minimal Installation CD or Knoppix. Once booted, open up fdisk and delete the sda6 partition (and sda7 if it's not already deleted.) Then you re-create a new partition in that same location; be sure you create the new partition with exactly the same starting cylinder as the old partition, otherwise the data can't be read by LVM. Next, you need to grow the PV to take advantage of this extra space. In most live-CD environments you first need to activate the VG with a `vgchange -a y VG_NAME` command. Then issue a `pvresize /dev/sda6` to grow the PV to the full size if the new partition. You can confirm this added the space by checking vgs and pvs for the expected readout. From here you're free to grow or add LV's into the new space. -- Josh signature.asc Description: OpenPGP digital signature
[gentoo-user] Extending a partition with LVM on it
Hi Lists, I recently did some rearranging of my partitions, so that everything except / and /boot (they're where my Windows used to be) is on a logical volume. Yay, me. My partitioning now looks like this: marcec marcec # df -h Dateisystem Größe Benut Verf Ben% Eingehängt auf /dev/sda1 1,2G 516M 610M 46% / udev 10M 280K 9,8M 3% /dev tmpfs 501M 0 501M 0% /dev/shm /dev/mapper/maindisk-Var 2,0G 340M 1,7G 17% /var /dev/mapper/maindisk-Usr 20G 13G 7,4G 64% /usr /dev/mapper/maindisk-Opt 15G 8,6G 6,5G 57% /opt /dev/mapper/multimedia-Home 45G 40G 5,7G 88% /home /dev/mapper/multimedia-Media 20G 1,5G 19G 8% /home/marcec/multimedia /dev/mapper/multimedia-Stuff 45G 37G 8,7G 81% /home/marcec/stuff I wasn't sure how big I should make /var and /usr. /opt is that big in the event I install some more games. Otherwise /boot is on sda5, the VG maindisk on sda6 and the VG multimedia on sdb. Now, since Windows was at the beginning of the hard drive, there is a huge gap (about 23 GB) between sda5 and sda6. What I want to know is, how would I go about filling the gap to have a single, large partition for maindisk? Gparted wouldn't do it and I didn't dare do anything with cfdisk. For the moment I added a new partition (via cfdisk, that I did dare do) that takes up the entire gap and extended maindisk to that. It's not what I wanted, but it works. So that puts the VG on both sda6 (new) and sda7 (old sda6). So it looks like this now: marcec marcec # pvs PV VG Fmt Attr PSize PFree /dev/sda6 maindisk lvm2 a-23,22G 23,22G /dev/sda7 maindisk lvm2 a- 273,31G 233,38G /dev/sdb1 multimedia lvm2 a- 149,05G 39,05G Of course, since I didn't do anything else to maindisk, I understand I can always remove the partition from LVM via vgreduce and pvremove. Any hints in this regard, or is my current solution the only viable? -- Marc Joliet -- People who think they know everything really annoy those of us who know we don't - Bjarne Stroustrup signature.asc Description: PGP signature