Storing Virtual Disks/Containers not on the root drive - HowTO Guide

starnetwork

Renowned Member
Dec 8, 2009
429
10
83
this is the simple steps to configure Virtual Disks/Containers for openVZ separately from root partition

1. Create PhysicalVolume #: pvcreate /dev/sdb
sdb / sdc is your additional hard drive

2. creates a new volume group #: vgcreate openvz /dev/sdb
openvz is your volume group name

3. Create FS #: mkfs.ext3 /dev/sdb

4. Mount the drive to openVZ Directory: mount -t ext3 /dev/sdb /var/lib/vz

Best Regards,
Star Network.
 
Thanks, a minor correction to make things clearer: Virtual Disks/Containers are not stored on the root partition, they are stored in logical volume called "data".

From beginning:

  • The installer takes the whole physical disk (e.g. /dev/sda) and creates 2 partitions (one for /boot and one for LVM), see fdisk
  • LVM contains the following volumes: root, data and swap (see 'lvs')
your howto describes storing /var/lib/vz on a second physical disk, e.g. /dev/sdb/
 
your howto describes storing /var/lib/vz on a second physical disk, e.g. /dev/sdb/
A simple addition, if you edit in your /etc/fstab changing the /dev/pve/data line to
Code:
/dev/vdisk/data /var/lib/vz ext3 defaults 0 1
with "vdisk" being my volume group, "data" being my logical group, and create the folder structure accordingly (as on /dev/pve/data), everything works correct even after reboot.
If you add the line
Code:
/dev/pve/data /var/lib/vz/template ext3 defaults 0 1
and create the folders cache, iso and qemu accordingly, you have still have the ISOs and Templates on your install partition, not wasting valuable RAID space.
Best regards,

christoph
 
Correct me if I'm wrong, but if you follow these instructions you won't be able to snapshot backup your LVM's because you've allocated the whole disk to the volume group...
 
Correct me if I'm wrong, but if you follow these instructions you won't be able to snapshot backup your LVM's because you've allocated the whole disk to the volume group...
Yes, but there are options. In your Volume Group you can create a logical volume for backups, like
Code:
lvcreate -n {lgname} -L {size} {vgname}
mkfs -t ext3 /dev/vgname/lgname
mount the lg and put backups there.
Or you can mount some share (Windows Samba, NFS etc.) on a complete different system - a good idea anyway - and put backups there, described in the Proxmox wiki.
Best regards

christoph