2010年8月20日 星期五

如何clone virtualbox產生的vdi檔

原本以為只要用cp就可以解決這個問題
沒想到卻會遇到uuid重複的問題
查了一下才知道原來得用virtualbox提供的工具才能做到複製

VBoxManage (大小寫要對,我就是沒注意到,害我搞了好久)
$cd  ~/.VirtualBox/HardDisks
$VBoxManage clonehd source.vdi target.vdi
指定source和target之後接下來等clone完之後就好了!
叫出virtualbox按下ctrl d叫出虛擬媒體管理員
再將複製完的vdi加入媒體中就可以了
以下是VBoxManage的相關說明


Oracle VM VirtualBox Command Line Management Interface Version 3.2.8
(C) 2005-2010 Oracle Corporation
All rights reserved.

Usage:

VBoxManage [-v|--version]    print version number and exit
VBoxManage [-q|--nologo] ... suppress the logo

VBoxManage list [--long|-l] vms|runningvms|ostypes|hostdvds|hostfloppies|
                            bridgedifs|hostonlyifs|dhcpservers|hostinfo|
                            hostcpuids|hddbackends|hdds|dvds|floppies|
                            usbhost|usbfilters|systemproperties

VBoxManage showvminfo       | [--details] [--statistics]
                            [--machinereadable]
VBoxManage showvminfo       | --log

VBoxManage registervm      

VBoxManage unregistervm     | [--delete]

VBoxManage createvm         --name
                            [--ostype ]
                            [--register]
                            [--basefolder | --settingsfile ]
                            [--uuid ]

VBoxManage modifyvm        
                            [--name ]
                            [--ostype ]
                            [--memory ]
                            [--pagefusion on|off]
                            [--vram ]
                            [--acpi on|off]
                            [--ioapic on|off]
                            [--pae on|off]
                            [--hpet on|off]
                            [--hwvirtex on|off]
                            [--nestedpaging on|off]
                            [--largepages on|off]
                            [--vtxvpid on|off]
                            [--synthcpu on|off]
                            [--cpuidset ]
                            [--cpuidremove ]
                            [--cpuidremoveall]
                            [--hardwareuuid ]
                            [--cpus ]
                            [--cpuhotplug on|off]
                            [--plugcpu ]
                            [--unplugcpu ]
                            [--rtcuseutc on|off]
                            [--monitorcount ]
                            [--accelerate3d on|off]
                            [--accelerate2dvideo on|off]
                            [--firmware bios|efi|efi32|efi64]
                            [--bioslogofadein on|off]
                            [--bioslogofadeout on|off]
                            [--bioslogodisplaytime ]
                            [--bioslogoimagepath ]
                            [--biosbootmenu disabled|menuonly|messageandmenu]
                            [--biossystemtimeoffset ]
                            [--biospxedebug on|off]
                            [--boot<1-4> none|floppy|dvd|disk|net>]
                            [--nic<1-N> none|null|nat|bridged|intnet|hostonly|
                                        vde]
                            [--nictype<1-N> Am79C970A|Am79C973|
                                            82540EM|82543GC|82545EM|
                                            virtio]
                            [--cableconnected<1-N> on|off]
                            [--nictrace<1-N> on|off]
                            [--nictracefile<1-N> ]
                            [--nicspeed<1-N> ]
                            [--nicbootprio<1-N> ]
                            [--bridgeadapter<1-N> none|]
                            [--hostonlyadapter<1-N> none|]
                            [--intnet<1-N> ]
                            [--natnet<1-N> |default]
                            [--vdenet<1-N> |default]
                            [--natsettings<1-N> [],[],
                                                [],[],
                                                []]
                            [--natpf<1-N> [],tcp|udp,[],
                                          ,[],]
                            [--natpf<1-N> delete ]
                            [--nattftpprefix<1-N> ]
                            [--nattftpfile<1-N> ]
                            [--nattftpserver<1-N> ]
                            [--natdnspassdomain<1-N> on|off]
                            [--natdnsproxy<1-N> on|off]
                            [--natdnshostresolver<1-N> on|off]
                            [--nataliasmode<1-N> default|[log],[proxyonly],
                                                         [sameports]]
                            [--macaddress<1-N> auto|]
                            [--mouse ps2|usb|usbtablet
                            [--keyboard ps2|usb
                            [--uart<1-N> off| ]
                            [--uartmode<1-N> disconnected|
                                             server |
                                             client |
                                             file |
                                             ]
                            [--guestmemoryballoon ]
                            [--gueststatisticsinterval ]
                            [--audio none|null|oss|alsa|pulse]
                            [--audiocontroller ac97|sb16]
                            [--clipboard disabled|hosttoguest|guesttohost|
                                         bidirectional]
                            [--vrdp on|off]
                            [--vrdpport default|]
                            [--vrdpaddress ]
                            [--vrdpauthtype null|external|guest]
                            [--vrdpmulticon on|off]
                            [--vrdpreusecon on|off]
                            [--vrdpvideochannel on|off]
                            [--vrdpvideochannelquality ]
                            [--usb on|off]
                            [--usbehci on|off]
                            [--snapshotfolder default|]
                            [--teleporter on|off]
                            [--teleporterport ]
                            [--teleporteraddress                             [--teleporterpassword ]

VBoxManage import           [--dry-run|-n] [more options]
                            (run with -n to have options displayed
                             for a particular OVF)

VBoxManage export           --output|-o
                            [--legacy09]
                            [--vsys ]
                                    [--product ]
                                    [--producturl ]
                                    [--vendor ]
                                    [--vendorurl ]
                                    [--version ]
                                    [--eula ]
                                    [--eulafile ]

VBoxManage startvm          |
                            [--type gui|sdl|vrdp|headless]

VBoxManage controlvm        |
                            pause|resume|reset|poweroff|savestate|
                            acpipowerbutton|acpisleepbutton|
                            keyboardputscancode [ ...]|
                            injectnmi|
                            setlinkstate<1-N> on|off |
                            nic<1-N> null|nat|bridged|intnet|hostonly
                                     [] |
                            nictrace<1-N> on|off
                            nictracefile<1-N>
                            guestmemoryballoon ]
                            gueststatisticsinterval ]
                            usbattach |

|
                            usbdetach |
|
                            vrdp on|off |
                            vrdpport default| |
                            vrdpvideochannelquality
                            setvideomodehint [display] |
                            setcredentials
                                           [--allowlocallogon ] |
                            teleport --host --port
                                   [--maxdowntime ] [--password password]
                            plugcpu
                            unplugcpu

VBoxManage discardstate     |

VBoxManage adoptstate       |

VBoxManage snapshot         |
                            take [--description ] [--pause] |
                            delete | |
                            restore | |
                            restorecurrent |
                            edit ||--current
                                 [--name ]
                                 [--description ] |
                            showvminfo |

VBoxManage openmedium       disk|dvd|floppy
                            [--type normal|immutable|writethrough|
                                    shareable] (disk only)
                            [--uuid ]
                            [--parentuuid ] (disk only)

VBoxManage closemedium      disk|dvd|floppy |
                            [--delete]

VBoxManage storageattach   
                            --storagectl
                            --port
                            --device
                            [--type dvddrive|hdd|fdd]
                            [--medium none|emptydrive|
                                      ||host:]
                            [--passthrough on|off]
                            [--forceunmount]

VBoxManage storagectl      
                            --name
                            [--add ide|sata|scsi|floppy|sas]
                            [--controller LSILogic|LSILogicSAS|BusLogic|
                                          IntelAHCI|PIIX3|PIIX4|ICH6|I82078]
                            [--sataideemulation<1-4> <1-30>]
                            [--sataportcount <1-30>]
                            [--hostiocache on|off]
                            [--remove]

VBoxManage showhdinfo       |

VBoxManage createhd         --filename
                            --size
                            [--format VDI|VMDK|VHD] (default: VDI)
                            [--variant Standard,Fixed,Split2G,Stream,ESX]
                            [--type normal|writethrough|
                                    shareable] (default: normal)
                            [--comment ]
                            [--remember]

VBoxManage modifyhd         |
                            [--type normal|writethrough|immutable|shareable]
                            [--autoreset on|off]
                            [--compact]

VBoxManage clonehd          |
                            [--format VDI|VMDK|VHD|RAW|]
                            [--variant Standard,Fixed,Split2G,Stream,ESX]
                            [--type normal|writethrough|immutable|shareable]
                            [--remember] [--existing]

VBoxManage convertfromraw  
                            [--format VDI|VMDK|VHD]
                            [--variant Standard,Fixed,Split2G,Stream,ESX]
VBoxManage convertfromraw   stdin
                            [--format VDI|VMDK|VHD]
                            [--variant Standard,Fixed,Split2G,Stream,ESX]

VBoxManage addiscsidisk     --server |
                            --target
                            [--port ]
                            [--lun ]
                            [--encodedlun ]
                            [--username ]
                            [--password ]
                            [--type normal|writethrough|immutable|shareable]
                            [--intnet]

VBoxManage getextradata     global||
                            |enumerate

VBoxManage setextradata     global||
                           
                            [] (no value deletes key)

VBoxManage setproperty      hdfolder default| |
                            machinefolder default| |
                            vrdpauthlibrary default| |
                            websrvauthlibrary default|null| |
                            loghistorycount

VBoxManage usbfilter        add
                            --target ||global
                            --name
                            --action ignore|hold (global filters only)
                            [--active yes|no] (yes)
                            [--vendorid ] (null)
                            [--productid ] (null)
                            [--revision ] (null)
                            [--manufacturer ] (null)
                            [--product ] (null)
                            [--remote yes|no] (null, VM filters only)
                            [--serialnumber ] (null)
                            [--maskedinterfaces ]

VBoxManage usbfilter        modify
                            --target ||global
                            [--name ]
                            [--action ignore|hold] (global filters only)
                            [--active yes|no]
                            [--vendorid |""]
                            [--productid |""]
                            [--revision |""]
                            [--manufacturer |""]
                            [--product |""]
                            [--remote yes|no] (null, VM filters only)
                            [--serialnumber |""]
                            [--maskedinterfaces ]

VBoxManage usbfilter        remove
                            --target ||global

VBoxManage sharedfolder     add |
                            --name --hostpath
                            [--transient] [--readonly]

VBoxManage sharedfolder     remove |
                            --name [--transient]

VBoxManage vmstatistics     | [--reset]
                            [--pattern ] [--descriptions]

VBoxManage guestproperty    get |
                            [--verbose]

VBoxManage guestproperty    set |
                            [ [--flags ]]

VBoxManage guestproperty    enumerate |
                            [--patterns ]

VBoxManage guestproperty    wait |
                            [--timeout ] [--fail-on-timeout]

VBoxManage guestcontrol     execute |
                           
                            --username --password
                            [--arguments ""]
                            [--environment "= [=]"]
                            [--flags ] [--timeout ]
                            [--verbose] [--wait-for exit,stdout,stderr||]

VBoxManage metrics          list [*|host| []]
                                                 (comma-separated)

VBoxManage metrics          setup
                            [--period ] (default: 1)
                            [--samples ] (default: 1)
                            [--list]
                            [*|host| []]

VBoxManage metrics          query [*|host| []]

VBoxManage metrics          enable
                            [--list]
                            [*|host| []]

VBoxManage metrics          disable
                            [--list]
                            [*|host| []]

VBoxManage metrics          collect
                            [--period ] (default: 1)
                            [--samples ] (default: 1)
                            [--list]
                            [--detach]
                            [*|host| []]

VBoxManage hostonlyif       ipconfig
                            [--dhcp |
                            --ip [--netmask (def: 255.255.255.0)] |
                            --ipv6 [--netmasklengthv6 (def: 64)]]

VBoxManage dhcpserver       add|modify --netname |
                                       --ifname
                                [--ip
                                 --netmask
                                 --lowerip
                                 --upperip ]
                                [--enable | --disable]

VBoxManage dhcpserver       remove --netname |
                                   --ifname