Win10无法启动VirtualBox

在Win10上遇到了一个问题:

Failed to open a session for the virtual machine ubuntu.

Raw-mode is unavailable courtesy of Hyper-V. (VERR_SUPDRV_NO_RAW_MODE_HYPER_V_ROOT).

Result Code: E_FAIL (0x80004005)
Component: ConsoleWrap
Interface: IConsole {872da645-4a9b-1727-bee2-5585105b9eed}

最后发现是前几天安装了Win10的Hyper-V模块,卸载后就好了。

VirtualBox的几种联网方式

VirtualBox有四种联网方式:

NAT:
虚拟机通过网络地址转换协议来访问宿主机网络,虚拟机可以访问宿主机可以访问的所有网络
宿主机和虚拟机之间无法通讯
而在宿主机局域网其他主机看来,虚拟机是不存在的
虚拟机之间不可以相互访问

Bridged:
虚拟机通过桥接,把自己虚拟为宿主机同一局域网的一台设备,虚拟机可以访问宿主机可以访问的所有网络
对于宿主机来说,虚拟机就是同一局域网的一台设备
而在宿主机局域网其他主机看来,虚拟机就是同一局域网的一台设备
虚拟机之间可以相互访问

HostOnly:
虚拟机宿主机可以相互访问,默认虚拟机不可以访问宿主机所在网络(宿主机可以共享网络给虚拟机,但一般不会这么用)。
虚拟机之间可以相互访问

Internal:
只有虚拟机之间可以相互访问。

具体情况如下(假设网段设置都正确):

通讯 Internal HostOnly NAT Bridge
虚拟机到宿主机 NO YES YES YES
宿主机到虚拟机 NO YES NO YES,部分网络服务受限
虚拟机到其他主机 NO NO YES YES,部分网络服务受限
其他主机到虚拟机 NO NO NO YES
虚拟机到虚拟机 YES YES NO YES

VBoxManage常用命令

1、常用命令

#列出全部虚拟机
VBoxManage list vms
#列出全部运行中的虚拟机
VBoxManage list runningvms
#列出虚拟机信息
VBoxManage showvminfo uuid|vmname
#开启虚拟机
VBoxManage startvm uuid|vmname
#开启虚拟机,无GUI模式
VBoxManage startvm uuid|vmname --type headless
#暂停虚拟机
VBoxManage controlvm uuid|vmname pause
#继续运行虚拟机
VBoxManage controlvm uuid|vmname resume
#按下机箱重启按钮
VBoxManage controlvm uuid|vmname reset
#断电
VBoxManage controlvm uuid|vmname poweroff
#按下机箱电影按钮
VBoxManage controlvm uuid|vmname acpipowerbutton
#按下机箱睡眠按钮
VBoxManage controlvm uuid|vmname acpisleepbutton

2、全部参数

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

Usage:

  VBoxManage [<general option>] <command>
 
 
General Options:
 
  [-v|--version]            print version number and exit
  [-q|--nologo]             suppress the logo
  [--settingspw <pw>]       provide the settings password
  [--settingspwfile <file>] provide a file containing the settings password
 
 
Commands:
 
  list [--long|-l]          vms|runningvms|ostypes|hostdvds|hostfloppies|
                            intnets|bridgedifs|hostonlyifs|natnets|dhcpservers|
                            hostinfo|hostcpuids|hddbackends|hdds|dvds|floppies|
                            usbhost|usbfilters|systemproperties|extpacks|
                            groups|webcams

  showvminfo                <uuid|vmname> [--details]
                            [--machinereadable]
  showvminfo                <uuid|vmname> --log <idx>

  registervm                <filename>

  unregistervm              <uuid|vmname> [--delete]

  createvm                  --name <name>
                            [--groups <group>, ...]
                            [--ostype <ostype>]
                            [--register]
                            [--basefolder <path>]
                            [--uuid <uuid>]

  modifyvm                  <uuid|vmname>
                            [--name <name>]
                            [--groups <group>, ...]
                            [--ostype <ostype>]
                            [--iconfile <filename>]
                            [--memory <memorysize in MB>]
                            [--pagefusion on|off]
                            [--vram <vramsize in MB>]
                            [--acpi on|off]
                            [--pciattach 03:04.0]
                            [--pciattach 03:04.0@02:01.0]
                            [--pcidetach 03:04.0]
                            [--ioapic on|off]
                            [--hpet on|off]
                            [--triplefaultreset on|off]
                            [--hwvirtex on|off]
                            [--nestedpaging on|off]
                            [--largepages on|off]
                            [--vtxvpid on|off]
                            [--vtxux on|off]
                            [--pae on|off]
                            [--longmode on|off]
                            [--synthcpu on|off]
                            [--cpuidset <leaf> <eax> <ebx> <ecx> <edx>]
                            [--cpuidremove <leaf>]
                            [--cpuidremoveall]
                            [--hardwareuuid <uuid>]
                            [--cpus <number>]
                            [--cpuhotplug on|off]
                            [--plugcpu <id>]
                            [--unplugcpu <id>]
                            [--cpuexecutioncap <1-100>]
                            [--rtcuseutc on|off]
                            [--graphicscontroller none|vboxvga|vmsvga]
                            [--monitorcount <number>]
                            [--accelerate3d on|off]
                            [--accelerate2dvideo on|off]
                            [--firmware bios|efi|efi32|efi64]
                            [--chipset ich9|piix3]
                            [--bioslogofadein on|off]
                            [--bioslogofadeout on|off]
                            [--bioslogodisplaytime <msec>]
                            [--bioslogoimagepath <imagepath>]
                            [--biosbootmenu disabled|menuonly|messageandmenu]
                            [--biossystemtimeoffset <msec>]
                            [--biospxedebug on|off]
                            [--boot<1-4> none|floppy|dvd|disk|net>]
                            [--nic<1-N> none|null|nat|bridged|intnet|hostonly|
                                        generic|natnetwork]
                            [--nictype<1-N> Am79C970A|Am79C973|
                                            82540EM|82543GC|82545EM|
                                            virtio]
                            [--cableconnected<1-N> on|off]
                            [--nictrace<1-N> on|off]
                            [--nictracefile<1-N> <filename>]
                            [--nicproperty<1-N> name=[value]]
                            [--nicspeed<1-N> <kbps>]
                            [--nicbootprio<1-N> <priority>]
                            [--nicpromisc<1-N> deny|allow-vms|allow-all]
                            [--nicbandwidthgroup<1-N> none|<name>]
                            [--bridgeadapter<1-N> none|<devicename>]
                            [--hostonlyadapter<1-N> none|<devicename>]
                            [--intnet<1-N> <network name>]
                            [--nat-network<1-N> <network name>]
                            [--nicgenericdrv<1-N> <driver>
                            [--natnet<1-N> <network>|default]
                            [--natsettings<1-N> [<mtu>],[<socksnd>],
                                                [<sockrcv>],[<tcpsnd>],
                                                [<tcprcv>]]
                            [--natpf<1-N> [<rulename>],tcp|udp,[<hostip>],
                                          <hostport>,[<guestip>],<guestport>]
                            [--natpf<1-N> delete <rulename>]
                            [--nattftpprefix<1-N> <prefix>]
                            [--nattftpfile<1-N> <file>]
                            [--nattftpserver<1-N> <ip>]
                            [--natbindip<1-N> <ip>
                            [--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|<mac>]
                            [--mouse ps2|usb|usbtablet|usbmultitouch]
                            [--keyboard ps2|usb
                            [--uart<1-N> off|<I/O base> <IRQ>]
                            [--uartmode<1-N> disconnected|
                                             server <pipe>|
                                             client <pipe>|
                                             file <file>|
                                             <devicename>]
                            [--lpt<1-N> off|<I/O base> <IRQ>]
                            [--lptmode<1-N> <devicename>]
                            [--guestmemoryballoon <balloonsize in MB>]
                            [--audio none|null|dsound]
                            [--audiocontroller ac97|hda|sb16]
                            [--clipboard disabled|hosttoguest|guesttohost|
                                         bidirectional]
                            [--draganddrop disabled|hosttoguest
                            [--vrde on|off]
                            [--vrdeextpack default|<name>
                            [--vrdeproperty <name=[value]>]
                            [--vrdeport <hostport>]
                            [--vrdeaddress <hostip>]
                            [--vrdeauthtype null|external|guest]
                            [--vrdeauthlibrary default|<name>
                            [--vrdemulticon on|off]
                            [--vrdereusecon on|off]
                            [--vrdevideochannel on|off]
                            [--vrdevideochannelquality <percent>]
                            [--usb on|off]
                            [--usbehci on|off]
                            [--snapshotfolder default|<path>]
                            [--teleporter on|off]
                            [--teleporterport <port>]
                            [--teleporteraddress <address|empty>
                            [--teleporterpassword <password>]
                            [--teleporterpasswordfile <file>|stdin]
                            [--tracing-enabled on|off]
                            [--tracing-config <config-string>]
                            [--tracing-allow-vm-access on|off]
                            [--usbcardreader on|off]
                            [--autostart-enabled on|off]
                            [--autostart-delay <seconds>]
                            [--vcpenabled on|off]
                            [--vcpscreens [<display>],...
                            [--vcpfile <filename>]
                            [--vcpwidth <width>]
                            [--vcpheight <height>]
                            [--vcprate <rate>]
                            [--vcpfps <fps>]
                            [--defaultfrontend default|<name>]

  clonevm                   <uuid|vmname>
                            [--snapshot <uuid>|<name>]
                            [--mode machine|machineandchildren|all]
                            [--options link|keepallmacs|keepnatmacs|
                                       keepdisknames]
                            [--name <name>]
                            [--groups <group>, ...]
                            [--basefolder <basefolder>]
                            [--uuid <uuid>]
                            [--register]

  import                    <ovfname/ovaname>
                            [--dry-run|-n]
                            [--options keepallmacs|keepnatmacs]
                            [more options]
                            (run with -n to have options displayed
                             for a particular OVF)

  export                    <machines> --output|-o <name>.<ovf/ova>
                            [--legacy09|--ovf09|--ovf10|--ovf20]
                            [--manifest]
                            [--iso]
                            [--options manifest|iso|nomacs|nomacsbutnat]
                            [--vsys <number of virtual system>]
                                    [--product <product name>]
                                    [--producturl <product url>]
                                    [--vendor <vendor name>]
                                    [--vendorurl <vendor url>]
                                    [--version <version info>]
                                    [--description <description info>]
                                    [--eula <license text>]
                                    [--eulafile <filename>]

  startvm                   <uuid|vmname>...
                            [--type gui|sdl|headless]

  controlvm                 <uuid|vmname>
                            pause|resume|reset|poweroff|savestate|
                            acpipowerbutton|acpisleepbutton|
                            keyboardputscancode <hex> [<hex> ...]|
                            setlinkstate<1-N> on|off |
                            nic<1-N> null|nat|bridged|intnet|hostonly|generic|
                                     natnetwork [<devicename>] |
                            nictrace<1-N> on|off |
                            nictracefile<1-N> <filename> |
                            nicproperty<1-N> name=[value] |
                            nicpromisc<1-N> deny|allow-vms|allow-all |
                            natpf<1-N> [<rulename>],tcp|udp,[<hostip>],
                                        <hostport>,[<guestip>],<guestport> |
                            natpf<1-N> delete <rulename> |
                            guestmemoryballoon <balloonsize in MB> |
                            usbattach <uuid>|<address> |
                            usbdetach <uuid>|<address> |
                            clipboard disabled|hosttoguest|guesttohost|
                                      bidirectional |
                            draganddrop disabled|hosttoguest |
                            vrde on|off |
                            vrdeport <port> |
                            vrdeproperty <name=[value]> |
                            vrdevideochannelquality <percent> |
                            setvideomodehint <xres> <yres> <bpp>
                                            [[<display>] [<enabled:yes|no> |
                                              [<xorigin> <yorigin>]]] |
                            screenshotpng <file> [display] |
                            vcpenabled on|off |
                            vcpscreens all|none|<screen>,[<screen>...] |
                            setcredentials <username>
                                           --passwordfile <file> | <password>
                                           <domain>
                                           [--allowlocallogon <yes|no>] |
                            teleport --host <name> --port <port>
                                     [--maxdowntime <msec>]
                                     [--passwordfile <file> |
                                      --password <password>] |
                            plugcpu <id> |
                            unplugcpu <id> |
                            cpuexecutioncap <1-100>
                            webcam <attach [path [settings]]> | <detach [path]> | <list>

  discardstate              <uuid|vmname>

  adoptstate                <uuid|vmname> <state_file>

  snapshot                  <uuid|vmname>
                            take <name> [--description <desc>] [--live] |
                            delete <uuid|snapname> |
                            restore <uuid|snapname> |
                            restorecurrent |
                            edit <uuid|snapname>|--current
                                 [--name <name>]
                                 [--description <desc>] |
                            list [--details|--machinereadable]
                            showvminfo <uuid|snapname>

  closemedium               disk|dvd|floppy <uuid|filename>
                            [--delete]

  storageattach             <uuid|vmname>
                            --storagectl <name>
                            [--port <number>]
                            [--device <number>]
                            [--type dvddrive|hdd|fdd]
                            [--medium none|emptydrive|additions|
                                      <uuid|filename>|host:<drive>|iscsi]
                            [--mtype normal|writethrough|immutable|shareable|
                                     readonly|multiattach]
                            [--comment <text>]
                            [--setuuid <uuid>]
                            [--setparentuuid <uuid>]
                            [--passthrough on|off]
                            [--tempeject on|off]
                            [--nonrotational on|off]
                            [--discard on|off]
                            [--bandwidthgroup <name>]
                            [--forceunmount]
                            [--server <name>|<ip>]
                            [--target <target>]
                            [--tport <port>]
                            [--lun <lun>]
                            [--encodedlun <lun>]
                            [--username <username>]
                            [--password <password>]
                            [--initiator <initiator>]
                            [--intnet]

  storagectl                <uuid|vmname>
                            --name <name>
                            [--add ide|sata|scsi|floppy|sas]
                            [--controller LSILogic|LSILogicSAS|BusLogic|
                                          IntelAHCI|PIIX3|PIIX4|ICH6|I82078]
                            [--portcount <1-30>]
                            [--hostiocache on|off]
                            [--bootable on|off]
                            [--remove]

  bandwidthctl              <uuid|vmname>
                            add <name> --type disk|network
                                --limit <megabytes per second>[k|m|g|K|M|G] |
                            set <name>
                                --limit <megabytes per second>[k|m|g|K|M|G] |
                            remove <name> |
                            list [--machinereadable]
                            (limit units: k=kilobit, m=megabit, g=gigabit,
                                          K=kilobyte, M=megabyte, G=gigabyte)

  showhdinfo                <uuid|filename>

  createhd                  --filename <filename>
                            [--size <megabytes>|--sizebyte <bytes>]
                            [--diffparent <uuid>|<filename>
                            [--format VDI|VMDK|VHD] (default: VDI)
                            [--variant Standard,Fixed,Split2G,Stream,ESX]

  modifyhd                  <uuid|filename>
                            [--type normal|writethrough|immutable|shareable|
                                    readonly|multiattach]
                            [--autoreset on|off]
                            [--property <name=[value]>]
                            [--compact]
                            [--resize <megabytes>|--resizebyte <bytes>]

  clonehd                   <uuid|inputfile> <uuid|outputfile>
                            [--format VDI|VMDK|VHD|RAW|<other>]
                            [--variant Standard,Fixed,Split2G,Stream,ESX]
                            [--existing]

  convertfromraw            <filename> <outputfile>
                            [--format VDI|VMDK|VHD]
                            [--variant Standard,Fixed,Split2G,Stream,ESX]
                            [--uuid <uuid>]
  convertfromraw            stdin <outputfile> <bytes>
                            [--format VDI|VMDK|VHD]
                            [--variant Standard,Fixed,Split2G,Stream,ESX]
                            [--uuid <uuid>]

  getextradata              global|<uuid|vmname>
                            <key>|enumerate

  setextradata              global|<uuid|vmname>
                            <key>
                            [<value>] (no value deletes key)

  setproperty               machinefolder default|<folder> |
                            hwvirtexclusive on|off |
                            vrdeauthlibrary default|<library> |
                            websrvauthlibrary default|null|<library> |
                            vrdeextpack null|<library> |
                            autostartdbpath null|<folder> |
                            loghistorycount <value>
                            defaultfrontend default|<name>

  usbfilter                 add <index,0-N>
                            --target <uuid|vmname>|global
                            --name <string>
                            --action ignore|hold (global filters only)
                            [--active yes|no] (yes)
                            [--vendorid <XXXX>] (null)
                            [--productid <XXXX>] (null)
                            [--revision <IIFF>] (null)
                            [--manufacturer <string>] (null)
                            [--product <string>] (null)
                            [--remote yes|no] (null, VM filters only)
                            [--serialnumber <string>] (null)
                            [--maskedinterfaces <XXXXXXXX>]

  usbfilter                 modify <index,0-N>
                            --target <uuid|vmname>|global
                            [--name <string>]
                            [--action ignore|hold] (global filters only)
                            [--active yes|no]
                            [--vendorid <XXXX>|""]
                            [--productid <XXXX>|""]
                            [--revision <IIFF>|""]
                            [--manufacturer <string>|""]
                            [--product <string>|""]
                            [--remote yes|no] (null, VM filters only)
                            [--serialnumber <string>|""]
                            [--maskedinterfaces <XXXXXXXX>]

  usbfilter                 remove <index,0-N>
                            --target <uuid|vmname>|global

  sharedfolder              add <uuid|vmname>
                            --name <name> --hostpath <hostpath>
                            [--transient] [--readonly] [--automount]

  sharedfolder              remove <uuid|vmname>
                            --name <name> [--transient]

  guestproperty             get <uuid|vmname>
                            <property> [--verbose]

  guestproperty             set <uuid|vmname>
                            <property> [<value> [--flags <flags>]]

  guestproperty             delete|unset <uuid|vmname>
                            <property>

  guestproperty             enumerate <uuid|vmname>
                            [--patterns <patterns>]

  guestproperty             wait <uuid|vmname> <patterns>
                            [--timeout <msec>] [--fail-on-timeout]

  guestcontrol              <uuid|vmname>

                              exec[ute]
                              --image <path to program> --username <name>
                              [--passwordfile <file> | --password <password>]
                              [--domain <domain>] [--verbose] [--timeout <msec>]
                              [--environment "<NAME>=<VALUE> [<NAME>=<VALUE>]"]
                              [--wait-exit] [--wait-stdout] [--wait-stderr]
                              [--dos2unix] [--unix2dos]
                              [-- [<argument1>] ... [<argumentN>]]

                              copyfrom
                              <guest source> <host dest> --username <name>
                              [--passwordfile <file> | --password <password>]
                              [--domain <domain>] [--verbose]
                              [--dryrun] [--follow] [--recursive]

                              copyto|cp
                              <host source> <guest dest> --username <name>
                              [--passwordfile <file> | --password <password>]
                              [--domain <domain>] [--verbose]
                              [--dryrun] [--follow] [--recursive]

                              createdir[ectory]|mkdir|md
                              <guest directory>... --username <name>
                              [--passwordfile <file> | --password <password>]
                              [--domain <domain>] [--verbose]
                              [--parents] [--mode <mode>]

                              removedir[ectory]|rmdir
                              <guest directory>... --username <name>
                              [--passwordfile <file> | --password <password>]
                              [--domain <domain>] [--verbose]
                              [--recursive|-R|-r]

                              removefile|rm
                              <guest file>... --username <name>
                              [--passwordfile <file> | --password <password>]
                              [--domain <domain>] [--verbose]

                              ren[ame]|mv
                              <source>... <dest> --username <name>
                              [--passwordfile <file> | --password <password>]
                              [--domain <domain>] [--verbose]

                              createtemp[orary]|mktemp
                              <template> --username <name>
                              [--passwordfile <file> | --password <password>]
                              [--directory] [--secure] [--tmpdir <directory>]
                              [--domain <domain>] [--mode <mode>] [--verbose]

                              list <all|sessions|processes|files> [--verbose]

                              process kill --session-id <ID>
                                           | --session-name <name or pattern>
                                           [--verbose]
                                           <PID> ... <PID n>

                              [p[s]]kill --session-id <ID>
                                         | --session-name <name or pattern>
                                         [--verbose]
                                         <PID> ... <PID n>

                              session close  --session-id <ID>
                                           | --session-name <name or pattern>
                                           | --all
                                           [--verbose]

                              stat
                              <file>... --username <name>
                              [--passwordfile <file> | --password <password>]
                              [--domain <domain>] [--verbose]

                              updateadditions
                              [--source <guest additions .ISO>] [--verbose]
                              [--wait-start]
                              [-- [<argument1>] ... [<argumentN>]]

                              watch [--verbose]

  debugvm                   <uuid|vmname>
                            dumpguestcore --filename <name> |
                            info <item> [args] |
                            injectnmi |
                            log [--release|--debug] <settings> ...|
                            logdest [--release|--debug] <settings> ...|
                            logflags [--release|--debug] <settings> ...|
                            osdetect |
                            osinfo |
                            getregisters [--cpu <id>] <reg>|all ... |
                            setregisters [--cpu <id>] <reg>=<value> ... |
                            show [--human-readable|--sh-export|--sh-eval|
                                  --cmd-set] 
                                <logdbg-settings|logrel-settings>
                                [[opt] what ...] |
                            statistics [--reset] [--pattern <pattern>]
                            [--descriptions]

  metrics                   list [*|host|<vmname> [<metric_list>]]
                                                 (comma-separated)

  metrics                   setup
                            [--period <seconds>] (default: 1)
                            [--samples <count>] (default: 1)
                            [--list]
                            [*|host|<vmname> [<metric_list>]]

  metrics                   query [*|host|<vmname> [<metric_list>]]

  metrics                   enable
                            [--list]
                            [*|host|<vmname> [<metric_list>]]

  metrics                   disable
                            [--list]
                            [*|host|<vmname> [<metric_list>]]

  metrics                   collect
                            [--period <seconds>] (default: 1)
                            [--samples <count>] (default: 1)
                            [--list]
                            [--detach]
                            [*|host|<vmname> [<metric_list>]]

  natnetwork                add --netname <name>
                            --network <network>
                            [--enable|--disable]
                            [--dhcp on|off]
                            [--port-forward-4 <rule>]
                            [--loopback-4 <rule>]
                            [--ipv6 on|off]
                            [--port-forward-6 <rule>]
                            [--loopback-6 <rule>]

  natnetwork                remove --netname <name>

  natnetwork                modify --netname <name>
                            [--network <network>]
                            [--enable|--disable]
                            [--dhcp on|off]
                            [--port-forward-4 <rule>]
                            [--loopback-4 <rule>]
                            [--ipv6 on|off]
                            [--port-forward-6 <rule>]
                            [--loopback-6 <rule>]

  natnetwork                start --netname <name>

  natnetwork                stop --netname <name>

  hostonlyif                ipconfig <name>
                            [--dhcp |
                            --ip<ipv4> [--netmask<ipv4> (def: 255.255.255.0)] |
                            --ipv6<ipv6> [--netmasklengthv6<length> (def: 64)]]
                            create |
                            remove <name>

  dhcpserver                add|modify --netname <network_name> |
                                       --ifname <hostonly_if_name>
                            [--ip <ip_address>
                            --netmask <network_mask>
                            --lowerip <lower_ip>
                            --upperip <upper_ip>]
                            [--enable | --disable]

  dhcpserver                remove --netname <network_name> |
                                   --ifname <hostonly_if_name>

  extpack                   install [--replace] <tarball> |
                            uninstall [--force] <name> |
                            cleanup

VirtualBox从U盘启动

默认情况下,Virtualbox从无法从U盘启动的。

但可以用变通的方法,将宿主机的U盘,模拟为一个虚拟盘,从虚拟盘进行启动。

1、首先产看本地硬盘信息
运行diskmgmt.msc
查看U盘是第几个驱动器,比如我的是第2个驱动器(编号从0开始,0,1,2这样)

2、将U盘模拟为一个虚拟盘

VBoxManage internalcommands createrawvmdk -filename D:\VirtualMashines\VirtualBox\WinXP\usbdisk.vmdk -rawdisk \\.\PhysicalDrive2

3、虚拟机中,添加该虚拟盘

4、启动,按F12,选择虚拟盘启动。

VirtualBox扩展及压缩虚拟磁盘

1、首先定位各虚拟磁盘的UUID

C:\ProgramerTools\Oracle\VirtualBox>VBoxManage.exe list hdds
UUID:           b806ffa9-ea8e-4059-9dd8-2d246e850ab6
Parent UUID:    base
State:          created
Type:           normal (base)
Location:       D:\VirtualMashines\VirtualBox\WinXP\WinXP.vdi
Storage format: VDI
Capacity:       10240 MBytes

UUID:           945de0c8-f928-44ad-ae39-9a12a71568ef
Parent UUID:    base
State:          created
Type:           normal (base)
Location:       D:\VirtualMashines\VirtualBox\Debian8\Debian8.vdi
Storage format: VDI
Capacity:       20480 MBytes

UUID:           e49d8a88-d68b-43b8-954e-2be419933e08
Parent UUID:    base
State:          created
Type:           normal (base)
Location:       D:\VirtualMashines\VirtualBox\Docker\Debian8Docker\Debian8Docker
.vdi
Storage format: VDI
Capacity:       20480 MBytes

UUID:           eab29989-ce9c-4491-8dd0-2190ed3029d6
Parent UUID:    base
State:          created
Type:           normal (base)
Location:       D:\VirtualMashines\VirtualBox\FreeBSD10\FreeBSD10.vdi
Storage format: VDI
Capacity:       20480 MBytes

UUID:           74bcd43e-a315-437e-9b4f-895051ff8433
Parent UUID:    base
State:          created
Type:           normal (base)
Location:       D:\VirtualMashines\VirtualBox\FreeBSD10\FreeBSD10A01.vdi
Storage format: VDI
Capacity:       20480 MBytes

2、扩展WinXP虚拟磁盘
2.1我的xp虚拟机一共只有10G,我需要扩展到20G(要关虚拟机)

C:\ProgramerTools\Oracle\VirtualBox>VBoxManage modifyhd b806ffa9-ea8e-4059-9dd8-
2d246e850ab6 --resize 20480
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

2.2扩展后,开启虚拟机,自己到磁盘管理器中分配空间即可。

3、扩展Debian虚拟磁盘
3.1我的Debian8Docker虚拟机一共只有20G,我需要扩展到30G(要关虚拟机)

C:\ProgramerTools\Oracle\VirtualBox>VBoxManage modifyhd e49d8a88-d68b-43b8-954e-
2be419933e08 --resize 30720
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

3.2扩展后,开启虚拟机,使用gparted等工具分配空间即可。
需要提前unmount分区,如果是调整扩展分区,需要umount该扩展分区下的所有挂载点。

4、压缩WinXP虚拟磁盘
4.1需要到微软官网下载sdelete工具,然后在虚拟机中运行:

sdelete -z

4.2关闭虚拟机,运行:

VBoxManage modifyhd b806ffa9-ea8e-4059-9dd8-2d246e850ab6 --compact

5、压缩Debian虚拟磁盘:
5.1A在虚拟机中运行zerofree命令,需要将分区挂载为只读模式

apt-get install zerofree
cd /
umount /home
zerofree /dev/sda6

5.1B在虚拟机中运行dd命令,需要将分区挂载为读写模式

dd if=/dev/zero of=/bigemptyfile
rm bigemptyfile 

5.2关闭虚拟机,运行:

VBoxManage modifyhd 945de0c8-f928-44ad-ae39-9a12a71568ef --compact

6、压缩FreeBSD虚拟磁盘:
6.1A在虚拟机中运行dd命令,需要将分区挂载为读写模式

dd if=/dev/zero of=bigemptyfile bs=1m
rm bigemptyfile

6.1B在虚拟机中运行dd命令,需要将分区挂载为读写模式(适用于影片空闲空间较小)

cat /dev/zero > bigemptyfile;sync;sleep 1;sync;
rm -f bigemptyfile

6.2关闭虚拟机,运行:

VBoxManage modifyhd eab29989-ce9c-4491-8dd0-2190ed3029d6 --compact
VBoxManage modifyhd 74bcd43e-a315-437e-9b4f-895051ff8433 --compact