CentOS 5
Sponsored Link

Install GuestOS in a virtual disk
[1] I created GuestOS in LVM partition, but in this section, I create it in an image-file like Vmware products. It's easier to backup or move to another computer than the one in LVM partition. However, it's slower to access to disks than the one in LVM, though.
[root@ns ~]#
mkdir /var/xen

[root@ns ~]#
dd if=/dev/zero of=/var/xen/lan.img bs=1 count=1 seek=20G

1+0 records in
1+0 records out
1 byte (1 B) copied, 7.8e-05 seconds, 12.8 kB/s
[root@ns ~]#
dd if=/dev/zero of=/var/xen/lan.swap bs=1 count=1 seek=1G

1+0 records in
1+0 records out
1 byte (1 B) copied, 8e-05 seconds, 12 kB/s
[root@ns ~]#
[root@ns ~]#
mkswap /var/xen/lan.swap

Setting up swapspace version 1, size = 1073737 kB
[root@ns ~]#
mkfs -t ext3 -F /var/xen/lan.img

mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
2621440 inodes, 5242880 blocks
262144 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
160 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
 
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

 
4096000


Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

[root@ns ~]#
mount -o loop /var/xen/lan.img /mnt


[root@ns ~]#
cp root.tgz /mnt/
# copy it created in (3)-[3]

[root@ns ~]#
cd /mnt

[root@ns mnt]#
tar zxvf root.tgz

[root@ns mnt]#
rm -f root.tgz

[root@ns mnt]#
cp /root/usr.tgz usr/
# copy it created in (3)-[3]

[root@ns mnt]#
cd usr

[root@ns usr]#
tar zxvf usr.tgz

[root@ns usr]#
rm -f usr.tgz

[root@ns usr]#
cd ../var

[root@ns var]#
cp /root/var.tgz ./
# copy it created in (3)-[3]

[root@ns var]#
tar zxvf var.tgz

[root@ns var]#
rm -f var.tgz

[root@ns var]#
cd ../

[root@ns mnt]#
vi etc/fstab


# specify file system in fstab

/dev/hda1
/
ext3
defaults
1 1

devpts
/dev/pts
devpts
gid=5,mode=620
0 0

tmpfs
/dev/shm
tmpfs
defaults
0 0

proc
/proc
proc
defaults
0 0

sysfs
/sys
sysfs
defaults
0 0

/dev/hda2
swap
swap
defaults
0 0


[root@ns mnt]#
vi etc/sysconfig/network


NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=
lan
.server-linux.info
# change hostname

GATEWAY=192.168.0.1

[root@ns mnt]#
vi etc/sysconfig/network-scripts/ifcfg-eth0


# Broadcom Corporation NetXtreme BCM5751 Gigabit Ethernet PCI Express
DEVICE=eth0
BOOTPROTO=static
BROADCAST=192.168.0.255
#HWADDR=00:13:72:0F:00:80
IPADDR=192.168.0.
31
# change IP address

IPV6ADDR=
IPV6PREFIX=
NETMASK=255.255.255.0
NETWORK=192.168.0.0
ONBOOT=yes

[root@ns mnt]#
vi etc/hosts


# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1
lan
.server-linux.info  
lan
  localhost.localdomain localhost

::1
localhost6.localdomain6 localhost6


[root@ns mnt]#
[root@ns ~]#
umount /mnt

[root@ns ~]#
cp /etc/xen/www /etc/xen/lan

[root@ns ~]#
vi /etc/xen/lan


# change like below

kernel
= "/boot/vmlinuz-2.6.18-8.1.1.el5xen"

ramdisk
= "/boot/initrd-2.6.18-8.1.1.el5xen.img"

memory
= "512"

name
= "
lan
"

vcpus
= "2"

nicks
= "1"

vif
= [ 'mac=00:16:3e:00:00:
20
,bridge=xenbr0' ]

disk
= [ '
file:/var/xen/lan.img,hda1,w
',

'
file:/var/xen/lan.swap,hda2,w
' ]
root
= "/dev/hda1 ro"

extra
= "3"


[root@ns ~]#
xm create -c lan


CentOS release 5 (Final)
Kernel 2.6.18-8.1.3.el5xen on an i686

lan.server-linux.info login:

[root@lan ~]#
chmod 1777 /tmp
# change permission
[2] Backup image-file of GuestOS.
[root@ns ~]#
# on Host

[root@ns ~]#
cp /var/xen/lan.img /root/root.img

[root@ns ~]#
cp /var/xen/lan.swap /root/swap.img

[root@ns ~]#
total 3957992
-rw------- 1  root  root
1333
May 11 18:39  anaconda-ks.cfg

-rw-r--r-- 1  root  root
18026
May 11 18:39  install.log

-rw-r--r-- 1  root  root
2889
May 11 18:39  install.log.syslog

-rw-r--r-- 1  root  root
21474836481
May 11 18:39  root.img

-rw-r--r-- 1  root  root
60396721
May 11 18:39  root.tgz

-rw-r--r-- 1  root  root
1073741825
May 11 18:39  swap.img

-rw-r--r-- 1  root  root
299138604
May 11 18:39  usr.tgz

-rw-r--r-- 1  root  root
88646338
May 11 18:39  var.tgz
[3] Add new GuestOS from backup file.
[root@ns ~]#
cp root.img /var/xen/rx7.img

[root@ns ~]#
cp swap.img /var/xen/rx7.swap

[root@ns ~]#
mount -o loop /var/xen/rx7.img /mnt

[root@ns ~]#
vi /mnt/etc/sysconfig/network


NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=
rx7
.server-linux.info
# change hostname

GATEWAY=192.168.0.1

[root@ns ~]#
vi /mnt/etc/sysconfig/network-scripts/ifcfg-eth0


# Broadcom Corporation NetXtreme BCM5751 Gigabit Ethernet PCI Express
DEVICE=eth0
BOOTPROTO=static
BROADCAST=192.168.0.255
#HWADDR=00:13:72:0F:00:80
IPADDR=192.168.0.
32
# change IP address

IPV6ADDR=
IPV6PREFIX=
NETMASK=255.255.255.0
NETWORK=192.168.0.0
ONBOOT=yes

[root@ns ~]#
umount /mnt

[root@ns ~]#
cp /etc/xen/lan /etc/xen/rx7

[root@ns ~]#
vi /etc/xen/rx7


# change like below

kernel
= "/boot/vmlinuz-2.6.18-8.1.1.el5xen"

ramdisk
= "/boot/initrd-2.6.18-8.1.1.el5xen.img"

memory
= "512"

name
= "
rx7
"

vcpus
= "2"

nicks
= "1"

vif
= [ 'mac=00:16:3e:00:00:
21
,bridge=xenbr0' ]

disk
= [ '
file:/var/xen/rx7.img,hda1,w
',

'
file:/var/xen/rx7.swap,hda2
' ]
root
= "/dev/hda1 ro"

extra
= "3"


[root@ns ~]#
xm create -c rx7


CentOS release 5 (Final)
Kernel 2.6.18-8.1.3.el5xen on an i686

rx7.server-linux.info login:

[root@rx7 ~]#
chmod 1777 /tmp
# change permission


[root@ns ~]#
# on Host

[root@ns ~]#
xm list

Name
ID
Mem(MiB)
VCPUs
State
Time(s)

Host
0
510
2
r-----
34.6

lan
3
511
2
-b----
10.8

rx7
4
511
2
-b----
13.9

mail
2
511
2
-b----
19.4

www
1
511
2
-b----
12.3

Matched Content
 
Tweet