Mengawinkan Libvirt dengan Ubuntu Cloud Image
- Unduh dan tweak Ubuntu Cloud Image seperti yang pernah saya tuliskan di sini.
- Persiapkan meta data asperti yang dituliskan di sini : http://blog.oddbit.com/2015/03/10/booting-cloud-images-with-libvirt/ atau gunakan skrip https://github.com/larsks/virt-utils/blob/master/create-config-drive
root@studio:~# wget https://github.com/larsks/virt-utils/raw/master/create-config-drive root@studio:~# chmod +x create-config-drive
- Jalankan dengan :
root@studio:~# ./create-config-drive -k /home/samsul/.ssh/id_rsa.pub -u user-data config-virt-install.iso adding pubkey from /home/samsul/.ssh/id_rsa.pub generating configuration image at config-virt-install.iso
- Salin berkas
root@studio:~# virsh vol-list default root@studio:~# cp xenial-server-cloudimg-amd64-disk1.img /var/lib/libvirt/images/ root@studio:~# /etc/init.d/libvirt-bin restart root@studio:~# /etc/init.d/libvirt-guest restart root@studio:~# virsh vol-list default Nama Path ------------------------------------------------------------------------------ blankon-clone.qcow2 /var/lib/libvirt/images/blankon-clone.qcow2 blankon.qcow2 /var/lib/libvirt/images/blankon.qcow2 generic-clone.qcow2 /var/lib/libvirt/images/generic-clone.qcow2 generic.qcow2 /var/lib/libvirt/images/generic.qcow2 vps-template-ubuntu16.04.img /var/lib/libvirt/images/vps-template-ubuntu16.04.img
- Jalanlankan Install
root@studio:~# virt-install -n vps-utemplate -r 2048 -w network=netw1 --disk vol=default/vps-template-ubuntu16.04.img --import --disk path=/home/samsul/Unduhan/ISO/Ubuntu/config-virt-install.iso,device=cdrom Starting install... Creating domain... | 0 B 00:00:01 Domain creation completed.
- VPS sudah bisa dinikmati
root@studio:~# virsh console vps-utemplate Connected to domain vps-utemplate Escape character is ^] .............................................. ..............(proses booting) Ubuntu 16.04.2 LTS ubuntu ttyS0 ubuntu login: root Password: Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-78-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage Get cloud support with Ubuntu Advantage Cloud Guest: http://www.ubuntu.com/business/services/cloud 0 packages can be updated. 0 updates are security updates. root@ubuntu:~#
- Selanjutnya, kita dapat melakukan clone menjadi beberapa VPS.
root@studio:~# virsh shutdown vps-utemplate Domain vps-utemplate is being shutdown root@studio:~# virt-clone --original vps-utemplate --name ceph-ubuntu1 --file /home/samsul/tmp/virsh/ceph-ubuntu1.img Allocating 'ceph-ubuntu1.img' | 2.2 GB 00:00:30 Clone 'ceph-ubuntu1' created successfully. root@studio:~# virsh list --all Id Nama Status ---------------------------------------------------- - BlankOnX shut off - ceph-ubuntu1 shut off - ceph-ubuntu2 shut off - ceph-ubuntu3 shut off - ceph-ubuntu4 shut off - ceph-ubuntu5 shut off - debian8 shut off - ubuntu14.04 shut off - Ubuntu2 shut off - vps-utemplate shut off - Win7 shut off
- Lakukan resize disk
root@studio:~# virsh start ceph-ubuntu1 Domain ceph-ubuntu1 started root@studio:~# virsh blockresize --domain ceph-ubuntu1 --path /home/samsul/tmp/virsh/ceph-ubuntu1.img --size 5GB Block device '/home/samsul/tmp/virsh/ceph-ubuntu1.img' is resized root@studio:~# virsh console ceph-ubuntu1 Connected to domain ceph-ubuntu1 Escape character is ^] ...................................................... ....................(proses booting) Ubuntu 16.04.2 LTS ubuntu ttyS0 ubuntu login: root Password: Last login: Tue Jul 25 02:04:24 UTC 2017 from 192.168.100.1 on pts/0 Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-78-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage Get cloud support with Ubuntu Advantage Cloud Guest: http://www.ubuntu.com/business/services/cloud 0 packages can be updated. 0 updates are security updates. root@ubuntu:~# df -h Filesystem Size Used Avail Use% Mounted on udev 994M 0 994M 0% /dev tmpfs 201M 3.1M 197M 2% /run /dev/sda1 4.5G 833M 3.7G 19% / tmpfs 1001M 0 1001M 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 1001M 0 1001M 0% /sys/fs/cgroup tmpfs 201M 0 201M 0% /run/user/0 root@ubuntu:~#
Sudah selesai, kini VPS dapat digunakan untuk berbagai keperluan nge-LAB.
~~DISQUS~~