Skip to content

Instantly share code, notes, and snippets.

@drolfe
Last active April 13, 2016 07:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drolfe/86f865d9fc2bab25224a1d44f30ae501 to your computer and use it in GitHub Desktop.
Save drolfe/86f865d9fc2bab25224a1d44f30ae501 to your computer and use it in GitHub Desktop.
kvm disk form
#! /bin/sh
### BEGIN INIT INFO
# Provides: form_disk
### END INIT INFO
PATH=/sbin:/bin:/usr/sbin:/usr/bin
case "$1" in
start)
/path/to/update/script
;;
stop|restart|reload)
;;
esac
##### below in seperate file #####
before_reboot(){
rm -f /etc/udev/rules.d/70-persistent-net.rules
(echo d; echo 2; echo n; echo p; echo 2; echo 1018 ; echo; echo t; echo 2; echo 8e; echo w ) | sudo fdisk /dev/vda
touch /var/run/rebooting-for-table-update
update-rc.d form_disk defaults
reboot
}
after_reboot(){
pvresize /dev/vda2
lvresize /dev/vg_centos6/lv_root /dev/vda2
resize2fs /dev/mapper/vg_centos6-lv_root
rm /var/run/rebooting-for-table-update
update-rc.d form_disk remove
}
if [ -f /var/run/rebooting-for-table-update ]; then
after_reboot
else
before_reboot
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment