设为首页 收藏本站
查看: 1418|回复: 0

[经验分享] xen创建pvm和hvm的过程

[复制链接]

尚未签到

发表于 2015-4-13 12:14:29 | 显示全部楼层 |阅读模式
  these are the basic steps of installing domU with xen-tools in ubuntu13.04 64bit in xen4.3
  you can also use virt-manager which has an UI, but there may be some bugs between xen and virt-manager.
  
  install a bridge:
  before xen4.1, xen will automatically create xenbr0. in xen4.3, things are different, we need to create xenbr0 by hands.
  the steps are for the situation where your computer is using dhcp. for static ip setting, the bridge may be not crrect.
  first, install a tool named brctl:
  sudo apt-get install bridge-utils
  sudo brctl (this will show the help info. then you can see how to use commands like 'addbr' or 'addif')
  sudo brctl show (this is to see your current status)
  then change file "etc/network/interfaces" to this:

auto lo
iface lo inet loopback
auto xenbr0
iface xenbr0 inet dhcp
bridge_ports eth0
auto eth0
iface eth0 inet manual

  then turn xenbr0 up:
  sudo ifup xenbr0
  then in ifconfig you should see the status of xenbr0 is "up"
  sudo ifconfig xenbr0
  ok, reboot to get things work
  
  Install PV domu:
  sudo apt-get install xen-tools
  sudo xen-create-image --hostname=yourhostname --dist=lucid --dir=/home/zmj/xenfile(change it to your own) --mirror=http://cn.archive.ubuntu.com/ubuntu --role=udev --verbose --pygrub --dhcp --passwd
  ps:the hostname is the vm’s name
  this xen-create-image command will automatically create a *.cfg fill in /etc/xen/ and create "domains/yourhostname/disk.img and swap.img" under your dir (in this example "/home/zmj/xenfile")
  if these files, i.e. "domains/yourhostname/disk.img and swap.img" already exist in your dir, then the command will fail. you have three choices: 1.use --force in the command to rewrite the files 2. delete the files by hands 3. change your hostname to something else
  the "yourhostname" are suggested to be short, better within 10 chars. there is a case that we cannot get things done until we give a short name to the --hostname.
  this command will take a relative long time because it needs to download something via http.
  with the *.cfg file you can create VM with 'xm create'. of course you can write *.cfg by yourself as long as the settings in your *.cfg file are correct, which would be much more difficult.
  by the way, in /etc/xen there are some example.cfg which you can refer to.
  you can find your img file at the --dir you specified at the command, i.e. /home/zmj/xenfile. you can mount this img to see what is inside:)
  the --passwd option is important. with this, it will ask you for the pasword of your domu at the end of this command's running. otherwise, you'll not be able to login unless you mount the whole domu img and edit /etc/shadow file. or you can set passwd=1 in /etc/xen-tools/xen-tools.conf, which makes the command always asking a password.
  you can use --lvm instead of --dir. more info,  plz refer to http://manpages.ubuntu.com/manpages/precise/man8/xen-create-image.8.html
  sudo xl create /etc/xen/yourhostname.cfg (plz teach yourself if dont know how to use xl)
  it will throw an error if bridge xenbr0 is missing. or you can modify the .cfg file.
  do this command you may see this

Iyk@ubuntu:Æ sud0 xl create /etc/xen/ubuntu.cfg  
xend is runnlng, wh1ch may cause unpredlctable results when us1ng th1s xl command.  
Please shut down xend before cont1nu1ng.

  At this time,you can do this command:
sudo service xend stop
ps:这里因为现在的命令xl不需要使用xend了,以前的xm是需要用到xend的。
  sudo xl list
  You shall see your domU after this command.
  sudo xl console yourhostname
  Use this command to go inside the domU with username=root and password=yourpasswd
  Press “Ctrl+]” will get you out of the vm console.
  
  Install HVM domU:(if your xen kernel is a vmware virtual machine, you can not create a HVM)
  The installation of HVM is much easier than that of a PV.
  Put a *.iso file at some directory which is the OS you are going to build, for example win7.iso
  Use this command to create an empty *.img file, which will act like the hard disk of your VM.
  dd if=/dev/zero of=XXX.img bs=1024k count=(count of bs)
  Write a *.cfg file like this:

kernel = "/usr/local/lib/xen/boot/hvmloader"
builder='hvm'
memory = 2048
vcpus=4
shadow_memory = 64
name = "u8s"
vif = [ 'mac=00:16:3E:63:34:21, bridge=xenbr0' ]
disk = [ 'file:/home/zmj/img/ubuntu8s.img,hda,w', 'file:/home/zmj/iso/ubuntu8s.iso,hdc:cdrom,r' ]
boot="bc"
vnc = 1
sdl = 0
vncconsole=1
xen_platform_pci=0
acpi = 1
apic = 1
device_model = '/usr/local/lib/xen/bin/qemu-dm'
stdvga=0
serial='pty'
usbdevice='tablet'

  The *.img path and the *.iso path shall be correct. The kelnel path and the device_model path shall be correct.
  Use this command to start the installation
  sudo xl create *.cfg
  After the installation, change “bc” to “c” in the *.cfg file. “bc” means boot from cd, while “c” means boot from hard disk.
  Run this command again and you’ll find the VM running
  sudo xl create *.cfg
  Use this command to see the vm list
  sudo xl list
  Use this command to open the VM.
  sudo xl vncviewer domu

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-56651-1-1.html 上篇帖子: squeeze+xen 下篇帖子: xen hypercall 的应用层实现
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表