Posts

Showing posts with the label Virtualization

How to resize VM disk size

This note provides steps to resize the KVM based VM images. In this situation, VM disk is raw format and filesystem is ext4. Expand disk size In order to expand disk size, VM must be shutdown Increase raw disk size qemu-img resize vm-1.img +10G Resize partition virt-rescue -a vm-1.img At rescue environment ><rescue> fdisk /dev/sdx Use normal fdisk command to delete partition and re-create the partition with bigger size. For this case, I would like to expand /dev/sda3 to have additional 10G ><rescue> fdisk /dev/sda d (select 3 to delete parition sda3) n (create new partition) select as primary select default start and end w (save the changes and exit from fdisk menu) ><rescue> e2fsck -f /dev/sda3 ><rescue> resize2fs /dev/sda3 ><rescue> sync ><rescue> exit I selected default start and end of disk because I want to use the rest of disk spac...

VM image and network configuration at OpenStack environment

This note focuses on VM image and network manipulation at OpenStack environment Glance is the image service in OpenStack envrionment Create CentOS7 image glance image-create --name centos7-64 --file CentOS-7-x86_64-GenericCloud-1706.qcow2 --disk-format qcow2 --container-format bare --progres Default image directory /var/lib/glance/images/ You may want to convert raw disk to qcow2 qemu-img convert -f raw -O qcow2 vm-1.img vm-1.qcow2 Edit config parameter for Glance /etc/glance/glance-api.conf Restart Glance service to take effect of changes systemctl restart openstack-glance-api Neutron is network service at OpenStack environment Create network neutron net-create Custom-network --provider:network_type flat --provider:physical_network externalnet --router:external=True --shared neutron subnet-create --name external_subnet --enable_dhcp=False --allocation_pool start=192.168.1.10,end=192.168.1.250 --gateway=192.168.1.1 --dns 8.8.8.8 External-network 192.168.1.0/...

How to setup Kimchi(Wok) for management of KVM host

This note provides steps how to install kimchi(wok) for management of KVM virtualization Install Centos7 with Minimal installation Update system to up to date yum update -y Install KVM yum -y install qemu-kvm libvirt virt-install bridge-utils bind-utils virt-manager wget net-tools virt-viewer genisoimage epel-release Make sure KVM start upon reboot systemctl start libvirtd systemctl enable libvirtd Download Kimchi project installers wget https://github.com/kimchi-project/kimchi/releases/download/2.5.0/kimchi-2.5.0-0.el7.centos.noarch.rpm wget https://github.com/kimchi-project/kimchi/releases/download/2.5.0/wok-2.5.0-0.el7.centos.noarch.rpm wget http://kimchi-project.github.io/gingerbase/downloads/latest/ginger-base.el7.centos.noarch.rpm wget http://kimchi-project.github.io/ginger/downloads/latest/ginger.el7.centos.noarch.rpm Install RPMs yum localinstall * Start service systemctl enable wokd systemctl start wokd Allow firewall firewall-cmd --zone=public --pe...

How to setup KVM host and manage guest operation systems

This note provides steps how to install KVM and manage Guest OS with virsh. Install KVM yum -y install qemu-kvm libvirt virt-install bridge-utils bind-utils virt-manager wget net-tools virt-viewer genisoimage epel-release Install Guest OS from installer iso image virt-install --name VM-1 --ram 4096 --disk path=/testvm/VM-1.qcow2,size=40 --vcpus 2 --os-type linux --os-variant rhel6 --network bridge=br0 --graphics none --console pty,target_type=serial --cdrom /iso/CentOS-6.8-x86_64-bin-DVD1.iso --force Default directory for intalled VM /var/lib/libvirt/images/ Dump VM config into xml virsh dumpxml VM-1 > VM-1.xml Useful operation commands Create and start VM virsh define VM-1.xml virsh start VM-1 Shutdown VM virsh shutdown VM-1 Poweroff VM virsh destroy VM-1 Remove from VM list virsh undefine VM-1 Resize VM disk size qemu-img resize VM-1.img +60GB

OpenVZ operation commands

This note includes useful commands to adjust guest OS resources allocation at OpenVZ environment. Monitor kmemsize usages cat /proc/user_beancounters Version: 2.5 uid resource held maxheld barrier limit failcnt vm01: kmemsize 836919 1005343 2752512 2936012 0 May increase the barrier and limit vzctl set vm01 --kmemsize [barrier in number]:[limit in number] --save Validate config vzcfgvalidate /etc/vz/conf/vm01.conf Monitor Disk usage vzquota stat vm01 resource usage softlimit hardlimit grace 1k-blocks 327664 1048576 1153434 inodes 18857 200000 220000 Increase diskspace vzctl set vm01 --diskspace 20G:25G --save Increase double of inodes vzctl set vm01 --diskinodes $(( 200000*2 )):$(( 220000*2 )) --save Set CPU allocation vzctl set vm01 --cpuunits 1000 --save vzctl set vm02 --cpuunits 1000 --save vzctl set vm03 --cpuunits 200...

Migrate physical system to OpenVZ container

In this lab, we already install Openvz container kernel at host system. Create new empty VM mkdir /vz/root/101 /vz/private/101 cat /etc/vz/conf/ve-vps.basic.conf-sample > /etc/vz/conf/101.conf Copy data from Physical to VM directory rsync -arvpz --numeric-ids --exclude dev --exclude proc --exclude tmp --exclude sys --exclude mnt -e "ssh -l root@x.x.x.x" root@x.x.x.x:/ /vz/private/101/ Create /etc/vz/conf/101.conf VE_ROOT="/vz/root/$VEID" VE_PRIVATE="/vz/private/$VEID" OSTEMPLATE="centos-5" IP_ADDRESS="192.168.1.1" HOSTNAME="penguin" NAMESERVER="8.8.8.8" #Making adjustments Edit /vz/private/101/etc/inittab sed -i -e '/getty/d' /vz/private/101/etc/inittab Edit /vz/private/101/etc/mtab rm -f /vz/private/101/etc/mtab ln -s /proc/mounts /vz/private/101/etc/mtab Edit /vz/private/101/etc/fstab cp /vz/private/101/etc/fstab /vz/private/101/etc/fstab.old grep devpts /vz/private/101/etc/f...

CentOS 5.1 with Xen Virtualization

At a start, install CentOS minimal installation Update OS using yum yum -y update Install NTP for time sync (Xen HOST only) yum -y install ntp sed -i -e 's/^restrict -6/#restrict -6/' /etc/ntp.conf ntpdate pool.ntp.org hwclock --systohc /etc/rc.d/init.d/ntpd start chkconfig ntpd on Reboot with lastest patches reboot Install Xen and Xen Kernel yum -y install xen kernel-xen Enable booting Xen Kernel sed -i -e 's/^default=1/default=0/' /boot/grub/grub.conf Reboot for new XEN kernel reboot Commands for LVM creation pvcreate /dev/sdax vgcreate vg0 /dev/sdax lvcreate -n vm01 --size 6g vg0 lvcreate -n vm02 --size 6g vg0 Sample config for VM01 to be save to: /etc/xen/vm01 name = "vm01" disk = [ "phy:/dev/vg0/vm01,xvda,w" ] maxmem = 512 memory = 512 vcpus = 2 bootloader = "/usr/bin/pygrub" vif = [ "bridge=xenbr0" ] Populate the Xen VM partition with minimal OS fdisk /dev/vg0/vm01 kpartx -v -a /dev/vg0/...