Add a New Disk to a Xen VM

小钟从进实验室开始一直在做云平台的部署配置工作,在配置虚拟机的过程中遇到一些问题,今天要说的是如何为用Xen创建好的虚拟机挂载新的存储卷。

  • Create a sparse file. Seek  indicates the “size” of the disk in MB. 10000=9.8GB
  • Create the filesystem.

#dd if=/dev/zero of=add.img bs=1M seek=10000 count=1

  • Edit the DomU’s config file /etc/xen/<hostname> & add the new disk:

disk=[....,

"file:/var/xen/imges/add.img,hdb1,w"]

  • Start the VM, edit /etc/fstab and mount the disk:

/dev/hdb1 /opt                  ext3                 defaults     0  0

在这儿做一下简单解释,第一步和第二步是为虚拟机创建一块镜像文件,也即额外的存储卷,所以大小可以按照需要来设置;第三步、将新加卷信息添加到虚拟机的配置文件,好比在物理机上将一块新硬盘装在主板上;第四步、让虚拟机OS启动后挂载磁盘。这样进入虚拟机后就可以使用了。(原文:小钟的博客)

猜你喜欢

转载自thewaychung.iteye.com/blog/1594386
XEN