Skip to content

Instantly share code, notes, and snippets.

@javierwilson
Created January 25, 2013 19:27
Show Gist options
  • Save javierwilson/4637104 to your computer and use it in GitHub Desktop.
Save javierwilson/4637104 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ -z $1 ]; then
echo "Usage: $0 <virtual_machine_name>"
exit
fi
VM=$1
HOMEIMG=/home/$VM
OLDDISK=$HOMEIMG/$VM.img
NEWDISK=$HOMEIMG/$VM.new.img
PART=/dev/sda2
LVPART=/dev/vg/lv_root
ADD="+70G"
# Look at current sizing
# virt-filesystems --long --parts --blkdevs -h -a $OLDDISK
# Create output disk. Virt-resize cannot do in-place disk modifications :(
echo "Creating $NEWDISK..."
truncate -r $OLDDISK $NEWDISK
truncate -s $ADD $NEWDISK
echo "Resizing..."
virt-resize --expand $PART --LV-expand $LVPART $OLDDISK $NEWDISK
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment