Clone ZFS-based Solaris xVM domain

 

Introduction

If you're using a ZFS volume as the root disk for a domain, you can make use of the snapshotting facilities to quickly "clone" another domain with the same configuration. By taking a clone of the root disk, you can very quickly provision similar domains, and even better, the nature of the clone means the only extra storage used is that of the differences between the domains.We're working on ways of automating this procedure, but for now these are the steps you'll need to take.

Step-by-step

First, we need to shutdown the domain we're cloning so we can take a consistent snapshot of the disk:

xm shutdown -w domain1

Alternatively, you might want to do a sys-unconfig in the domain so the new clone will come up with the configuration screens.

Now we take a snapshot of the root disk used by 'domain1', and then a clone (writable snapshot) :

zfs snapshot pool/domain1-root@clone
zfs clone pool/domain1-root@clone pool/domain2-root

If you now do a zfs list, you should see the snapshot and clone present, and using next to no additional disk space. For our last step, we need to duplicate domain1's configuration. First dump the configuration to a file:

virsh dumpxml domain1 >domain1.xml
cp domain1.xml domain2.xml

You will need to make at least three changes. First, you will want a new name for your domain, so edit this line:

<name>domain1</name>

with the new name:

<name>domain2</name>

Second, you must remove the UUID line so virsh will generate a new domain configuration. Remove the line that looks like this:

<uuid>72bb96b6e6cf13594fb0cd1290610611</uuid>

Finally we have to point to the new disk by editing the following line:

<source dev='/dev/zvol/dsk/export/domain1-root'/>

to be:

<source dev='/dev/zvol/dsk/export/domain2-root'/>

Finally, tell virsh about the new domain:

virsh define domain2.xml

Now you can boot your cloned domain!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值