Wednesday, September 23, 2009

Cloning and Copying VirtualBox virtual machines « Stuart’s Notes

Cloning and Copying VirtualBox virtual machines « Stuart’s Notes: "Cloning and Copying VirtualBox virtual machines

Change History
2008-11-03: Updates.
2008-11-01: First draft.

This article explains how to clone and copy VirtualBox VMs (virtual machines).

The techniques described in this article were tested on a Windows XP Pro SP2 host operating system using VirtualBox version 2.0.4. The details may vary if you use a Linux or some other host OS.
Introduction

Cloning and copying VirtualBox VMs is not as straight forward or obvious as it is with VMWare Desktop and this subject has created a lot of confusion in the support forums. This is because:

* There is no single VirtualBox command for VM cloning.
* The documentation is vague.
* A couple of the VirtualBox commands are poorly named.

The good news is that the underlying technology is just great and with a little understanding copying and cloning VMs is quite easy.

This article explains how to copy an existing VM containing an installed and configured guest OS. Before starting it helps to have a basic understanding of VirtualBox virtual machines.
Virtual Machines

A VirtualBox VM consists of three parts:

1. One or more virtual hard disk image files (VDI files).
2. Zero or more Snapshots (also VDI files).
3. XML configuration files defining the VM (virtual hardware parameters).

Snapshots

* A snapshot bookmarks the state of the VM (specifically the VM file system) at the point in time the snapshot is made.
* You return to a previous snapshot by deleting the current state and all newer snapshots.
* When you create a snapshot, changes to the file system accumulate in the current snapshot file, older snapshot files and disk image files are effectively read-only.
* If there are no snapshots the VM’s disk image file accumulates file system changes just like normal disks.

With respect to copying the important thing to understand about snapshots is that there is no easy way to copy them, so if your source VM has any snapshot information that you want to copy you first need to merge the snapshot(s) into the source VM’s disk images.
Copying a Virtual Machine

Here’s an outline of the copy process:

1. If the source VM has any snapshot information that you want to copy you first need to merge the snapshot(s) into the source VM’s disk image files.
2. Make a clone the source VM’s disk image file(s).
3. Create a new VM and attach the cloned disk image file(s).

Here are the details:
Merge source snapshots

Here’s how to merge the source snapshots to the source disk image VDI file (skip this step if you source VM doesn’t have any snapshots).

1. If the source VM is running close it.
2. From the VirtualBox window select the source VM then click the Snapshots tab.
3. If you want to include the current state of the disk in the merge save it as a snapshot by selecting the Current State then executing the Take Snapshot (Ctrl+Shift+S) command.
4. Select the most recent snapshot you want to include in the target VM and execute the Discard Snapshot (Ctrl+Shift+D) command. This merges the snapshot file into it’s parent VDI file (snapshot or base disk).
5. Repeat the previous step, working your way down the snapshot list until the oldest snapshot has been merged into the base VDI.

The VirtualBox snapshot commands are poorly named, in particular the inconsistent and confusing use of the word Discard:
Command Should be named Applied to Description
Discard Snapshot (Ctrl+Shift+D)

Merge with Parent

Snapshot

Merges the snapshot file into the parent snapshot or disk image file and then deletes the now redundant snapshot file.
Revert to Current Snapshot (Ctrl+Shift+R)


Current State

Deletes the current state returning the VM state to the most recent snapshot.
Discard Current Snapshot and State (Ctrl+Shift+B)

Delete Current Snapshot and State

Current State

Deletes the current state and the most recent snapshot returning the VM state to that of the penultimate snapshot. Use this command to delete snapshots.
Clone or copy the source disk image

At this point the entire state of the source VM that we want to copy is contained in the disk image VDI file.

To avoid confusion I use the term copying to refer to copying a VM to different host machine and the term cloning to refer to creating a copy on the same host.

Copying to another host machine
If you want to create a copy on another host machine you simply copy the disk image to the new host.

1. If the source VM is running close it.
2. Copy the source disk image to the VirtualBox VDI directory on the target host machine. You’ll normally find the source disk image in the VirtualBox VDI directory (the standard VDI location on Windows hosts is C:\Documents and Settings\<username>\.VirtualBox\VDI).

Once you’ve copied the disk image you need to register it with VirtualBox on the target host machine:

1. From the VirtualBox window select File→Virtual Disk Manager (Ctrl+D) menu command.
2. Press the Add button and select the copied disk image file.

Creating a clone on the same host machine
Use the VBoxManage command-line utility the clonevdi command option to clone and register the disk image (you can’t just copy the disk image to the same host machine because the disk UUID will conflict with the source disk image):

1. Open a Command Prompt window on the host machine.
2. Change to the VirtualBox VDI directory (normally C:\Documents and Settings\<username>\.VirtualBox\VDI).
3. Now run the VBoxManage command with the clonevdi command option. The following example transcript shows the creation of a copy of Ubuntu 8.04.vdi named Ubuntu 8.04 clone.vdi and registers the new disk:

C:\Documents and Settings\srackham\.VirtualBox\VDI> 'C:\Program
Files\Sun\xVM VirtualBox\VBoxManage.exe' clonevdi 'Ubuntu 8.04.vdi'
'Ubuntu 8.04 clone.vdi' VirtualBox Command Line Management Interface
Version 2.0.4 (C) 2005-2008 Sun Microsystems, Inc. All rights
reserved.

0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

C:\Documents and Settings\srackham\.VirtualBox\VDI>

Create a new virtual machine

There is no command to copy a VM so we create a new VM and attach our copied disk to it:

1. From the VirtualBox window select Machine→New… (Ctrl+N) menu command.
2. Work your way through the Create New Virtual Machine wizard till you get to the Virtual Hard Disk page then press the Existing… (not the New…) button and select the disk image VDI file that you previously cloned or copied.

That’s it, you should now be able to start and run your new VM.

Warning: Try not to be tempted to edit the VirtualBox XML configuration files manually — the files are interrelated and making changes manually is not as easy as it looks (I’m talking from experience here) — best to use the VirtualBox commands instead."

Friday, September 18, 2009

上帝也幽默 - 文学城: 热点论坛 web.wenxuecity.com

1 、中日韩三国足球队主教练一起来到天堂,询问上帝各自的足球队什么时候才能得世界杯冠军,上帝说:韩国需要50年。韩国教练大哭起来:我是见不到了。上帝又说:日本需要100 年。日本教练大哭起来:我是见不到了。中国教练连忙问:我们呢?上帝大哭起来:我是见不到了。



2 、信徒:“万能的上帝啊,一万年对您来说是多长呢?”上帝:“我眨一下眼的功夫。”信徒:“那么10亿元钱呢?”上帝:“不过是我的一根头发而已。”信徒:“哦,慈悲的上帝啊,那就请您给我一根头发吧。”上帝:“没问题,等我眨一下眼之后给你。”

3 、一个神父在打高尔夫球,一个修女在旁边观看,第一杆打偏了,神父骂道:“TMD ,打偏了!”又打,神父又骂:“TMD ,又打偏了!”修女说:“你做为神父说脏话上帝要惩罚的。”话音刚落,只听一个霹雷把修女给劈死了。神父纳闷了:为什么骂人的是我,为什么会劈死修女呢?这时只听天空传来上帝的声音:“TMD ,我也打偏了!”

4 、有一个男人,中年得子,甚是溺爱,含莘茹苦拉扯儿子成人,辛辛苦苦供儿子上完大学,儿子西装革履,红光满面,自己却衣衫褴褛,饥肠辘辘,省吃俭用为儿子买了房,娶了妻,自己也老了。然而儿子不孝,在一个风雨之夜将他赶出了家门。老人来到一个破庙避雨,老人很伤心,仰天长叹:上帝呀,为什么对我这么不公平?在一道闪电过后,一个更苍老的声音说:“这是报应啊。”这时老人看见一个比他更老的人从破庙的角落里进出来。老人大惊:“你是上帝吗?”更老的人说: “混蛋!在二十多年前你就把我赶出来了,我是你爸爸呀,你已经不认识我了?”

5 、在理发店,神父理完发交钱时,理发师说:“不收您的钱啦,我就当是为上帝服务了。”第二天早晨,理发师看见店门前多了一封感谢信和几本《圣经》。过了几天,一个警官理发后要交钱,理发师说:“不收您的钱啦,我就当是为我们社区服务了。”第二天早晨,理发师看见店门前又多了一封感谢信和一些《社区服务手册》。又过了几天,一go-vern-ment官员来理发,交钱时,理发师对他说:“不收您的钱啦,我就当是为go-vern-ment服务了。”第二天早晨,理发师看见门前站了一排go-vern-ment官员

6 、一天,克林顿的妻子希拉里被带去见上帝,她发现在上帝的客厅里挂着许多表,而且这些表有的走得快,有的走得慢。于是她就问上帝的仆人:“为何上帝要收集这麽多表?而且这些表走得还不一样快?”上帝的仆人说到:“这些表代表着人的生命,世界上每一个人都有一块着样的表,如果他的外遇多,他的表走得就快,没有外遇表走得就慢。”希拉里听完后向四周看了看又说道:“为何没看见我丈夫克林顿的表?”上帝的仆人说:“你丈夫的表被上帝拿到办公室当电风扇去了!

7 、一对儿同年同月同日生的老夫妇共同生活了35年。今天,他们大摆宴席,庆贺他们的60岁大寿。宴席过程中,上帝来了。上帝称赞老夫妇是真正的“恩爱夫妇”,并答应给他们每人一个愿望。老太太激动地说:“我们很贫穷,我只想想好好看看这个世界,做一次全球旅游。”上帝挥了一下手,砰的一声,一打儿飞机票从空中落入老太太的手上。该老头儿许愿了,只见他沉思了一会儿,说道:“我想娶一个比我年轻30岁的女人。”上帝又了一下手,砰!……老头儿一下子变成了 90岁

8 、上帝用泥巴捏了个人,从此就有了人类;最先有的是白人——因为上帝把泥人放到火上烤轻了;其次有了黑人——因为担心火候不到结果给烤大了;后来掌握了最佳火候也就有了我们黄色人种,所以说我们是上帝最成功的杰作。

9 、小彼得自豪地对他的朋友说:“我叔叔是神父,所有的人都称他尊敬的神父。”小保罗说:“我叔叔是主教,谁跟他说话都称他阁下。”小拉克乌斯不服气了:“这有什么了不起的。我叔叔体重150 公斤。”所有的人见了他都喊道:“噢!我的上帝!”

10、我对上帝说:让论坛里所有人永远健康快乐~!上帝说:只能四天~!我说:好,春天、夏天、秋天、冬天。上帝说:三天。我说:好,昨天、今天、明天。上帝说:不行,两天。我说:好,白天、黑天。上帝说:不行,就一天~!我说:好~!上帝茫然问到:哪一天?我说:在我帖里回帖的所有朋友生活着的每一天~!!上帝哭了……说:那以后在你帖子上转帖的所有朋友将天天健康快乐

如何发掘出更多退休的钱?

如何发掘出更多退休的钱? http://bbs.wenxuecity.com/bbs/tzlc/1328415.html 按照常规的说法,退休的收入必须得有退休前的80%,或者是4% withdrawal rule,而且每年还得要加2-3%对付通胀,这是一个很大...