Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2484230
  • 博文数量: 609
  • 博客积分: 10061
  • 博客等级: 上将
  • 技术积分: 5920
  • 用 户 组: 普通用户
  • 注册时间: 2008-06-25 08:30
文章分类

全部博文(609)

文章存档

2010年(13)

2009年(39)

2008年(558)

我的朋友

分类: LINUX

2008-08-30 08:05:00

Using Xen and virtualization tools in Fedora 7

Now was the time to test how Xen works on my Fedora7 (installed on the laptop). First thing I did was to update my Fedora via yum update. That updated alot of stuff after a base install. To start with, the packages I was going to use have cool updates available. The versions of packages I am using right now are:

kernel-xen-devel-2.6.20-2925.9.fc7
kernel-xen-2.6.20-2925.9.fc7
xen-libs-3.1.0-0.rc7.1.fc7
xen-3.1.0-0.rc7.1.fc7
virt-manager-0.4.0-2.fc7
libvirt-0.2.3-1.fc7
python-virtinst-0.103.0-3.fc7
libvirt-python-0.2.3-1.fc7
dnsmasq-2.38-1.fc7
httpd-2.2.4-4


Though httpd not necessary but I used it for installation source so I have to check it out too :).

The first step is to boot into a Fedora7 xen kernel. After the boot I guess xend daemon must be running. If it isn't running we must start it. The next thing for me (a laptop user) was to check out /etc/xen/xend-config.sxp and comment this out

Line 143: (network-script network-bridge)


and un-comment this
Line 149: #(network-script /bin/true)


so that xen can use the virtual networking interface provided by libvirt that is basically a bridged + NAT forward network.

Now the next thing is to restart xend and libvirtd daemon.

service libvirtd restart
service xend restart
chkconfig xend on
chkconfig libvirtd on


After following services are restarted a typical ifconfig looks like below:

eth0      Link encap:Ethernet  HWaddr 00:0F:B0:C9:43:03  
inet addr:192.168.2.9 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::20f:b0ff:fec9:4303/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:57 errors:0 dropped:0 overruns:0 frame:0
TX packets:67 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:16531 (16.1 KiB) TX bytes:12359 (12.0 KiB)
Interrupt:21 Base address:0x4000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:16300 errors:0 dropped:0 overruns:0 frame:0
TX packets:16300 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:147442764 (140.6 MiB) TX bytes:147442764 (140.6 MiB)

virbr0 Link encap:Ethernet HWaddr 00:00:00:00:00:00
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
inet6 addr: fe80::200:ff:fe00:0/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:29417 errors:0 dropped:0 overruns:0 frame:0
TX packets:67430 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1533486 (1.4 MiB) TX bytes:98153742 (93.6 MiB)


The eth0 is my wired ethernet and virbr0 is a virtual network device provided by libvirtd. Note that it has it's own IP subnet that is 192.168.122.0/255.255.255.0 and by default it is bridged to the available physical network device. So our virtual vm is going to communicate with the dom0 host via this interface.

So the next step is to configure the install source. I mostly prefer a http install source. So I mounted my fedora 7 ISO on to a mount point and later configured that mount point directory in apache for http access. The series of commands I gave were

mkdir /media/iso
mount -t iso9660 -o ro,loop /media/sda3/F-7-i386-DVD.iso /media/iso
vi /etc/httpd/conf/httpd.conf

Line 991:
Line 992: ServerAdmin webmaster@dummy-host.example.com
Line 993: DocumentRoot /media/
Line 994:
Line 995: Options Indexes Includes
Line 996:

Line 997: ServerName server.example.com
Line 998: ErrorLog logs/server.example.com-error_log
Line 999: CustomLog logs/server.example.com-access_log common
Line 1000:


service httpd restart


Now comes the next important step to start creating the virtual machine. I am first going to show how I created the vm using the command line tool called virtinstall and later will tell how we can use the GUI based tool called virt-manager to perform the same operation.

So the quick run of virt-install is shown below:

[root@localhost ~]# virt-install 
Would you like a fully virtualized guest (yes or no)? This will allow you to run unmodified operating systems. no
What is the name of your virtual machine? fedora7pv1
How much RAM should be allocated (in megabytes)? 512
What would you like to use as the disk (path)? /media/sda3/linux.img
Would you like to enable graphics support? (yes or no) yes
What is the install location?


If everything went fine you will soon see a vnc viewer under which the installation of Fedora7 is performed. You can from here proceed in the same way as you proceed while installing fedora7 normally. The only thing I would like to comment is about the networking part which comes during "Configuring TCP/IP" very early during installation. I selected here enable ipv4 network and dhcp (don't have ipv6 yet to test :().

Now I tried to create the same configuriation VM using the GUI based virt-manager. To start virt-manager in fedora7 Applications -> System Tools -> Virtual machine manager. I would not discuss the steps I used to perform the installation as the screenshots shown below are pretty self-explanatory.

After the installation is done it's time to start the freshly installed virtual machine. How you start your VM doesn't depends on how you installed the VM (either virt-install or virt-manager).

I still haven't figured out how to start the VM via command line. Earlier in RHEL5 it used to be like this:

cd /etc/xen/auto
ln -s ../rhel5pv1 rhel5pv1
service xendomains start
chkconfig xendomains on


That used to start the VM which I could later communicate via:

xm console rhel5pv1


But this seems to be not working right now. I will probably get to know about this later. Okay for now you can start the VM via virt-manager the cool GUI. When you start virt-manager it shows you the list of available VM. On the top is dom0 (the host) and below are the VM's available on the system. I have only VM right now so I select it, right click it and then select start. This will start the VM in the background if you want to see what's going on behind the scene you can again right click on the VM and select Open. This will show you the VM's screen in a window that you can later use to access the VM.

Here are the I took to explain the process of VM creation via virt-manager.

阅读(963) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~