-   Fedora (
-   -   Removing Vol-Group (

BadKharma 11-20-2005 01:40 PM

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).


WhatsHisName 11-22-2005 02:06 AM

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:

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.

BadKharma 11-23-2005 05:42 AM

Thank you for the help!

However when I try to use the pvmove command I get the following error:


[root@disco peren]# /usr/sbin/pvmove /dev/hdb1
  No extents available for allocation

After googling for help I found another with the same problem.

[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.


Here is more information that might help


Device                          Type    Size    Mount Point    Free    Full %

/dev/VolGroup00/LogVol00        ext3    N/A    /              0 B    N/A
/dev/hda1                      ?      98.7 MB /boot          75.0 MB 24.1%
/dev/hdc                        auto    N/A    /media/cdrom1  0 B    N/A
/dev/hdd                        auto    N/A    /media/cdrom    0 B    N/A
/dev/mapper/VolGroup00-LogVol00 ?      21.3 GB /              15.6 GB 26.7%


[root@disco peren]# mount
/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw)
none on /proc type proc (rw)
none on /sys type sysfs (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
usbfs on /proc/bus/usb type usbfs (rw)
/dev/hda1 on /boot type ext3 (rw)
none on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)


[root@disco peren]# /usr/sbin/lvdisplay
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                3M41jb-GlLM-Ae2R-mH00-idnU-pg5z-G9hhA6
  LV Write Access        read/write
  LV Status              available
  # open                1
  LV Size                21.69 GB
  Current LE            694
  Segments              4
  Allocation            inherit
  Read ahead sectors    0
  Block device          253:0

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol01
  VG Name                VolGroup00
  LV UUID                icidbq-dYP8-8ZWB-hLQe-YoPb-mr3A-ledN5e
  LV Write Access        read/write
  LV Status              available
  # open                1
  LV Size                256.00 MB
  Current LE            8
  Segments              1
  Allocation            inherit
  Read ahead sectors    0
  Block device          253:1


[root@disco peren]# /usr/sbin/vgdisplay
  --- Volume group ---
  VG Name              VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  6
  VG Access            read/write
  VG Status            resizable
  MAX LV                0
  Cur LV                2
  Open LV              2
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size              22.00 GB
  PE Size              32.00 MB
  Total PE              704
  Alloc PE / Size      702 / 21.94 GB
  Free  PE / Size      2 / 64.00 MB
  VG UUID              G1THgD-aacB-XjNy-cDN3-JN8P-BcYl-8J137H


[root@disco peren]# /usr/sbin/pvdisplay
  --- Physical volume ---
  PV Name              /dev/hdb1
  VG Name              VolGroup00
  PV Size              9.41 GB / not usable 0
  Allocatable          yes
  PE Size (KByte)      32768
  Total PE              301
  Free PE              2
  Allocated PE          299
  PV UUID              1IKP6J-LOSn-UwL8-D4As-U1D6-NEqk-YcnW7i

  --- Physical volume ---
  PV Name              /dev/hda2
  VG Name              VolGroup00
  PV Size              12.59 GB / not usable 0
  Allocatable          yes (but full)
  PE Size (KByte)      32768
  Total PE              403
  Free PE              0
  Allocated PE          403
  PV UUID              69s3fO-J0SL-dJUC-Dtm7-d4x3-vN1b-h1KiE9

WhatsHisName 11-23-2005 12:06 PM

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.

Paulinux 09-29-2007 12:31 PM

I want to shrink my LVM system to occupy 40G on an 80G drive so that I can clone it to an empty 40G.

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

[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
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
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?


PS: What do you think of this method:

All times are GMT -5. The time now is 08:00 AM.