在RHEL上安装Xen DomU

  • Most of our machines have used the Centos4 image from Jailtime.org.
  • Editing a File system image using loopback device:
    [root@arch1 xen]# mount -o loop /opt/xen/centos.4-3.img /mnt/xenfs
    [root@arch1 xen]# 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.
      [root@arch1 lib]# cd /mnt/xenfs
      [root@arch1 xenfs]# chroot .
      bash-3.00# ls
      bin boot dev etc halt home initrd lib lost+found media mnt opt proc root sbin selinux srv sys tmp usr var
      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
    [root@arch1 xen]# 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
    [root@arch1 xen]# xm create centos3.4-3.xen.cfg
    Using config file "./centos3.4-3.xen.cfg".
    Started domain centos3.4-3
    [root@arch1 xen]# 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
    [root@arch1 xen]#
  • 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
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值