Labels

Monday, October 24, 2011

Resizing with LVM

I am running a proxmox server with several virtual machines and noticed that I have more disk space configured on the virtual machines then I have on the partition they are running on. Here are the steps I took to increase the size of the ext3 partition hosting the vms.


  1. View the mount points to determine what logical volume the vms are on
  2. ~# mount
    /dev/pve/root on / type ext3 (rw,errors=remount-ro)
    tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
    proc on /proc type proc (rw,noexec,nosuid,nodev)
    sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
    procbususb on /proc/bus/usb type usbfs (rw)
    udev on /dev type tmpfs (rw,mode=0755)
    tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
    devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
    /dev/mapper/pve-data on /var/lib/vz type ext3 (rw)
    /dev/cciss/c0d0p1 on /boot type ext3 (rw)
  3. View the logical volume to determine what volume group it is on:
  4. ~# lvdisplay /dev/mapper/pve-data
      --- Logical volume ---
      LV Name                /dev/pve/data
      VG Name                pve
  5. View the volume group to be sure there is room for expansion:
  6. ~# vgdisplay pve
      --- Volume group ---
      VG Name               pve
      System ID
      Format                lvm2
      Metadata Areas        2
      Metadata Sequence No  2236
      VG Access             read/write
      VG Status             resizable
      MAX LV                0
      Cur LV                3
      Open LV               3
      Max PV                0
      Cur PV                2
      Act PV                2
      VG Size               477.93 GB
      PE Size               4.00 MB
      Total PE              122351
      Alloc PE / Size       44928 / 175.50 GB
      Free  PE / Size       77423 / 302.43 GB
      VG UUID               ThGaW0-KPoF-ZA3V-jgxE-zv6d-jaMY-Pc8Y1W
  7. Extend the logical volume (-L flag as used below allows you to specify the new size of the volume):
  8. ~# lvextend -L150G /dev/pve/data
      Extending logical volume root to 150.00 GB
      Logical volume root successfully resized
  9. Resize the ext3 partition
  10. ~# resize2fs /dev/pve/data
    resize2fs 1.41.3 (12-Oct-2008)
    Filesystem at /dev/pve/data is mounted on /var/lib/vz; on-line resizing required
    old desc_blocks = 4, new_desc_blocks = 10
    Performing an on-line resize of /dev/pve/data to 39321600 (4k) blocks.
    The filesystem on /dev/pve/data is now 39321600 blocks long.
Pretty easy.

Monday, January 10, 2011

Create copy of VM on Proxmox

  1. Ssh into the Proxmox server as root.
  2. Run "vzdump" with desired VMID.
  3. $vzdump 101
  4. Run "qmrestore" with unused VMID. Your dump file should be located in /var/lib/vz/dump.
  5. $qmrestore /var/lib/vz/dump/vzdump-qemu-101-2011_01_10-11_13_30.tar 102
I tested this with a Ubuntu server 10.10 VM.  From the Proxmox console I deleted the network device and recreated it to be sure it had a unique MAC address (not sure if that was necessary).  I started the new VM, logged in, and changed the hostname and some values for the apache server.


**UPDATE (02/09/2011)**
I noticed that when running the this command I would see:
INFO: mode failure - unable to dump into snapshot (use option --dumpdir)
After some intrepid googling I discovered this was because the dump was being created on the same lvm group vzdump had to suspend the vm to do the backup.  To avoid this (since I was backing up a live webserver) I mounted a windows share (on a domain) and pointed the dump to there.

  1. Mount the windows share to the /mnt/share directory (be sure that directory exists)
  2. $mount -t smbfs //server/share /mnt/share -o username=domainuser
  3. Run vzdump with the --dumpdir option
  4. $vzdump --dumpdir /mnt/share/dumps 101

Linux DNS entry

As I was playing with linux servers I noticed that a DNS entry was not being created when I added new servers to the network. After some googling I found the solution. If you are running dhcp3 update your dhclient.conf (mine was under /etc/dhcp3) to include the following line:

send fqdn.server-update on;

Restart networking.