samsungsamsung 发表于 2015-10-11 14:44:02

在RHEL上安装Xen DomU


[*]Most of our machines have used the Centos4 image from Jailtime.org.
[*]Editing a File system image using loopback device:
# mount -o loop /opt/xen/centos.4-3.img /mnt/xenfs
# mount
/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw)
none on /proc type proc (rw)
none on /sys type sysfs (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/cciss/c0d0p1 on /boot type ext3 (rw)
none on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/opt/xen/centos.4-3.img on /mnt/xenfs type ext3 (rw,loop=/dev/loop4)
                        
  

[*]I recommend to chroot before editing, to make sure you don't accidently edit the host server configs.
# cd /mnt/xenfs
# chroot .
bash-3.00# ls
binbootdevetchalthomeinitrdliblost+foundmediamntoptprocrootsbinselinuxsrvsystmpusrvar
bash-3.00#
                              
  



[*]At minimum you want to edit the /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=arch2
GATEWAY=10.100.105.1
                        
  

[*]- and /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
IPADDR=10.100.105.41
NETMASK=255.255.255.0
NETWORK=10.100.105.0
BROADCAST=10.100.105.255

[*]– and edit/create /etc/resolv.conf
domain j2noc.com
nameserver 10.2.2.111
nameserver 10.254.254.249




  


[*]Xen config files

[*]Put them in /etc/xen
[*]Sample file, hopefully this is self explanatory. See Xen site for details.
kernel = "/boot/vmlinuz-2.6.16.33-xen"
memory = 128
name = "centos2.4-3"
vif = [ '' ]
ip = "10.100.105.42"
disk = ['file:/opt/xen/centos/centos2.4-3.img,sda1,w', 'file:/opt/xen/centos/centos2.swap,sda2,w']
root = "/dev/sda1 ro"
                              
  




Copying module files to the guest
  If the host OS has devices installed that are not part of the guest, you can surface support for those by copying the /lib/modules for the xen kernel into the guest fs.


[*]Assumes that you created map files using depmod previously.
[*]mount -o loop the guest filesystem.
[*]cp -a /lib/modules/2.6.16.33-xen /mnt/xenfs/lib/modules

Starting the Guest


[*]Use xm create
# xm list
Name                                    ID   Mem VCPUs      State   Time(s)
Domain-0                                 0    65   2   r-----   7475.6
centos.4-3                                 1   128   1   -b----   4230.5
centos2.4-3                              2   128   1   -b----    314.8
centos5.4-3                              9   512   1   -b----   5418.3
# xm create centos3.4-3.xen.cfg
Using config file "./centos3.4-3.xen.cfg".
Started domain centos3.4-3
# xm list
Name                                    ID   Mem VCPUs      State   Time(s)
Domain-0                                 0    65   2   r-----   7478.1
centos.4-3                                 1   128   1   -b----   4230.5
centos2.4-3                              2   128   1   -b----    314.8
centos3.4-3                               13   256   1   -b----      1.0
centos5.4-3                              9   512   1   -b----   5418.4
#


[*]Console into the running guest
xm console centos2.4-3

[*]If you're fast you may catch boot. If you're slow and get a blank screen, hit Return.

[*]Exiting back to the Host is a bit like screen
[*]Use Ctrl-]




[*] If you want to be guaranteed to watch the boot process, you can start the guest in console mode
xm console centos2.4-3 -c

Expanding the size of a filesystem


[*]Bring down the guest instance if it's up!!!

[*]Given you want to expand a virtual disk called filesystem.image by 1024MB (1G), do the following:


[*]dd if=/dev/zero bs=1M count=1024 >> filesystem.image
[*]e2fsck -f filesystem.image
[*]resize2fs filesystem.image
[*]e2fsck -f filesystem.image

版权声明:本文为博主原创文章,未经博主允许不得转载。
页: [1]
查看完整版本: 在RHEL上安装Xen DomU