Skip to content

Instantly share code, notes, and snippets.

@faizal2007
Last active March 1, 2020 07:31
Show Gist options
  • Save faizal2007/2554843cdc41b4f3107e38a35f128804 to your computer and use it in GitHub Desktop.
Save faizal2007/2554843cdc41b4f3107e38a35f128804 to your computer and use it in GitHub Desktop.
Sample related script to manage xen with xen-tools
## Need to run manual paste command
### Create snapshot
lvcreate -L50G -s -n centos-disk-snapshot /dev/sanbox-vg/centos-disk-fresh
### Restore snapshot
lvconvert --merge /dev/sanbox-vg/centos-disk-snapshot
lvchange -an /dev/sanbox-vg/centos-disk-fresh
lvchange -ay /dev/sanbox-vg/centos-disk-fresh
xen-create-image --hostname=dnsserver --size=10Gb --memory=1Gb --swap=2Gb \
--lvm=sanbox-vg --ip=10.10.5.21 --netmask=255.255.255.0 --gateway=10.10.5.1 \
--arch=amd64 --install-method=debootstrap --dist=stretch --passwd
#!/bin/bash
total_memory=$(xm info | grep total_memory | awk '{print $3}')
remaining=$(xm info | grep free_memory | awk '{print $3 - 512}')
used_memory=$((total_memory-remaining))
echo -e 'Total Memory:\t'$total_memory'MB ('$((total_memory/1024))'GB)'
echo -e 'Memory Used:\t'$used_memory'MB ('$((used_memory/1024))'GB)'
echo -e 'Remaining:\t'$remaining'MB ('$((remaining/1024))'GB)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment