Removing Vol-Group
I'm geting more and more annoyed on one of the HDDs that is part of a volume-group.
Is it possible to split a volume group into separate logical volumes so that I can remove the loud HDD without loss of data? (The volume-group is ~20% full). Thanks! |
Use the pvmove command to move the physical extents to partitions on the other disks. See:
man pvmove and be sure to look at the example at the end of the man page. Also, see Chapter 11 "Common Tasks" in the LVM HowTo: http://www.ibiblio.org/pub/Linux/doc...LVM-HOWTO.html It's a good idea to minimize the logical volumes before you start pvmove, but be very careful! All of this needs to be done with the logical volumes unmounted for an ext3 filesystem. |
Thank you for the help!
However when I try to use the pvmove command I get the following error: Code:
[root@disco peren]# /usr/sbin/pvmove /dev/hdb1 [linux-lvm] Cleanly removing a PV from an LV or, how do I get more available extents? Because the VolGroup is mounted as /, is it still possible to unmount and resize the group before I do the pvmove or am I forced to scrap the data in the volume group? I'm still a n00b so I need specific information on how to proceed. Thanks! Here is more information that might help Code:
Device Type Size Mount Point Free Full % Code:
[root@disco peren]# mount Code:
[root@disco peren]# /usr/sbin/lvdisplay Code:
[root@disco peren]# /usr/sbin/vgdisplay Code:
[root@disco peren]# /usr/sbin/pvdisplay |
It looks like there is no unallocated space in the volume group, so you need to shrink the logical volume(s) to make some space. You should make them as small as possible, or you may run into a “contiguous space” error when you use pvmove.
You will need to boot into rescue mode using the first installation CD (boot: linux rescue) and do the work from there. Be sure to NOT search for or mount the installation. If you get the suggestion to “chroot /mnt/sysimage”, then you need to reboot, because the filesystem or some part of it has been mounted. When you shrink a logical volume, you need to first shrink the filesystem and then shrink the logical volume. What I do is to make the filesystem a little smaller than the target logical volume size. For example, if you had the logical volume /dev/VG00/LV00 that you wanted to shrink from 20GB to 10GB, you would: resize2fs /dev/VG00/LV00 9G lvm lvresize -L 10G /dev/VG00/LV00 That would give you a 9GB filesystem inside a 10GB logical volume. Note the use of “lvm ...” in rescue mode. After you use “lvm pvmove...”, you would then use “lvm pvremove...” to eliminate the bad partition and then grow the logical volumes and filesystems back whatever sizes you want. For example: lvm lvresize -L 20G /dev/VG00/LV00 resize2fs /dev/VG00/LV00 That would give you a 20GB filesystem inside a 20GB logical volume. |
Problem:
I want to shrink my LVM system to occupy 40G on an 80G drive so that I can clone it to an empty 40G. Background: I installed FC6 on an 80G drive, accepted default partition sizes (who am I to argue with Linux?), and set up my server. To keep it safe, I cloned the 80G (using G4U -basically the dd command) on to a 320G that I could safely "mess with". The 320G has since evolved into the system I want to run, so I need to clone it onto a 40G for daily use and abuse. G4U won't clone a big drive onto a small one. Rather than risk ruining my 320G, I will try to shrink the less valuable 80G and then G4U it on to the empty 40G. There is more than enough space on the 40G to hold my stuff. If this works, I will apply the method to move 320G to 40G. THIS IS MY 80G DRIVE: Filesystem ext3 ******************************************************************** Disk /dev/hda: 80.0 GB, 80026361856 bytes 255 heads, 63 sectors/track, 9729 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hda1 * 1 13 104391 83 Linux /dev/hda2 14 9729 78043770 8e Linux LVM ******************************************************************** HERE'S LVM INFO: ******************************************************************** [root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup00-LogVol00 71G 3.6G 64G 6% / /dev/hda1 99M 17M 78M 18% /boot tmpfs 490M 0 490M 0% /dev/shm [root@localhost ~]# vgdisplay --- Volume group --- VG Name VolGroup00 System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 3 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 1 Act PV 1 VG Size 74.41 GB PE Size 32.00 MB Total PE 2381 Alloc PE / Size 2380 / 74.38 GB Free PE / Size 1 / 32.00 MB VG UUID 1VTA50-C4sx-BAPf-VJAr-iOo8-dW0m-UgLmGD ******************************************************************** I think that shrinking my LV00 to 37 will allow me to clone it to the 40G using G4U. Following your example (WhatsHisName), I think I need to do this: 1) Boot with "linux rescue" option 2) resize2fs /dev/VG00/LV00 37G 3) lvm lvresize -L 38G /dev/VG00/LV00 4) Clone this to the 40G drive where I will then: 5) lvm lvresize -L 40G /dev/VG00/LV00 6) resize2fs /dev/VG00/LV00 Did I get it right ? Is there a better way to move my server to a smaller drive? Thanks. PS: What do you think of this method: http://forums.fedoraforum.org/forum/...t=lvm+commands |
All times are GMT -5. The time now is 02:10 AM. |