Linux – create a LVM snapshot on a “full” logical volume

centos5linuxlvmsnapshot

I want to try using LVM snapshots for backups. I'm working on an older CentOS 5 box, but I'm not sure if I can do it. From what I read, it seems like I need extra space on the physical disk in which to create a new volume. Is that the case? To me, from looking at the LVM command output, it looks like everything is full… It isn't, there is 13 GB free on the root filesystem, but I don't think that matters. This is my current state:

[root@server ~]# pvdisplay
  /dev/cdrom: open failed: No medium found
  --- Physical volume ---
  PV Name               /dev/hda2
  VG Name               VolGroup00
  PV Size               19.89 GB / not usable 19.49 MB
  Allocatable           yes (but full)
  PE Size (KByte)       32768
  Total PE              636
  Free PE               0
  Allocated PE          636
  PV UUID               O6N2b1-RxMe-gnEz-5Nkr-A7pA-AzLe-n2Qwy0

[root@server ~]# lvdisplay
  /dev/cdrom: open failed: No medium found
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                PxmE7L-5B6b-Bvnp-zuca-SaiG-b20A-dDM4qq
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                17.91 GB
  Current LE             573
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol01
  VG Name                VolGroup00
  LV UUID                uGP3Jz-pPJW-KLet-YZHC-5Uzn-8jT3-4GHPX7
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                1.97 GB
  Current LE             63
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

[root@server ~]# vgdisplay
  /dev/cdrom: open failed: No medium found
  --- 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               19.88 GB
  PE Size               32.00 MB
  Total PE              636
  Alloc PE / Size       636 / 19.88 GB
  Free  PE / Size       0 / 0
  VG UUID               vSc34e-sbP3-lwaj-PF9p-921E-3oP8-vkwJIz

Maybe I can shrink my / volume, then create a new one, then snapshot onto the new one? Is that the only way (without messing with hardware)?

Thanks

Best Answer

Your volume group is full, so you can't create any logical volume, snapshot or whatever.

The basics of lvm is to always keep space available in the volume groups so that you can create new volume, snapshots of volumes and eventually extend volume.

The solutions you have are:

  • Add a physical volume to your volume group
  • reduce / suppress a logical volume in your volume group

Then you will be able to create snapshots. When you create a snapshot you allocate some space to it. At creation no space will be used, but when the original volume will receive modifications the snapshot will begin to allocate space in order to keep in its original state. Also you can write to a snapshot, this will reclaim space on it and not alter the original volume. Once all the space allocated to the snapshot is used the snapshot is unusuable.