Posts

Showing posts from July, 2014

How to Mount the VM Disk

Mount the VM Disk which built On image file, ------------------------------------------------------------------------- losetup /dev/loop0 /root/mailserver.img -Attach the image file to loop device. kpartx -a -v /dev/loop0 -Map the vm partitions, Output: ------------ add map loop0p1 (253:4): 0 1024000 linear /dev/loop0 2048 add map loop0p2 (253:5): 0 7362560 linear /dev/loop0 1026048 Then mount the VM partitions, mount /dev/mapper/loop0p1 /mnt/boot mount /dev/mapper/loop0p2 /mnt/root -->if it is not LVM. if vm root partition is an LVM, You will receive the below error, mount: unknown filesystem type 'LVM2_member' Which means LVM not identify that vm lvm partition.   pvscan vgscan && lvscan Output: ------------- inactive '/dev/VolGroup/lv_root' [17.54 GiB] inherit inactive '/dev/VolGroup/lv_swap' [1.97 GiB] inherit   ACTIVE '/dev/vg0/ubuntu' [10.00 GiB] inherit ACTIVE

Storage Topics

https://www.brainshark.com/netapp/vu?pi=zHZzXcLDoz3ncNz0

Mapping physical storage to domU disk

Protocol Description Example phy: Block devices, such as a physical disk, in domain 0 phy:/dev/sdc file: Raw disk images accessed by using loopback file:/path/file nbd: Raw disk images accessed by using NBD ndb: ip_port tap:aio: Raw disk images accessed by using blktap . Similar to loopback but without using loop devices. tap:aio:/path/file tap:cdrom CD reader block devices tap:cdrom:/dev/sr0 tap:vmdk: VMware disk images accessed by using blktap tap:vmdk:/path/file tap:qcow: QEMU disk images accessed by using blktap tap:qcow:

OpenSource Cloud Projects that you could FOCUS on !

*1. Hypervisor and Container* *Docker. Io* - an open-source engine for building, packing and running any application as a lightweight container, built upon the LXC container mechanism included in the Linux kernel. It was written by dotCloud and released in 2013. *KVM* - a lightweight hypervisor that was accepted into the Linux kernel in February 2007. It was originally developed by Qumranet, a startup that was acquired by Red Hat in 2008. *Xen Project* - a cross-platform software hypervisor that runs on platforms such as BSD, Linux and Solaris. Xen was originally written at the University of Cambridge by a team led by Ian Pratt and is now a Linux Foundation Collaborative Project. *CoreOS* – a new Linux distribution that uses containers to help manage massive server deployments. Its beta version was released in May 2014. *2. Infrastructure as a Service* *Apache Cloud**S**tack* - an open source IaaS platform with Amazon Web Services (AWS) compatibility. CloudStack was originally

Xen HVM Migration

Migrate VM[vm139]: Source Node: ------------- --- Logical volume ---   LV Path                /dev/vg_grp/vm139_img   LV Name                vm139_img   VG Name                vg_grp     LV Status              available   # open                 3   LV Size                10.00 GiB   Current LE             320   Segments               1   Allocation             inherit   Read ahead sectors     auto   - currently set to     256   Block device           253:24 Source Node: ------------- Backup: -------- lvcreate -n vm139_backup --size 15G /dev/vg_grp mkfs.ext3 /dev/vg_grp/vm139_backup mkdir -p /home/vm139_backup mount /dev/vg_grp/vm139_backup /home/vm139_backup xm shutdown vm139 dd if=/dev/vg_grp/vm139_img of=/home/vm139_backup/vm139_backup.img Destination Node: ----------------- lvcreate -n vm139_backup --size 15G /dev/vg_xenhvm lvcreate -n vm139_img --size 10G /dev/vg_xenhvm mkfs.ext3 /dev/vg_xenhvm/vm139_backup mkdir -p /home/vm139_backup mount /dev/vg_xenhvm/vm139_backup /home/vm139_

Port Mirroring

Port mirroring is an approach to monitoring network traffic that involves forwarding a copy of each  packet  from one network  switch  port to another. Port mirroring enables the administrator to keep close track of switch performance by placing a protocol analyzer on the  port  that's receiving the mirrored data. An administrator configures port mirroring by assigning a port from which to copy all packets and another port to which those packets will be sent. A packet bound for -- or heading away from -- the first port will be forwarded to the second port as well. The administrator must then place a protocol analyzer on the port that's receiving the mirrored data to monitor each segment separately. Network administrators can use port mirroring as a diagnostic or  debugging  tool. 

Xen DomU booting process on HVM[pure]

For this, the booting process starting with.         Welcome to CentOS Starting udev: piix4_smbus 0000:00:01.3: SMBus base address uninitialized - upgrade BIOS or use force_addr=0xaddr [  OK  ] Setting hostname localhost.localdomain:  [  OK  ] Setting up Logical Volume Management:   No volume groups found [  OK  ] Checking filesystems Checking all file systems. [/sbin/fsck.ext4 (1) -- /] fsck.ext4 -a /dev/xvda2 /dev/xvda2: clean, 18459/512064 files, 218237/2048000 blocks [/sbin/fsck.ext4 (1) -- /boot] fsck.ext4 -a /dev/xvda1 /dev/xvda1: clean, 38/51200 files, 34256/204800 blocks [  OK  ] Remounting root filesystem in read-write mode:  [  OK  ] Mounting local filesystems:  [  OK  ] Enabling /etc/fstab swaps:  [  OK  ] Entering non-interactive startup ip6tables: Applying firewall rules: [  OK  ] iptables: Applying firewall rules: [  OK  ] Bringing up loopback interface:  [  OK  ] Bringing up interface eth0:  Determining IP information for eth0... done. [  OK  ] Starting auditd: [  OK 

Xen DomU booting process [PV on HVM].

Centos: ------------- -Kernel loaded with parameter ide0=noprobe[it will prevent disk & NIC emulation, use xen pv drivers]. Linux version 2.6.32-431.el6.x86_64 (mockbuild@c6b8.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ) #1 SMP Fri Nov 22 03:15:09 UTC 2013 Command line: ro root=UUID=07a30ea1-f06a-44e5-a85a-6e346bb9e3af rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quieti console=ttyS0 ide0=noprobe E.g. Netfront and the Xen platform PCI driver have been compiled for this kernel: unplug emulated NICs. Blkfront and the Xen platform PCI driver have been compiled for this kernel: unplug emulated disks. Booting paravirtualized kernel on Xen NR_CPUS:4096 nr_cpumask_bits:15 nr_cpu_ids:15 nr_node_ids:1  Xen HVM callback vector for event delivery is enabled Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251) io scheduler noop registered io sch

SSL redirect issue in cpanel

If a domain using shared ip..... if someone access domain with https.. then the request would be sent to the default document root[htdocs] instead of the actual one... so that the redirect rules also  not working in .htaccess. -Need to update the below code in index.html under htdocs. [root@vm5 htdocs]# cat index.html <html><head><script> window.location.href = (window.location.protocol != "http:") ? "http:" + window.location.href.substring(window.location.protocol.length) : "/cgi-sys/defaultwebpage.cgi"; </script></head><body></body></html>

Database Backup script

#!/bin/bash export savepath='/var/mysqlbackups' export usr='mysql user' export pwd='' if [ ! -d $savepath ]; then     mkdir -p $savepath fi chmod 700 $savepath rm -rf $savepath/* echo 'mySQL Backup Script' echo 'Dumping individual tables..' for a in `echo 'show databases' | mysql -u$usr -p$pwd | grep -v Database | grep -v information_schema`; do echo $a   mkdir -p $savepath/$a   chmod 700 $savepath/$a   echo "Dumping database: $a" echo for i in `mysqldump --no-data -u $usr -p$pwd $a | grep 'CREATE TABLE' | sed -e 's/CREATE TABLE //' | sed -e 's/(.*//' | sed -e 's/\ /|/g' |sed -e's/|$//'`   do    echo "i = $i";    c=`echo $i|sed -e's/|/\ /g'|sed -e 's/\`//g'`;    echo " * Dumping table: $c"    mysqldump --compact --allow-keywords --add-drop-table --allow-keywords --skip-dump-date -q -a -c -u$usr -p$pwd $a "$c" > "$savepath/$a/$c.sql&quo

Enable text console for HVM Domu

 Is there any way to change Graphical console[vnc] to the non-graphical console (xen console)? For HVM guest, you need to enable serial port on domU config file (example here: http://pastebin.com/fb6fe631), and setup domU to use serial port (ttyS0 on Linux) by modifying (for Linux domU) /boot/grub/menu.lst, /etc/inittab, and /etc/securetty. If it's PV guest, you need to set up domU to use xen console (which is xvc0 on current xen version, hvc0 on pv_ops kernel). It's similar to setting up domU for serial console, you just need to change ttyS0 to hvc0. An example of domU setup that can use both xvc0 and vnc console is here : http://pastebin.com/f6a5022bf Referenece 1: ---------------- Part 2, converting HVM guest to PV guest #======================================================================= First we need to install kernel-xen with correct initrd - yum install kernel-xen - edit /boot/grub/menu.lst so it looks like this #====================================

How to create VM in xen virtualization

The command below will create an 8GB file that will be used as an 8GB drive. The whole file will be written to disk in one go so may take a short while to complete. dd if=/dev/zero of=/xenimages/test01/disk1.img oflag=direct bs=1M count=8192 Alternatively, you can use the command below to create the same size file as a sparse file. What this does is create the file, but only take up disk space as the file is used. In this case the file will only really take about 1mb of disk initially and grow as you use it. dd if=/dev/zero of=/xenimages/test01/disk1.img oflag=direct bs=1M seek=8191 count=1 There are pros and cons of using sparse files. On one hand they only take as much disk as is actually used, on the other hand the file can become fragmented and you could run out of real disk if you overcommit space. Next up we’ll mount the install CD and export it over nfs so that xen can use it as a network install. mkdir /tmp/centos52 mount /dev/hda /tmp/centos52 -o loop,ro Jus