最近在研究 Xen VM, 真是一個坑. 紀錄一下如果我要給不同VM不同的disk storage capacity 時我該怎麼做?
Step1 - Create an image
下面的例子是建立一個10G大小的img檔
$ sudo dd if=/dev/zero of=/path/to/your/vm/new.img bs=1M count=10240
Step2 - Modify configuration
把這個新的img檔的路徑, 寫入cfg中的Disk device(s).
domain.cfg
#
# Disk device(s).
#
root = '/dev/xvda2 ro'
disk = [
'file:/path/to/your/vm/disk.img,xvda2,w',
'file:/path/to/your/vm/swap.img,xvda1,w',
'file:/path/to/your/vm/new.img,xvda3,w',
]
Step3 - Start the Xen VM and login
$ xl create domain.cfg
$ ssh root@your.domain.ip
Step4 - Format the new disk and Mount it
$ fdisk -l
$ sudo mkfs.ext3 /dev/xvda3
$ mount /dev/xvda3 /path/to/directory