Prepare a stock centos HN to do vzdumps using LVM snapshots

Situation:

- Stock Centos 4 system with OpenVZ kernel + utilities installed. One big /vz partition, using LVM.

Trying to make a backup using:

vzdump --dumpdir /var/ --snapshot 101
Error message received:
Insufficient free extents (1) in volume group
VolGroup00: 16 required
What does that mean?

It means that you don't have enough free space in the VG (Volume Group) to create an LVM snapshot.

What is the solution? Reduce the size of one partition, then resize one LV (logical volume). This is easily done if you don't have only one big / partition. I usually always make a separate partition for /var and for /vz.

To determine what logical volume needs to be resized, you can use the df -h command. Mine showed:

/dev/mapper/VolGroup00-LogVol05
119G 16G 99G 14% /vz

To resize it:

  1. Make backups of your VM to be sure
  2. Stop the vz service (service vz stop)
  3. umount /vz
  4. e2fsck -f /dev/VolGroup00/LogVol05
  5. Use resize2fs /dev/VolGroup00/LogVol05 110G
  6. Use lvresize to reduce the LV sizey by 2 GB:lvresize --size -2G /dev/VolGroup00/LogVol05
Optionnaly, you can resize your FS to match the size of the LV, using no size arguments to ext2resize:
  1. e2fsck -f /dev/VolGroup00/LogVol05
  2. resize2fs /dev/VolGroup00/LogVol05
I have not re-tested this procedure itself from the beginning (I don't have a test system here), but it should be pretty safe. Please leave comments if you try this.

If you need to know how big are your LV : lvdisplay.
If you need to know how big are our VG: vgdisplay. This also tells the free space in the VG.

You can not try to use lvm snapshots with vzdump.

Comments

Popular posts from this blog

General linux performance troubleshooting

Asterisk works under OpenVZ (no zaptel)