I love Free Software!

Pages

Funny Quotes to Think

When you say "I wrote a program that crashed Windows", people just stare at You blankly and say "Hey, I got those with the system, for free"

-Torvalds, Linus(1995-03-08)-

Saturday, July 10, 2010

Create a virtual HDD using qemu-img

When you create a virtual machine using KVM and virt-manager, virtual HDD will create in /var/lib/libvirt/images/ directory. Unfortunately I dont have enough  space in my / partition.
I faced difficulty in creating virtual HDD in other partion using virt-manager. To work around this issue, I used qemu-image. Using qemu-img you can create a new vitual HDD with any size on any of your partition

 # qemu-img create -f qcow debian.qcow 5G

This will create a Virtual HDD debain.qcow with size 5GB, later then you can select this HDD for installation using virt-manager

Create a shared network interface for KVM

KVM Virtual machines uses its own virtual network as the default network. If you want to access your virtual machine inside your LAN, you need to change your virtual network interface to shared network interface.

How to create shared interface ??
Configure your physical interface as a bridge in your machine (not in virtual machine). Then you can create a new network interface for you virtual machine with source interface as bridge

Here in my machine I have one interface eth0. I changed my physical interface to a bridge interface so that any of my virtual machine can share my physical interface for networking

edit your network configuration

 # vi /etc/network/interfaces

Change your configuration to make your interface eth0 as a bridge

auto eth0
iface eth0 inet manual

auto bro
iface br0 inet static
         address 192.168.1.10
         netmask 255.255.255.0
         gateway 192.168.1.1
         bridge-ports eth0
         bridge-stp on
         bridge-maxwait 0

This will create a bridge interface br0

Wednesday, July 7, 2010

Apache redirect webiste to another using mod_rewrite

In some situation you may need to redirect your website to another website.
For example I have two domains example.net and example.com. Since I don't have any web pages uploaded for example.net,  I just want to redirect example.net to my existing site example.com.

Create an Apache virtual host for example.net and redirect your website using mod_rewrite.

You can look apache site for more details about mod_rewrite module. Apache Rewrite Module

Here is my virtualhost configuration for example.net

<VirtualHost *:80>
    ServerAdmin admin@example.net
    DocumentRoot /var/www/example.net
    ServerName example.net
    ServerAlias www.example.net

<Directory /var/www/example.net>
Options +FollowSymLinks
RewriteEngine on
Redirect 301 / http://example.com/
RewriteCond %{HTTP_HOST} ^([^.:]+\.)*example\.net\.?(:[0-9]*)?$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
</Directory>
</VirtualHost>