VirtualBox

source: vbox/trunk/doc/manual/en_US/user_AdvancedTopics.xml@ 32780

最後變更 在這個檔案從32780是 32721,由 vboxsync 提交於 14 年 前

doc/manual: document VBoxService --timesync-set-on-restore

檔案大小: 74.8 KB
 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
3"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
4<chapter id="AdvancedTopics">
5 <title>Advanced topics</title>
6
7 <sect1 id="vboxconfigdata">
8 <title>VirtualBox configuration data</title>
9
10 <para>For each system user, VirtualBox stores configuration data in the
11 user's home directory, as per the conventions of the host operating
12 system:<itemizedlist>
13 <listitem>
14 <para>On Windows, this is
15 <computeroutput>%HOMEDRIVE%%HOMEPATH%\.VirtualBox</computeroutput>;
16 typically something like <computeroutput>C:\Documents and
17 Settings\Username\.VirtualBox</computeroutput>.</para>
18 </listitem>
19
20 <listitem>
21 <para>On Mac OS X, this is
22 <computeroutput>$HOME/Library/VirtualBox</computeroutput>.</para>
23 </listitem>
24
25 <listitem>
26 <para>On Unix-like systems (Linux, Solaris), this is
27 <computeroutput>$HOME/.VirtualBox</computeroutput>.</para>
28 </listitem>
29 </itemizedlist></para>
30
31 <para>VirtualBox creates this configuration directory automatically, if
32 necessary. Optionally, you can supply an alternate configuration directory
33 by setting the
34 <computeroutput><literal>VBOX_USER_HOME</literal></computeroutput>
35 environment variable. You can globally change some of the locations where
36 VirtualBox keeps extra configuration and data by selecting "Global
37 settings" from the "File" menu in the VirtualBox main window. Then, in the
38 window that pops up, click on the "General" tab.</para>
39
40 <para>VirtualBox stores all its global and machine-specific configuration
41 data in XML documents. We intentionally do not document the specifications
42 of these files, as we must reserve the right to modify them in the future.
43 We therefore strongly suggest that you do not edit these files manually.
44 VirtualBox provides complete access to its configuration data through its
45 the <computeroutput>VBoxManage</computeroutput> command line tool (see
46 <xref linkend="vboxmanage" />) and its API (see <xref
47 linkend="VirtualBoxAPI" />).</para>
48
49 <para>The XML files are versioned. When a new settings file is created
50 (e.g. because a new virtual machine is created), VirtualBox automatically
51 uses the settings format of the current VirtualBox version. These files
52 may not be readable if you downgrade to an earlier version of VirtualBox.
53 However, when VirtualBox encounters a settings file from an earlier
54 version (e.g. after upgrading VirtualBox), it attempts to preserve the
55 settings format as much as possible. It will only silently upgrade the
56 settings format if the current settings cannot be expressed in the old
57 format, for example because you enabled a feature that was not present in
58 an earlier version of VirtualBox.<footnote>
59 <para>As an example, before VirtualBox 3.1, it was only possible to
60 enable or disable a single DVD drive in a virtual machine. If it was
61 enabled, then it would always be visible as the secondary master of
62 the IDE controller. With VirtualBox 3.1, DVD drives can be attached to
63 arbitrary slots of arbitrary controllers, so they could be the
64 secondary slave of an IDE controller or in a SATA slot. If you have a
65 machine settings file from an earlier version and upgrade VirtualBox
66 to 3.1 and then move the DVD drive from its default position, this
67 cannot be expressed in the old settings format; the XML machine file
68 would get written in the new format, and a backup file of the old
69 format would be kept.</para>
70 </footnote> In such cases, VirtualBox backs up the old settings file in
71 the virtual machine's configuration directory. If you need to go back to
72 the earlier version of VirtualBox, then you will need to manually copy
73 these backup files back.</para>
74
75 <para>In detail, the following settings files are in use:</para>
76
77 <para><itemizedlist>
78 <listitem>
79 <para>In the configuration directory,
80 <computeroutput>VirtualBox.xml</computeroutput> is the main
81 configuration file. This includes global configuration options and
82 the media and virtual machine registry. The media registry links to
83 all CD/DVD, floppy and disk images that have been added to the
84 Virtual Media Manager. For each registered VM, there is one entry
85 which points to the VM configuration file, also in XML
86 format.</para>
87 </listitem>
88
89 <listitem>
90 <para>Virtual machine settings and files are, by default, saved as
91 XML files in a subdirectory of the
92 <computeroutput>Machines</computeroutput> directory, which
93 VirtualBox creates under the main configuration directory (see
94 above). You can change the location of this main "Machines" folder
95 in the "Global settings" dialog.</para>
96
97 <para>By default, for each virtual machine, VirtualBox uses another
98 subdirectory of the "Machines" directory that carries the same name
99 as the virtual machine. As a result, your virtual machine names must
100 conform to the conventions of your operating system for valid file
101 names. For example, a machine called "Fedora 6" would, by default,
102 have its settings saved in
103 <computeroutput>.VirtualBox/Machines/Fedora 6/Fedora
104 6.xml</computeroutput> (on a Linux or Solaris host).</para>
105
106 <para>If you would like more control over the file names used, you
107 can create the machine using <computeroutput>VBoxManage
108 createvm</computeroutput> with the
109 <computeroutput>--settingsfile</computeroutput> option; see <xref
110 linkend="vboxmanage-createvm" />.</para>
111
112 <para>The virtual machine directory will be renamed if you change
113 the machine name. If you do not wish this to happen, you can create
114 the machine using <computeroutput>VBoxManage
115 createvm</computeroutput> with the
116 <computeroutput>--basefolder</computeroutput> option. In this case,
117 the folder name will never change.</para>
118 </listitem>
119
120 <listitem>
121 <para>VirtualBox keeps snapshots and saved states in another special
122 folder for each virtual machine. By default, this is a subfolder of
123 the virtual machine folder called
124 <computeroutput>Snapshots</computeroutput> -- in our example,
125 <computeroutput>.VirtualBox/Machines/Fedora
126 6/Snapshots</computeroutput>. You can change this setting for each
127 machine using <computeroutput>VBoxManage</computeroutput> as
128 well.</para>
129 </listitem>
130
131 <listitem>
132 <para>VDI container files are, by default, created in the
133 <computeroutput>HardDisks</computeroutput> directory under the main
134 configuration directory (see above). In particular, this directory
135 is used when the "Create new virtual disk" wizard is started to
136 create a new VDI file. Changing this default is probably most useful
137 if the disk containing your home directory does not have enough room
138 to hold your VDI files, which can grow very large.</para>
139 </listitem>
140 </itemizedlist></para>
141 </sect1>
142
143 <sect1 id="vboxsdl">
144 <title>VBoxSDL, the simplified VM displayer</title>
145
146 <sect2>
147 <title>Introduction</title>
148
149 <para>VBoxSDL is a simple graphical user interface (GUI) that lacks the
150 nice point-and-click support which VirtualBox, our main GUI, provides.
151 VBoxSDL is currently primarily used internally for debugging VirtualBox
152 and therefore not officially supported. Still, you may find it useful
153 for environments where the virtual machines are not necessarily
154 controlled by the same person that uses the virtual machine.<note>
155 <para>VBoxSDL is not available on the Mac OS X host platform.</para>
156 </note></para>
157
158 <para>As you can see in the following screenshot, VBoxSDL does indeed
159 only provide a simple window that contains only the "pure" virtual
160 machine, without menus or other controls to click upon and no additional
161 indicators of virtual machine activity:</para>
162
163 <para><mediaobject>
164 <imageobject>
165 <imagedata align="center" fileref="images/vbox-sdl.png"
166 width="10cm" />
167 </imageobject>
168 </mediaobject></para>
169
170 <para>To start a virtual machine with VBoxSDL instead of the VirtualBox
171 GUI, enter the following on a command line:<screen>VBoxSDL --startvm &lt;vm&gt;</screen></para>
172
173 <para>where <computeroutput>&lt;vm&gt;</computeroutput> is, as usual
174 with VirtualBox command line parameters, the name or UUID of an existing
175 virtual machine.</para>
176 </sect2>
177
178 <sect2>
179 <title>Secure labeling with VBoxSDL</title>
180
181 <para>When running guest operating systems in fullscreen mode, the guest
182 operating system usually has control over the whole screen. This could
183 present a security risk as the guest operating system might fool the
184 user into thinking that it is either a different system (which might
185 have a higher security level) or it might present messages on the screen
186 that appear to stem from the host operating system.</para>
187
188 <para>In order to protect the user against the above mentioned security
189 risks, the secure labeling feature has been developed. Secure labeling
190 is currently available only for VBoxSDL. When enabled, a portion of the
191 display area is reserved for a label in which a user defined message is
192 displayed. The label height in set to 20 pixels in VBoxSDL. The label
193 font color and background color can be optionally set as hexadecimal RGB
194 color values. The following syntax is used to enable secure
195 labeling:</para>
196
197 <screen>VBoxSDL --startvm "VM name"
198 --securelabel --seclabelfnt ~/fonts/arial.ttf
199 --seclabelsiz 14 --seclabelfgcol 00FF00 --seclabelbgcol 00FFFF</screen>
200
201 <para>In addition to enabling secure labeling, a TrueType font has to be
202 supplied. To use another font size than 12 point use the parameter
203 <computeroutput>--seclabelsiz</computeroutput>.</para>
204
205 <para>The label text can be set with <screen>VBoxManage setextradata "VM name" "VBoxSDL/SecureLabel" "The Label"</screen>
206 Changing this label will take effect immediately.</para>
207
208 <para>Typically, full screen resolutions are limited to certain
209 "standard" geometries such as 1024 x 768. Increasing this by twenty
210 lines is not usually feasible, so in most cases, VBoxSDL will chose the
211 next higher resolution, e.g. 1280 x 1024 and the guest's screen will not
212 cover the whole display surface. If VBoxSDL is unable to choose a higher
213 resolution, the secure label will be painted on top of the guest's
214 screen surface. In order to address the problem of the bottom part of
215 the guest screen being hidden, VBoxSDL can provide custom video modes to
216 the guest that are reduced by the height of the label. For Windows
217 guests and recent Solaris and Linux guests, the VirtualBox Guest
218 Additions automatically provide the reduced video modes. Additionally,
219 the VESA BIOS has been adjusted to duplicate its standard mode table
220 with adjusted resolutions. The adjusted mode IDs can be calculated using
221 the following formula:</para>
222
223 <screen>reduced_modeid = modeid + 0x30</screen>
224
225 <para>For example, in order to start Linux with 1024 x 748 x 16, the
226 standard mode 0x117 (1024 x 768 x 16) is used as a base. The Linux video
227 mode kernel parameter can then be calculated using:</para>
228
229 <screen>vga = 0x200 | 0x117 + 0x30
230vga = 839</screen>
231
232 <para>The reason for duplicating the standard modes instead of only
233 supplying the adjusted modes is that most guest operating systems
234 require the standard VESA modes to be fixed and refuse to start with
235 different modes.</para>
236
237 <para>When using the X.org VESA driver, custom modelines have to be
238 calculated and added to the configuration (usually in
239 <literal>/etc/X11/xorg.conf</literal>. A handy tool to determine
240 modeline entries can be found at <literal><ulink
241 url="http://www.tkk.fi/Misc/Electronics/faq/vga2rgb/calc.html">http://www.tkk.fi/Misc/Electronics/faq/vga2rgb/calc.html</ulink></literal>.)</para>
242 </sect2>
243
244 <sect2>
245 <title>Releasing modifiers with VBoxSDL on Linux</title>
246
247 <para>When switching from a X virtual terminal (VT) to another VT using
248 Ctrl-Alt-Fx while the VBoxSDL window has the input focus, the guest will
249 receive Ctrl and Alt keypress events without receiving the corresponding
250 key release events. This is an architectural limitation of Linux. In
251 order to reset the modifier keys, it is possible to send
252 <computeroutput>SIGUSR1</computeroutput> to the VBoxSDL main thread
253 (first entry in the <computeroutput>ps</computeroutput> list). For
254 example, when switching away to another VT and saving the virtual
255 machine from this terminal, the following sequence can be used to make
256 sure the VM is not saved with stuck modifiers:</para>
257
258 <para><screen>kill -usr1 &lt;pid&gt;
259VBoxManage controlvm "Windows 2000" savestate</screen></para>
260 </sect2>
261 </sect1>
262
263 <sect1>
264 <title id="autologon">Automated guest logons</title>
265
266 <para>VirtualBox provides Guest Addition modules for Windows, Linux and
267 Solaris to enable automated logons on the guest.</para>
268
269 <para>When a guest operating system is running in a virtual machine, it
270 might be desirable to perform coordinated and automated logons using
271 credentials from a master logon system. (With "credentials", we are
272 referring to logon information consisting of user name, password and
273 domain name, where each value might be empty.)</para>
274
275 <sect2 id="autologon_win">
276 <title>Automated Windows guest logons</title>
277
278 <para>Since Windows NT, Windows has provided a modular system logon
279 subsystem ("Winlogon") which can be customized and extended by means of
280 so-called GINA modules (Graphical Identification and Authentication).
281 With Windows Vista and Windows 7, the GINA modules were replaced with a
282 new mechanism called "credential providers". The VirtualBox Guest
283 Additions for Windows come with both, a GINA and a credential provider
284 module, and therefore enable any Windows guest to perform automated
285 logons.</para>
286
287 <para>To activate the VirtualBox GINA or credential provider module,
288 install the Guest Additions with using the command line switch
289 <computeroutput>/with_autologon</computeroutput>. All the following
290 manual steps required for installing these modules will be then done by
291 the installer.</para>
292
293 <para>To manually install the VirtualBox GINA module, extract the Guest
294 Additions (see <xref linkend="windows-guest-file-extraction" />) and
295 copy the file <computeroutput>VBoxGINA.dll</computeroutput> to the
296 Windows <computeroutput>SYSTEM32</computeroutput> directory. Then, in
297 the registry, create the following key: <screen>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\GinaDLL</screen>
298 with a value of <computeroutput>VBoxGINA.dll</computeroutput>.</para>
299
300 <para><note>
301 The VirtualBox GINA is implemented as a wrapper around the standard Windows
302 GINA (<computeroutput>MSGINA.DLL</computeroutput>),
303 therefore it will most likely not work correctly with 3rd party GINA modules.
304 </note></para>
305
306 <para>To manually install the VirtualBox credential module, extract the
307 Guest Additions (see <xref linkend="windows-guest-file-extraction" />)
308 and copy the file <computeroutput>VBoxCredProv.dll</computeroutput> to
309 the Windows <computeroutput>SYSTEM32</computeroutput> directory. Then,
310 in the registry, create the following keys:<screen>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\
311 Authentication\Credential Providers\{275D3BCC-22BB-4948-A7F6-3A3054EBA92B}
312
313HKEY_CLASSES_ROOT\CLSID\{275D3BCC-22BB-4948-A7F6-3A3054EBA92B}
314
315HKEY_CLASSES_ROOT\CLSID\{275D3BCC-22BB-4948-A7F6-3A3054EBA92B}\InprocServer32</screen></para>
316
317 <para>with all default values (the key named
318 <computeroutput>(Default)</computeroutput> in each key) set to
319 <computeroutput>VBoxCredProv</computeroutput>. After that a new string
320 named <screen>HKEY_CLASSES_ROOT\CLSID\{275D3BCC-22BB-4948-A7F6-3A3054EBA92B}\InprocServer32\ThreadingModel</screen>
321 with a value of <computeroutput>Apartment</computeroutput> has to be
322 created.</para>
323
324 <para>To set credentials, use the following command on a
325 <emphasis>running</emphasis> VM:</para>
326
327 <screen>VBoxManage controlvm "Windows XP" setcredentials "John Doe" "secretpassword" "DOMTEST"</screen>
328
329 <para>While the VM is running, the credentials can be queried by the
330 VirtualBox logon modules (GINA or credential provider) using the
331 VirtualBox Guest Additions device driver. When Windows is in "logged
332 out" mode, the logon modules will constantly poll for credentials and if
333 they are present, a logon will be attempted. After retrieving the
334 credentials, the logon modules will erase them so that the above command
335 will have to be repeated for subsequent logons.</para>
336
337 <para>For security reasons, credentials are not stored in any persistent
338 manner and will be lost when the VM is reset. Also, the credentials are
339 "write-only", i.e. there is no way to retrieve the credentials from the
340 host side. Credentials can be reset from the host side by setting empty
341 values.</para>
342
343 <para>Depending on the particular variant of the Windows guest, the
344 following restrictions apply: <orderedlist>
345 <listitem>
346 <para>For <emphasis role="bold">Windows XP guests,</emphasis> the
347 logon subsystem needs to be configured to use the classic logon
348 dialog as the VirtualBox GINA module does not support the XP-style
349 welcome dialog.</para>
350 </listitem>
351
352 <listitem>
353 <para>For <emphasis role="bold">Windows Vista and Windows 7
354 guests,</emphasis> the logon subsystem does not support the
355 so-called Secure Attention Sequence
356 (<computeroutput>CTRL+ALT+DEL</computeroutput>). As a result, the
357 guest's group policy settings need to be changed to not use the
358 Secure Attention Sequence. Also, the user name given is only
359 compared to the true user name, not the user friendly name. This
360 means that when you rename a user, you still have to supply the
361 original user name (internally, Windows never renames user
362 accounts).</para>
363 </listitem>
364 </orderedlist></para>
365
366 <para>The following command forces VirtualBox to keep the credentials
367 after they were read by the guest and on VM reset: <screen>VBoxManage setextradata "Windows XP" VBoxInternal/Devices/VMMDev/0/Config/KeepCredentials 1</screen>Note
368 that this is a potential security risk as a malicious application
369 running on the guest could request this information using the proper
370 interface.</para>
371 </sect2>
372
373 <sect2 id="autologon_unix">
374 <title>Automated Linux/Unix guest logons</title>
375
376 <para>Starting with version 3.2, VirtualBox provides a custom PAM module
377 (Pluggable Authentication Module) which can be used to perform automated
378 guest logons on platforms which support this framework. Virtually all
379 modern Linux/Unix distributions rely on PAM.</para>
380
381 <para>The <computeroutput>pam_vbox.so</computeroutput> module itself
382 <emphasis role="bold">does not</emphasis> do an actual verification of
383 the credentials passed to the guest OS; instead it relies on other
384 modules such as <computeroutput>pam_unix.so</computeroutput> or
385 <computeroutput>pam_unix2.so</computeroutput> down in the PAM stack to
386 do the actual validation using the credentials retrieved by
387 <computeroutput>pam_vbox.so</computeroutput>. Therefore
388 <computeroutput>pam_vbox.so</computeroutput> has to be on top of the
389 authentication PAM service list.</para>
390
391 <note>
392 <para>The <computeroutput>pam_vbox.so</computeroutput> only supports
393 the <computeroutput>auth</computeroutput> primitive. Other primitives
394 such as <computeroutput>account</computeroutput>,
395 <computeroutput>session</computeroutput> or
396 <computeroutput>password</computeroutput> are not supported.</para>
397 </note>
398
399 <para>The <computeroutput>pam_vbox.so</computeroutput> module is shipped
400 as part of the Guest Additions but it is not installed and/or activated
401 on the guest OS by default. In order to install it, it has to be copied
402 from
403 <computeroutput>/opt/VBoxGuestAdditions-&lt;version&gt;/lib/VBoxGuestAdditions/</computeroutput>
404 to the security modules directory, usually
405 <computeroutput>/lib/security/</computeroutput>. Please refer to your
406 guest OS documentation for the correct PAM module directory.</para>
407
408 <para>For example, to use <computeroutput>pam_vbox.so</computeroutput>
409 with a Ubuntu Linux guest OS and GDM (the GNOME Desktop Manager) to
410 logon users automatically with the credentials passed by the host, the
411 guest OS has to be configured like the following:</para>
412
413 <orderedlist>
414 <listitem>
415 <para>The <computeroutput>pam_vbox.so</computeroutput> module has to
416 be copied to the security modules directory, in this case it is
417 <computeroutput>/lib/security</computeroutput>.</para>
418 </listitem>
419
420 <listitem>
421 <para>Edit the PAM configuration file for GDM found at
422 <computeroutput>/etc/pam.d/gdm</computeroutput>, adding the line
423 <computeroutput>auth requisite pam_vbox.so</computeroutput> at the
424 top. Additionaly, in most Linux distributions there is a file called
425 <computeroutput>/etc/pam.d/common-auth</computeroutput>. This file
426 is included in many other services (like the GDM file mentioned
427 above). There you also have to add add the line <computeroutput>auth
428 requisite pam_vbox.so</computeroutput>.</para>
429 </listitem>
430
431 <listitem>
432 <para>If authentication against the shadow database using
433 <computeroutput>pam_unix.so</computeroutput> or
434 <computeroutput>pam_unix2.so</computeroutput> is desired, the
435 argument <computeroutput>try_first_pass</computeroutput> is needed
436 in order to pass the credentials from the VirtualBox module to the
437 shadow database authentication module. For Ubuntu, this needs to be
438 added to <computeroutput>/etc/pam.d/common-auth</computeroutput>, to
439 the end of the line referencing
440 <computeroutput>pam_unix.so</computeroutput>. This argument tells
441 the PAM module to use credentials already present in the stack, i.e.
442 the ones provided by the VirtualBox PAM module.</para>
443 </listitem>
444 </orderedlist>
445
446 <para><warning>
447 <para>An incorrectly configured PAM stack can effectively prevent
448 you from logging into your guest system!</para>
449 </warning></para>
450
451 <para>To make deployment easier, you can pass the argument
452 <computeroutput>debug</computeroutput> right after the
453 <computeroutput>pam_vbox.so</computeroutput> statement. Debug log output
454 will then be recorded using syslog.</para>
455
456 <para><warning>
457 <para>At present, the GDM display manager only retrieves credentials
458 at startup so unless the credentials have been supplied to the guest
459 before GDM starts, automatic logon will not work. This limitation
460 needs to be addressed by the GDM developers or another display
461 manager must be used.</para>
462 </warning></para>
463 </sect2>
464 </sect1>
465
466 <sect1>
467 <title>Advanced configuration for Windows guests</title>
468
469 <sect2 id="sysprep">
470 <title>Automated Windows system preparation</title>
471
472 <para>Beginning with Windows NT 4.0, Microsoft offers a "system
473 preparation" tool (in short: Sysprep) to prepare a Windows system for
474 deployment or redistribution. Whereas Windows 2000 and XP ship with
475 Sysprep on the installation medium, the tool also is available for
476 download on the Microsoft web site. In a standard installation of
477 Windows Vista and 7, Sysprep is already included. Sysprep mainly
478 consists of an executable called
479 <computeroutput>sysprep.exe</computeroutput> which is invoked by the
480 user to put the Windows installation into preparation mode.</para>
481
482 <para>Starting with VirtualBox 3.2.2, the Guest Additions offer a way to
483 launch a system preparation on the guest operating system in an
484 automated way, controlled from the host system. To achieve that, see
485 <xref linkend="guestadd-guestcontrol" /> for using the feature with the
486 special identifier <computeroutput>sysprep</computeroutput> as the
487 program to execute, along with the user name
488 <computeroutput>sysprep</computeroutput> and password
489 <computeroutput>sysprep</computeroutput> for the credentials. Sysprep
490 then gets launched with the required system rights.</para>
491
492 <note>
493 <para>Specifying the location of "sysprep.exe" is <emphasis
494 role="bold">not possible</emphasis> -- instead the following paths are
495 used (based on the operating system): <itemizedlist>
496 <listitem>
497 <para><computeroutput>C:\sysprep\sysprep.exe</computeroutput>
498 for Windows NT 4.0, 2000 and XP</para>
499 </listitem>
500
501 <listitem>
502 <para><computeroutput>%WINDIR%\System32\Sysprep\sysprep.exe</computeroutput>
503 for Windows Vista, 2008 Server and 7</para>
504 </listitem>
505 </itemizedlist> The Guest Additions will automatically use the
506 appropriate path to execute the system preparation tool.</para>
507 </note>
508 </sect2>
509 </sect1>
510
511 <sect1 id="cpuhotplug">
512 <title>CPU hot-plugging</title>
513
514 <para>With virtual machines running modern server operating systems,
515 VirtualBox supports CPU hot-plugging.<footnote>
516 <para>Support for CPU hot-plugging was introduced with VirtualBox
517 3.2.</para>
518 </footnote> Whereas on a physical computer this would mean that a CPU
519 can be added or removed while the machine is running, VirtualBox supports
520 adding and removing virtual CPUs while a virtual machine is
521 running.</para>
522
523 <para>CPU hot-plugging works only with guest operating systems that
524 support it. So far this applies only to Linux and Windows Server 2008 x64
525 Data Center Edition. Windows supports only hot-add while Linux supports
526 hot-add and hot-remove but to use this feature with more than 8 CPUs a
527 64bit Linux guest is required.</para>
528
529 <para>At this time, CPU hot-plugging requires using the VBoxManage
530 command-line interface. First, hot-plugging needs to be enabled for a
531 virtual machine:<screen>VBoxManage modifyvm "VM name" --cpuhotplug on</screen></para>
532
533 <para>After that, the --cpus option specifies the maximum number of CPUs
534 that the virtual machine can have:<screen>VBoxManage modifyvm "VM name" --cpus 8</screen>When
535 the VM is off, you can then add and remove virtual CPUs with the modifyvm
536 --plugcpu and --unplugcpu subcommands, which take the number of the
537 virtual CPU as a parameter, like this:<screen>VBoxManage modifyvm "VM name" --plugcpu 3
538VBoxManage modifyvm "VM name" --unplugcpu 3</screen>Note that CPU 0 can never
539 be removed.</para>
540
541 <para>While the VM is running, CPUs can be added with the
542 <computeroutput>controlvm plugcpu/unplugcpu</computeroutput> commands
543 instead:<screen>VBoxManage controlvm "VM name" plugcpu 3
544VBoxManage controlvm "VM name" unplugcpu 3</screen></para>
545
546 <para>See <xref linkend="vboxmanage-modifyvm" /> and <xref
547 linkend="vboxmanage-controlvm" /> for details.</para>
548
549 <para>With Linux guests, the following applies: To prevent ejection while
550 the CPU is still used it has to be ejected from within the guest before.
551 The Linux Guest Additions contain a service which receives hot-remove
552 events and ejects the CPU. Also, after a CPU is added to the VM it is not
553 automatically used by Linux. The Linux Guest Additions service will take
554 care of that if installed. If not a CPU can be started with the following
555 command:<screen>echo 1 &gt; /sys/devices/system/cpu/cpu&lt;id&gt;/online</screen></para>
556 </sect1>
557
558 <sect1>
559 <title>Advanced display configuration</title>
560
561 <sect2>
562 <title>Custom VESA resolutions</title>
563
564 <para>Apart from the standard VESA resolutions, the VirtualBox VESA BIOS
565 allows you to add up to 16 custom video modes which will be reported to
566 the guest operating system. When using Windows guests with the
567 VirtualBox Guest Additions, a custom graphics driver will be used
568 instead of the fallback VESA solution so this information does not
569 apply.</para>
570
571 <para>Additional video modes can be configured for each VM using the
572 extra data facility. The extra data key is called
573 <literal>CustomVideoMode&lt;x&gt;</literal> with <literal>x</literal>
574 being a number from 1 to 16. Please note that modes will be read from 1
575 until either the following number is not defined or 16 is reached. The
576 following example adds a video mode that corresponds to the native
577 display resolution of many notebook computers:</para>
578
579 <screen>VBoxManage setextradata "VM name" "CustomVideoMode1" "1400x1050x16"</screen>
580
581 <para>The VESA mode IDs for custom video modes start at
582 <literal>0x160</literal>. In order to use the above defined custom video
583 mode, the following command line has be supplied to Linux:</para>
584
585 <screen>vga = 0x200 | 0x160
586vga = 864</screen>
587
588 <para>For guest operating systems with VirtualBox Guest Additions, a
589 custom video mode can be set using the video mode hint feature.</para>
590 </sect2>
591
592 <sect2>
593 <title>Configuring the maximum resolution of guests when using the
594 graphical frontend</title>
595
596 <para>When guest systems with the Guest Additions installed are started
597 using the graphical frontend (the normal VirtualBox application), they
598 will not be allowed to use screen resolutions greater than the host's
599 screen size unless the user manually resizes them by dragging the
600 window, switching to fullscreen or seamless mode or sending a video mode
601 hint using VBoxManage. This behavior is what most users will want, but
602 if you have different needs, it is possible to change it by issuing one
603 of the following commands from the command line:</para>
604
605 <screen>VBoxManage setextradata global GUI/MaxGuestResolution any</screen>
606
607 <para>will remove all limits on guest resolutions.</para>
608
609 <screen>VBoxManage setextradata global GUI/MaxGuestResolution &gt;width,height&lt;</screen>
610
611 <para>manually specifies a maximum resolution.</para>
612
613 <screen>VBoxManage setextradata global GUI/MaxGuestResolution auto</screen>
614
615 <para>restores the default settings. Note that these settings apply
616 globally to all guest systems, not just to a single machine.</para>
617 </sect2>
618
619 <sect2 id="vrdp-authenticate-sdk">
620 <title>Custom external VRDP authentication</title>
621
622 <para>As described in <xref linkend="vrdp-auth" />, VirtualBox supports
623 arbitrary external modules to perform authentication with its VRDP
624 servers. When the authentication method is set to "external" for a
625 particular VM, VirtualBox calls the library that was specified with
626 <computeroutput>VBoxManage setproperty vrdpauthlibrary</computeroutput>.
627 This library will be loaded by the VM process on demand, i.e. when the
628 first RDP connection is made by an external client.</para>
629
630 <para>External authentication is the most flexible as the external
631 handler can both choose to grant access to everyone (like the "null"
632 authentication method would) and delegate the request to the guest
633 authentication component. When delegating the request to the guest
634 component, it will still be called afterwards with the option to
635 override the result.</para>
636
637 <para>A VRDP authentication library is required to implement exactly one
638 entry point:</para>
639
640 <screen>#include "VRDPAuth.h"
641
642/**
643 * Authentication library entry point. Decides whether to allow
644 * a client connection.
645 *
646 * Parameters:
647 *
648 * pUuid Pointer to the UUID of the virtual machine
649 * which the client connected to.
650 * guestJudgement Result of the guest authentication.
651 * szUser User name passed in by the client (UTF8).
652 * szPassword Password passed in by the client (UTF8).
653 * szDomain Domain passed in by the client (UTF8).
654 * fLogon Boolean flag. Indicates whether the entry point is called
655 * for a client logon or the client disconnect.
656 * clientId Server side unique identifier of the client.
657 *
658 * Return code:
659 *
660 * VRDPAuthAccessDenied Client access has been denied.
661 * VRDPAuthAccessGranted Client has the right to use the
662 * virtual machine.
663 * VRDPAuthDelegateToGuest Guest operating system must
664 * authenticate the client and the
665 * library must be called again with
666 * the result of the guest
667 * authentication.
668 */
669VRDPAuthResult VRDPAUTHCALL VRDPAuth2(
670 PVRDPAUTHUUID pUuid,
671 VRDPAuthGuestJudgement guestJudgement,
672 const char *szUser,
673 const char *szPassword
674 const char *szDomain
675 int fLogon,
676 unsigned clientId)
677{
678 /* process request against your authentication source of choice */
679 return VRDPAuthAccessGranted;
680}</screen>
681
682 <para>A note regarding the UUID implementation of the first argument:
683 VirtualBox uses a consistent binary representation of UUIDs on all
684 platforms. For this reason the integer fields comprising the UUID are
685 stored as little endian values. If you want to pass such UUIDs to code
686 which assumes that the integer fields are big endian (often also called
687 network byte order), you need to adjust the contents of the UUID to e.g.
688 achieve the same string representation. The required changes
689 are:<itemizedlist>
690 <listitem>
691 <para>reverse the order of byte 0, 1, 2 and 3</para>
692 </listitem>
693
694 <listitem>
695 <para>reverse the order of byte 4 and 5</para>
696 </listitem>
697
698 <listitem>
699 <para>reverse the order of byte 6 and 7.</para>
700 </listitem>
701 </itemizedlist>Using this conversion you will get identical results
702 when converting the binary UUID to the string representation.</para>
703
704 <para>The second arguments contains information about the guest
705 authentication status. For the first call, it is always set to
706 <computeroutput>VRDPAuthGuestNotAsked</computeroutput>. In case the
707 function returns
708 <computeroutput>VRDPAuthDelegateToGuest</computeroutput>, a guest
709 authentication will be attempted and another call to the method is made
710 with its result. This can be either granted / denied or no judgement
711 (the guest component chose for whatever reason to not make a decision).
712 In case there is a problem with the guest authentication module (e.g.
713 the Additions are not installed or not running or the guest did not
714 respond within a timeout), the "not reacted" status will be
715 returned.</para>
716 </sect2>
717 </sect1>
718
719 <sect1>
720 <title>Advanced storage configuration</title>
721
722 <sect2 id="rawdisk">
723 <title>Using a raw host hard disk from a guest</title>
724
725 <para>Starting with version 1.4, as an alternative to using virtual disk
726 images (as described in detail in <xref linkend="storage" />),
727 VirtualBox can also present either entire physical hard disks or
728 selected partitions thereof as virtual disks to virtual machines.</para>
729
730 <para>With VirtualBox, this type of access is called "raw hard disk
731 access"; it allows a guest operating system to access its virtual hard
732 disk without going through the host OS file system. The actual
733 performance difference for image files vs. raw disk varies greatly
734 depending on the overhead of the host file system, whether dynamically
735 growing images are used and on host OS caching strategies. The caching
736 indirectly also affects other aspects such as failure behavior, i.e.
737 whether the virtual disk contains all data written before a host OS
738 crash. Consult your host OS documentation for details on this.</para>
739
740 <para><warning>
741 <para>Raw hard disk access is for expert users only. Incorrect use
742 or use of an outdated configuration can lead to <emphasis
743 role="bold">total loss of data </emphasis>on the physical disk. Most
744 importantly, <emphasis>do not</emphasis> attempt to boot the
745 partition with the currently running host operating system in a
746 guest. This will lead to severe data corruption.</para>
747 </warning></para>
748
749 <para>Raw hard disk access -- both for entire disks and individual
750 partitions -- is implemented as part of the VMDK image format support.
751 As a result, you will need to create a special VMDK image file which
752 defines where the data will be stored. After creating such a special
753 VMDK image, you can use it like a regular virtual disk image. For
754 example, you can use the Virtual Media Manager (<xref linkend="vdis" />)
755 or <computeroutput>VBoxManage</computeroutput> to assign the image to a
756 virtual machine.</para>
757
758 <sect3>
759 <title>Access to entire physical hard disk</title>
760
761 <para>While this variant is the simplest to set up, you must be aware
762 that this will give a guest operating system direct and full access to
763 an <emphasis>entire physical disk</emphasis>. If your
764 <emphasis>host</emphasis> operating system is also booted from this
765 disk, please take special care to not access the partition from the
766 guest at all. On the positive side, the physical disk can be
767 repartitioned in arbitrary ways without having to recreate the image
768 file that gives access to the raw disk.</para>
769
770 <para>To create an image that represents an entire physical hard disk
771 (which will not contain any actual data, as this will all be stored on
772 the physical disk), on a Linux host, use the command<screen>VBoxManage internalcommands createrawvmdk -filename /path/to/file.vmdk
773 -rawdisk /dev/sda</screen>This creates the image
774 <code>/path/to/file.vmdk</code> (must be absolute), and all data will
775 be read and written from <code>/dev/sda</code>.</para>
776
777 <para>On a Windows host, instead of the above device specification,
778 use e.g. <code>\\.\PhysicalDrive0</code>. On a Mac OS X host, instead
779 of the above device specification use e.g. <code>/dev/disk1</code>.
780 Note that on OS X you can only get access to an entire disk if no
781 volume is mounted from it.</para>
782
783 <para>Creating the image requires read/write access for the given
784 device. Read/write access is also later needed when using the image
785 from a virtual machine.</para>
786
787 <para>Just like with regular disk images, this does not automatically
788 register the newly created image in the internal registry of hard
789 disks. If you want this done automatically, add
790 <code>-register</code>: <screen>VBoxManage internalcommands createrawvmdk -filename /path/to/file.vmdk
791 -rawdisk /dev/sda -register</screen>After registering, you can assign
792 the newly created image to a virtual machine with e.g. <screen>VBoxManage storageattach WindowsXP --storagectl "IDE Controller"
793 --port 0 --device 0 --type hdd --medium /path/to/file.vmdk</screen>When
794 this is done the selected virtual machine will boot from the specified
795 physical disk.</para>
796 </sect3>
797
798 <sect3>
799 <title>Access to individual physical hard disk partitions</title>
800
801 <para>This "raw partition support" is quite similar to the "full hard
802 disk" access described above. However, in this case, any partitioning
803 information will be stored inside the VMDK image, so you can e.g.
804 install a different boot loader in the virtual hard disk without
805 affecting the host's partitioning information. While the guest will be
806 able to <emphasis>see</emphasis> all partitions that exist on the
807 physical disk, access will be filtered in that reading from partitions
808 for which no access is allowed the partitions will only yield zeroes,
809 and all writes to them are ignored.</para>
810
811 <para>To create a special image for raw partition support (which will
812 contain a small amount of data, as already mentioned), on a Linux
813 host, use the command<screen>VBoxManage internalcommands createrawvmdk -filename /path/to/file.vmdk
814 -rawdisk /dev/sda -partitions 1,5</screen></para>
815
816 <para>As you can see, the command is identical to the one for "full
817 hard disk" access, except for the additional
818 <computeroutput>-partitions</computeroutput> parameter. This example
819 would create the image <code>/path/to/file.vmdk</code> (which, again,
820 must be absolute), and partitions 1 and 5 of <code>/dev/sda</code>
821 would be made accessible to the guest.</para>
822
823 <para>VirtualBox uses the same partition numbering as your Linux host.
824 As a result, the numbers given in the above example would refer to the
825 first primary partition and the first logical drive in the extended
826 partition, respectively.</para>
827
828 <para>On a Windows host, instead of the above device specification,
829 use e.g. <code>\\.\PhysicalDrive0</code>. On a Mac OS X host, instead
830 of the above device specification use e.g. <code>/dev/disk1</code>.
831 Note that on OS X you can only use partitions which are not mounted
832 (eject the respective volume first). Partition numbers are the same on
833 Linux, Windows and Mac OS X hosts.</para>
834
835 <para>The numbers for the list of partitions can be taken from the
836 output of<screen>VBoxManage internalcommands listpartitions -rawdisk /dev/sda</screen>The
837 output lists the partition types and sizes to give the user enough
838 information to identify the partitions necessary for the guest.</para>
839
840 <para>Images which give access to individual partitions are specific
841 to a particular host disk setup. You cannot transfer these images to
842 another host; also, whenever the host partitioning changes, the image
843 <emphasis>must be recreated</emphasis>.</para>
844
845 <para>Creating the image requires read/write access for the given
846 device. Read/write access is also later needed when using the image
847 from a virtual machine. If this is not feasible, there is a special
848 variant for raw partition access (currently only available on Linux
849 hosts) that avoids having to give the current user access to the
850 entire disk. To set up such an image, use<screen>VBoxManage internalcommands createrawvmdk -filename /path/to/file.vmdk
851 -rawdisk /dev/sda -partitions 1,5 -relative</screen>When used from a
852 virtual machine, the image will then refer not to the entire disk, but
853 only to the individual partitions (in the example
854 <code>/dev/sda1</code> and <code>/dev/sda5</code>). As a consequence,
855 read/write access is only required for the affected partitions, not
856 for the entire disk. During creation however, read-only access to the
857 entire disk is required to obtain the partitioning information.</para>
858
859 <para>In some configurations it may be necessary to change the MBR
860 code of the created image, e.g. to replace the Linux boot loader that
861 is used on the host by another boot loader. This allows e.g. the guest
862 to boot directly to Windows, while the host boots Linux from the
863 "same" disk. For this purpose the
864 <computeroutput>-mbr</computeroutput> parameter is provided. It
865 specifies a file name from which to take the MBR code. The partition
866 table is not modified at all, so a MBR file from a system with totally
867 different partitioning can be used. An example of this is<screen>VBoxManage internalcommands createrawvmdk -filename /path/to/file.vmdk
868 -rawdisk /dev/sda -partitions 1,5 -mbr winxp.mbr</screen>The modified
869 MBR will be stored inside the image, not on the host disk.</para>
870
871 <para>For each of the above variants, you can register the resulting
872 image for immediate use in VirtualBox by adding
873 <computeroutput>-register</computeroutput> to the respective command
874 line. The image will then immediately appear in the list of registered
875 disk images. An example is<screen>VBoxManage internalcommands createrawvmdk -filename /path/to/file.vmdk
876 -rawdisk /dev/sda -partitions 1,5 -relative -register</screen> which
877 creates an image referring to individual partitions, and registers it
878 when the image is successfully created.</para>
879 </sect3>
880 </sect2>
881
882 <sect2 id="changevpd">
883 <title>Configuring the hard disk vendor product data (VPD)</title>
884
885 <para>VirtualBox reports vendor product data for its virtual hard disks
886 which consist of hard disk serial number, firmware revision and model
887 number. These can be changed using the following commands:</para>
888
889 <screen>VBoxManage setextradata "VM name"
890 "VBoxInternal/Devices/ahci/0/Config/Port0/SerialNumber" "serial"
891VBoxManage setextradata "VM name"
892 "VBoxInternal/Devices/ahci/0/Config/Port0/FirmwareRevision" "firmware"
893VBoxManage setextradata "VM name"
894 "VBoxInternal/Devices/ahci/0/Config/Port0/ModelNumber" "model"</screen>
895
896 <para>The serial number is a 20 byte alphanumeric string, the firmware
897 revision an 8 byte alphanumeric string and the model number a 40 byte
898 alphanumeric string. Instead of "Port0" (referring to the first port),
899 specify the desired SATA hard disk port.</para>
900
901 <para>Additional three parameters are needed for CD/DVD drives to report
902 the vendor product data:</para>
903
904 <screen>VBoxManage setextradata "VM name"
905 "VBoxInternal/Devices/ahci/0/Config/Port0/ATAPIVendorId" "vendor"
906VBoxManage setextradata "VM name"
907 "VBoxInternal/Devices/ahci/0/Config/Port0/ATAPIProductId" "product"
908VBoxManage setextradata "VM name"
909 "VBoxInternal/Devices/ahci/0/Config/Port0/ATAPIRevision" "revision"</screen>
910
911 <para>The vendor id is an 8 byte alphanumeric string, the product id an
912 16 byte alphanumeric string and the revision a 4 byte alphanumeric
913 string. Instead of "Port0" (referring to the first port), specify the
914 desired SATA hard disk port.</para>
915 </sect2>
916 </sect1>
917
918 <sect1>
919 <title>Launching more than 120 VMs on Solaris hosts</title>
920
921 <para>Solaris hosts have a fixed number of IPC semaphores IDs per process
922 preventing users from starting more than 120 VMs. While trying to launch
923 more VMs you would be shown a "Cannot create IPC semaphore" error.</para>
924
925 <para>In order to run more VMs, you will need to bump the semaphore ID
926 limit of the VBoxSVC process. Execute as root the
927 <computeroutput>prctl</computeroutput> command as shown below. The process
928 ID of VBoxSVC can be obtained using the
929 <computeroutput>ps</computeroutput> list command.</para>
930
931 <para><screen>prctl -r -n project.max-sem-ids -v 2048 &lt;pid-of-VBoxSVC&gt;</screen></para>
932 </sect1>
933
934 <sect1>
935 <title>Legacy commands for using serial ports</title>
936
937 <para>Starting with version 1.4, VirtualBox provided support for virtual
938 serial ports, which, at the time, was rather complicated to set up with a
939 sequence of <computeroutput>VBoxManage setextradata</computeroutput>
940 statements. Since version 1.5, that way of setting up serial ports is no
941 longer necessary and <emphasis>deprecated.</emphasis> To set up virtual
942 serial ports, use the methods now described in <xref
943 linkend="serialports" />.<note>
944 <para>For backwards compatibility, the old
945 <computeroutput>setextradata</computeroutput> statements, whose
946 description is retained below from the old version of the manual, take
947 <emphasis>precedence</emphasis> over the new way of configuring serial
948 ports. As a result, if configuring serial ports the new way doesn't
949 work, make sure the VM in question does not have old configuration
950 data such as below still active.</para>
951 </note></para>
952
953 <para>The old sequence of configuring a serial port used the following 6
954 commands:</para><screen>VBoxManage setextradata "VM name"
955 "VBoxInternal/Devices/serial/0/Config/IRQ" 4
956VBoxManage setextradata "VM name"
957 "VBoxInternal/Devices/serial/0/Config/IOBase" 0x3f8
958VBoxManage setextradata "VM name"
959 "VBoxInternal/Devices/serial/0/LUN#0/Driver" Char
960VBoxManage setextradata "VM name"
961 "VBoxInternal/Devices/serial/0/LUN#0/AttachedDriver/Driver" NamedPipe
962VBoxManage setextradata "VM name"
963 "VBoxInternal/Devices/serial/0/LUN#0/AttachedDriver/Config/Location" "\\.\pipe\vboxCOM1"
964VBoxManage setextradata "VM name"
965 "VBoxInternal/Devices/serial/0/LUN#0/AttachedDriver/Config/IsServer" 1</screen>
966 <para>This sets up a serial port in the guest with the default
967 settings for COM1 (IRQ 4, I/O address 0x3f8) and the
968 <computeroutput>Location</computeroutput> setting assumes that this
969 configuration is used on a Windows host, because the Windows named pipe
970 syntax is used. Keep in mind that on Windows hosts a named pipe must
971 always start with <computeroutput>\\.\pipe\</computeroutput>. On Linux the
972 same config settings apply, except that the path name for the
973 <computeroutput>Location</computeroutput> can be chosen more freely. Local
974 domain sockets can be placed anywhere, provided the user running
975 VirtualBox has the permission to create a new file in the directory. The
976 final command above defines that VirtualBox acts as a server, i.e. it
977 creates the named pipe itself instead of connecting to an already existing
978 one.</para>
979 </sect1>
980
981 <sect1 id="changenat">
982 <title>Fine-tuning the VirtualBox NAT engine</title>
983
984 <sect2>
985 <title>Configuring the address of a NAT network interface</title>
986
987 <para>In NAT mode, the guest network interface is assigned to the IPv4
988 range <computeroutput>10.0.x.0/24</computeroutput> by default where
989 <computeroutput>x</computeroutput> corresponds to the instance of the
990 NAT interface +2. So <computeroutput>x</computeroutput> is 2 when there
991 is only one NAT instance active. In that case the guest is assigned to
992 the address <computeroutput>10.0.2.15</computeroutput>, the gateway is
993 set to <computeroutput>10.0.2.2</computeroutput> and the name server can
994 be found at <computeroutput>10.0.2.3</computeroutput>.</para>
995
996 <para>If, for any reason, the NAT network needs to be changed, this can
997 be achieved with the following command:</para>
998
999 <screen>VBoxManage modifyvm "VM name" --natnet1 "192.168/16"</screen>
1000
1001 <para>This command would reserve the network addresses from
1002 <computeroutput>192.168.0.0</computeroutput> to
1003 <computeroutput>192.168.254.254</computeroutput> for the first NAT
1004 network instance of "VM name". The guest IP would be assigned to
1005 <computeroutput>192.168.0.15</computeroutput> and the default gateway
1006 could be found at <computeroutput>192.168.0.2</computeroutput>.</para>
1007 </sect2>
1008
1009 <sect2 id="nat-adv-tftp">
1010 <title>Configuring the boot server (next server) of a NAT network
1011 interface</title>
1012
1013 <para>For network booting in NAT mode, by default VirtualBox uses a
1014 built-in TFTP server at the IP address 10.0.2.3. This default behavior
1015 should work fine for typical remote-booting scenarios. However, it is
1016 possible to change the boot server IP and the location of the boot image
1017 with the following commands: <screen>VBoxManage modifyvm "VM name" --nattftpserver1 10.0.2.2
1018VBoxManage modifyvm "VM name" --nattftpfile1 /srv/tftp/boot/MyPXEBoot.pxe</screen></para>
1019 </sect2>
1020
1021 <sect2 id="nat-adv-settings">
1022 <title>Tuning TCP/IP buffers for NAT</title>
1023
1024 <para>The VirtualBox NAT stack performance is often determined by its
1025 interaction with the host's TCP/IP stack and the size of several buffers
1026 (<computeroutput>SO_RCVBUF</computeroutput> and
1027 <computeroutput>SO_SNDBUF</computeroutput>). For certain setups users
1028 might want to adjust the buffer size for a better performance. This can
1029 by achieved using the following commands (values are in kilobytes and
1030 can range from 8 to 1024): <screen>VBoxManage modifyvm "VM name" --natsettings1 16000,128,128,0,0</screen>
1031 This example illustrates tuning the NAT settings. The first parameter is
1032 the MTU, then the size of the socket's send buffer and the size of the
1033 socket's receive buffer, the initial size of the TCP send window, and
1034 lastly the initial size of the TCP receive window. Note that specifying
1035 zero means fallback to the default value.</para>
1036
1037 <para>Each of these buffers has a default size of 64KB and default MTU
1038 is 1500.</para>
1039 </sect2>
1040
1041 <sect2>
1042 <title>Binding NAT sockets to a specific interface</title>
1043
1044 <para>By default, VirtualBox's NAT engine will route TCP/IP packets
1045 through the default interface assigned by the host's TCP/IP stack. (The
1046 technical reason for this is that the NAT engine uses sockets for
1047 communication.) If, for some reason, you want to change this behavior,
1048 you can tell the NAT engine to bind to a particular IP address instead.
1049 Use the following command: <screen>VBoxManage modifyvm "VM name" --natbindip1 "10.45.0.2"</screen></para>
1050
1051 <para>After this, all outgoing traffic will be sent through the
1052 interface with the IP address 10.45.0.2. Please make sure that this
1053 interface is up and running prior to this assignment.</para>
1054 </sect2>
1055
1056 <sect2 id="nat-adv-dns">
1057 <title>Enabling DNS proxy in NAT mode</title>
1058
1059 <para>The NAT engine by default offers the same DNS servers to the guest
1060 that are configured on the host. In some scenarios, it can be desirable
1061 to hide the DNS server IPs from the guest, for example when this
1062 information can change on the host due to expiring DHCP leases. In this
1063 case, you can tell the NAT engine to act as DNS proxy using the
1064 following command: <screen>VBoxManage modifyvm "VM name" --natdnsproxy1 on</screen></para>
1065 </sect2>
1066
1067 <sect2 id="nat_host_resolver_proxy">
1068 <title>Using the host's resolver as a DNS proxy in NAT mode</title>
1069
1070 <para>For resolving network names, the DHCP server of the NAT engine
1071 offers a list of registered DNS servers of the host. If for some reason
1072 you need to hide this DNS server list and use the host's resolver
1073 settings, thereby forcing the VirtualBox NAT engine to intercept DNS
1074 requests and forward them to host's resolver, use the following command:
1075 <screen>VBoxManage modifyvm "VM name" --natdnshostresolver1 on</screen>
1076 Note that this setting is similar to the DNS proxy mode, however whereas
1077 the proxy mode just forwards DNS requests to the appropriate servers,
1078 the resolver mode will interpret the DNS requests and use the host's DNS
1079 API to query the information and return it to the guest.</para>
1080 </sect2>
1081
1082 <sect2 id="nat-adv-alias">
1083 <title>Configuring aliasing of the NAT engine</title>
1084
1085 <para>By default, the NAT core uses aliasing and uses random ports when
1086 generating an alias for a connection. This works well for the most
1087 protocols like SSH, FTP and so on. Though some protocols might need a
1088 more transparent behavior or may depend on the real port number the
1089 packet was sent from. It is possible to change the NAT mode via the
1090 VBoxManage frontend with the following commands: <screen>VBoxManage modifyvm "VM name" --nataliasmode proxyonly</screen>
1091 and <screen>VBoxManage modifyvm "Linux Guest" --nataliasmode sameports</screen>
1092 The first example disables aliasing and switches NAT into transparent
1093 mode, the second example enforces preserving of port values. These modes
1094 can be combined if necessary.</para>
1095 </sect2>
1096 </sect1>
1097
1098 <sect1 id="changedmi">
1099 <title>Configuring the BIOS DMI information</title>
1100
1101 <para>The DMI data VirtualBox provides to guests can be changed for a
1102 specific VM. Use the following commands to configure the DMI BIOS
1103 information:</para>
1104
1105 <screen>VBoxManage setextradata "VM name"
1106 "VBoxInternal/Devices/pcbios/0/Config/DmiBIOSVendor" "BIOS Vendor"
1107VBoxManage setextradata "VM name"
1108 "VBoxInternal/Devices/pcbios/0/Config/DmiBIOSVersion" "BIOS Version"
1109VBoxManage setextradata "VM name"
1110 "VBoxInternal/Devices/pcbios/0/Config/DmiBIOSReleaseDate" "BIOS Release Date"
1111VBoxManage setextradata "VM name"
1112 "VBoxInternal/Devices/pcbios/0/Config/DmiBIOSReleaseMajor" 1
1113VBoxManage setextradata "VM name"
1114 "VBoxInternal/Devices/pcbios/0/Config/DmiBIOSReleaseMinor" 2
1115VBoxManage setextradata "VM name"
1116 "VBoxInternal/Devices/pcbios/0/Config/DmiBIOSFirmwareMajor" 3
1117VBoxManage setextradata "VM name"
1118 "VBoxInternal/Devices/pcbios/0/Config/DmiBIOSFirmwareMinor" 4
1119VBoxManage setextradata "VM name"
1120 "VBoxInternal/Devices/pcbios/0/Config/DmiSystemVendor" "System Vendor"
1121VBoxManage setextradata "VM name"
1122 "VBoxInternal/Devices/pcbios/0/Config/DmiSystemProduct" "System Product"
1123VBoxManage setextradata "VM name"
1124 "VBoxInternal/Devices/pcbios/0/Config/DmiSystemVersion" "System Version"
1125VBoxManage setextradata "VM name"
1126 "VBoxInternal/Devices/pcbios/0/Config/DmiSystemSerial" "System Serial"
1127VBoxManage setextradata "VM name"
1128 "VBoxInternal/Devices/pcbios/0/Config/DmiSystemSKU" "System SKU"
1129VBoxManage setextradata "VM name"
1130 "VBoxInternal/Devices/pcbios/0/Config/DmiSystemFamily" "System Family"
1131VBoxManage setextradata "VM name"
1132 "VBoxInternal/Devices/pcbios/0/Config/DmiSystemUuid"
1133 "9852bf98-b83c-49db-a8de-182c42c7226b"</screen>
1134
1135 <para>If a DMI string is not set, the default value of VirtualBox is used.
1136 To set an empty string use
1137 <computeroutput>"&lt;EMPTY&gt;"</computeroutput>.</para>
1138
1139 <para>Note that in the above list, all quoted parameters (DmiBIOSVendor,
1140 DmiBIOSVersion but not DmiBIOSReleaseMajor) are expected to be strings. If
1141 such a string is a valid number, the parameter is treated as number and
1142 the VM will most probably refuse to start with an
1143 <computeroutput>VERR_CFGM_NOT_STRING</computeroutput> error. In that case,
1144 use <computeroutput>"string:&lt;value&gt;"</computeroutput>, for instance
1145 <screen>VBoxManage setextradata "VM name"
1146 "VBoxInternal/Devices/pcbios/0/Config/DmiSystemSerial" "string:1234"</screen></para>
1147
1148 <para>Changing this information can be necessary to provide the DMI
1149 information of the host to the guest to prevent Windows from asking for a
1150 new product key. On Linux hosts the DMI BIOS information can be obtained
1151 with <screen>dmidecode -t0</screen>and the DMI system information can be
1152 obtained with <screen>dmidecode -t1</screen></para>
1153 </sect1>
1154
1155 <sect1>
1156 <title>Fine-tuning timers and time synchronization</title>
1157
1158 <sect2 id="changetscmode">
1159 <title>Configuring the guest time stamp counter (TSC) to reflect guest
1160 execution</title>
1161
1162 <para>By default, VirtualBox keeps all sources of time visible to the
1163 guest synchronized to a single time source, the monotonic host time.
1164 This reflects the assumptions of many guest operating systems, which
1165 expect all time sources to reflect "wall clock" time. In special
1166 circumstances it may be useful however to make the TSC (time stamp
1167 counter) in the guest reflect the time actually spent executing the
1168 guest.</para>
1169
1170 <para>This special TSC handling mode can be enabled on a per-VM basis,
1171 and for best results must be used only in combination with hardware
1172 virtualization. To enable this mode use the following command:</para>
1173
1174 <screen>VBoxManage setextradata "VM name" "VBoxInternal/TM/TSCTiedToExecution" 1</screen>
1175
1176 <para>To revert to the default TSC handling mode use:</para>
1177
1178 <screen>VBoxManage setextradata "VM name" "VBoxInternal/TM/TSCTiedToExecution"</screen>
1179
1180 <para>Note that if you use the special TSC handling mode with a guest
1181 operating system which is very strict about the consistency of time
1182 sources you may get a warning or error message about the timing
1183 inconsistency. It may also cause clocks to become unreliable with some
1184 guest operating systems depending on they use the TSC.</para>
1185 </sect2>
1186
1187 <sect2 id="warpguest">
1188 <title>Accelerate or slow down the guest clock</title>
1189
1190 <para>For certain purposes it can be useful to accelerate or to slow
1191 down the (virtual) guest clock. This can be achieved as follows:</para>
1192
1193 <screen>VBoxManage setextradata "VM name" "VBoxInternal/TM/WarpDrivePercentage" 200</screen>
1194
1195 <para>The above example will double the speed of the guest clock
1196 while</para>
1197
1198 <screen>VBoxManage setextradata "VM name" "VBoxInternal/TM/WarpDrivePercentage" 50</screen>
1199
1200 <para>will halve the speed of the guest clock. Note that changing the
1201 rate of the virtual clock can confuse the guest and can even lead to
1202 abnormal guest behavior. For instance, a higher clock rate means shorter
1203 timeouts for virtual devices with the result that a slightly increased
1204 response time of a virtual device due to an increased host load can
1205 cause guest failures. Note further that any time synchronization
1206 mechanism will frequently try to resynchronize the guest clock with the
1207 reference clock (which is the host clock if the VirtualBox Guest
1208 Additions are active). Therefore any time synchronization should be
1209 disabled if the rate of the guest clock is changed as described above
1210 (see <xref linkend="changetimesync" />).</para>
1211 </sect2>
1212
1213 <sect2 id="changetimesync">
1214 <title>Tuning the Guest Additions time synchronization
1215 parameters</title>
1216
1217 <para>The VirtualBox Guest Additions ensure that the guest's system time
1218 is synchronized with the host time. There are several parameters which
1219 can be tuned. The parameters can be set for a specific VM using the
1220 following command:</para>
1221
1222 <screen>VBoxManage guestproperty set VM_NAME "/VirtualBox/GuestAdd/VBoxService/PARAMETER" VALUE</screen>
1223
1224 <para>where <computeroutput>PARAMETER</computeroutput> is one of the
1225 following:</para>
1226
1227 <para><glosslist>
1228 <glossentry>
1229 <glossterm><computeroutput>--timesync-interval</computeroutput></glossterm>
1230
1231 <glossdef>
1232 <para>Specifies the interval at which to synchronize the time
1233 with the host. The default is 10000 ms (10 seconds).</para>
1234 </glossdef>
1235 </glossentry>
1236
1237 <glossentry>
1238 <glossterm><computeroutput>--timesync-min-adjust</computeroutput></glossterm>
1239
1240 <glossdef>
1241 <para>The minimum absolute drift value measured in milliseconds
1242 to make adjustments for. The default is 1000 ms on OS/2 and 100
1243 ms elsewhere.</para>
1244 </glossdef>
1245 </glossentry>
1246
1247 <glossentry>
1248 <glossterm><computeroutput>--timesync-latency-factor</computeroutput></glossterm>
1249
1250 <glossdef>
1251 <para>The factor to multiply the time query latency with to
1252 calculate the dynamic minimum adjust time. The default is 8
1253 times, that means in detail: Measure the time it takes to
1254 determine the host time (the guest has to contact the VM host
1255 service which may take some time), multiply this value by 8 and
1256 do an adjustment only if the time difference between host and
1257 guest is bigger than this value. Don't do any time adjustment
1258 otherwise.</para>
1259 </glossdef>
1260 </glossentry>
1261
1262 <glossentry>
1263 <glossterm><computeroutput>--timesync-max-latency</computeroutput></glossterm>
1264
1265 <glossdef>
1266 <para>The max host timer query latency to accept. The default is
1267 250 ms.</para>
1268 </glossdef>
1269 </glossentry>
1270
1271 <glossentry>
1272 <glossterm><computeroutput>--timesync-set-threshold</computeroutput></glossterm>
1273
1274 <glossdef>
1275 <para>The absolute drift threshold, given as milliseconds where
1276 to start setting the time instead of trying to smoothly adjust
1277 it. The default is 20 minutes.</para>
1278 </glossdef>
1279 </glossentry>
1280
1281 <glossentry>
1282 <glossterm><computeroutput>--timesync-set-start</computeroutput></glossterm>
1283
1284 <glossdef>
1285 <para>Set the time when starting the time sync service.</para>
1286 </glossdef>
1287 </glossentry>
1288
1289 <glossentry>
1290 <glossterm><computeroutput>--timesync-set-on-restore 0|1</computeroutput></glossterm>
1291
1292 <glossdef>
1293 <para>Set the time after the VM was restored from a saved state
1294 when passing 1 as parameter (default). Disable by passing 0.
1295 In the latter case, the time will be adjusted smoothly which
1296 can take a long time.</para>
1297 </glossdef>
1298 </glossentry>
1299 </glosslist></para>
1300
1301 <para>All these parameters can be specified as command line parameters
1302 to VBoxService as well.</para>
1303 </sect2>
1304 </sect1>
1305
1306 <sect1 id="addhostonlysolaris">
1307 <title>Configuring multiple host-only network interfaces on Solaris
1308 hosts</title>
1309
1310 <para>By default VirtualBox provides you with one host-only network
1311 interface. Adding more host-only network interfaces on Solaris hosts
1312 requires manual configuration. Here's how to add two more host-only
1313 network interfaces.</para>
1314
1315 <para>You first need to stop all running VMs and unplumb all existing
1316 "vboxnet" interfaces. Execute the following commands as root:</para>
1317
1318 <screen>ifconfig vboxnet0 unplumb</screen>
1319
1320 <para>Once you make sure all vboxnet interfaces are unplumbed, remove the
1321 driver using:</para>
1322
1323 <para><screen>rem_drv vboxnet</screen>then edit the file
1324 <computeroutput>/platform/i86pc/kernel/drv/vboxnet.conf</computeroutput>
1325 and add a line for the new interfaces:</para>
1326
1327 <para><screen>name="vboxnet" parent="pseudo" instance=1;
1328name="vboxnet" parent="pseudo" instance=2;</screen>Add as many of these lines
1329 as required and make sure "instance" number is uniquely incremented. Next
1330 reload the vboxnet driver using:</para>
1331
1332 <para><screen>add_drv vboxnet</screen>Now plumb all the interfaces using
1333 <computeroutput>ifconfig vboxnetX plumb</computeroutput> (where X can be
1334 0, 1 or 2 in this case) and once plumbed you can then configure the
1335 interface like any other network interface.</para>
1336
1337 <para>To make your newly added interfaces' settings persistent across
1338 reboots you will need to edit the files
1339 <computeroutput>/etc/netmasks</computeroutput>, and if you are using NWAM
1340 <computeroutput>/etc/nwam/llp</computeroutput> and add the appropriate
1341 entries to set the netmask and static IP for each of those interfaces. The
1342 VirtualBox installer only updates these configuration files for the one
1343 "vboxnet0" interface it creates by default.</para>
1344 </sect1>
1345
1346 <sect1 id="solariscodedumper">
1347 <title>Configuring VirtualBox CoreDumper on Solaris hosts</title>
1348
1349 <para>VirtualBox is capable of producing its own core files when things go
1350 wrong and for more extensive debugging. Currently this is only available
1351 on Solaris hosts.</para>
1352
1353 <para>The VirtualBox CoreDumper can be enabled using the following
1354 command:</para>
1355
1356 <para><screen>VBoxManage setextradata "VM name" VBoxInternal2/CoreDumpEnabled 1</screen></para>
1357
1358 <para>You can specify which directory to use for core dumps with this
1359 command:</para>
1360
1361 <para><screen>VBoxManage setextradata "VM name" VBoxInternal2/CoreDumpDir &lt;path-to-directory&gt;</screen>Make
1362 sure the directory you specify is on a volume with sufficient free space
1363 and that the VirtualBox process has sufficient permissions to write files
1364 to this directory. If you skip this command and don't specify any core
1365 dump directory, the current directory of the VirtualBox executable will be
1366 used (which would most likely fail when writing cores as they are
1367 protected with root permissions). It is recommended you explicity set a
1368 core dump directory.</para>
1369
1370 <para>You must specify when the VirtualBox CoreDumper should be triggered.
1371 This is done using the following commands:</para>
1372
1373 <para><screen>VBoxManage setextradata "VM name" VBoxInternal2/CoreDumpReplaceSystemDump 1
1374VBoxManage setextradata "VM name" VBoxInternal2/CoreDumpLive 1</screen>At
1375 least one of the above two commands will have to be provided if you have
1376 enabled the VirtualBox CoreDumper.</para>
1377
1378 <para>Setting <computeroutput>CoreDumpReplaceSystemDump</computeroutput>
1379 sets up the VM to override the host's core dumping mechanism and in the
1380 event of any crash only the VirtualBox CoreDumper would produce the core
1381 file.</para>
1382
1383 <para>Setting <computeroutput>CoreDumpLive</computeroutput> sets up the VM
1384 to produce cores whenever the VM receives a
1385 <computeroutput>SIGUSR2</computeroutput> signal. After producing the core
1386 file, the VM will not be terminated and will continue to run. You can then
1387 take cores of the VM process using:</para>
1388
1389 <para><screen>kill -s SIGUSR2 &lt;VM-process-id&gt;</screen></para>
1390
1391 <para>Core files produced by the VirtualBox CoreDumper are of the form
1392 <computeroutput>core.vb.&lt;ProcessName&gt;.&lt;ProcessID&gt;</computeroutput>,
1393 e.g.<computeroutput>core.vb.VBoxHeadless.11321</computeroutput>.</para>
1394 </sect1>
1395
1396 <sect1 id="guitweaks">
1397 <title>Locking down the GUI</title>
1398
1399 <para>There are several advanced customization settings for locking down
1400 the GUI, that is, removing some features that the user should not
1401 see.<screen>VBoxManage setextradata global GUI/Customizations OPTION[,OPTION...]</screen></para>
1402
1403 <para>where <computeroutput>OPTION</computeroutput> is one of the
1404 following keywords:<glosslist>
1405 <glossentry>
1406 <glossterm><computeroutput>noSelector</computeroutput></glossterm>
1407
1408 <glossdef>
1409 <para>Don't allow to start the VM selector GUI. Trying to do so
1410 will show a window containing a proper error message.</para>
1411 </glossdef>
1412 </glossentry>
1413
1414 <glossentry>
1415 <glossterm><computeroutput>noMenuBar</computeroutput></glossterm>
1416
1417 <glossdef>
1418 <para>The VM windows will not contain a menu bar.</para>
1419 </glossdef>
1420 </glossentry>
1421
1422 <glossentry>
1423 <glossterm><computeroutput>noStatusBar</computeroutput></glossterm>
1424
1425 <glossdef>
1426 <para>The VM windows will not contain a status bar.</para>
1427 </glossdef>
1428 </glossentry>
1429 </glosslist></para>
1430
1431 <para>To disable any GUI customization do <screen>VBoxManage setextradata global GUI/Customizations</screen></para>
1432
1433 <para>To disable all host key combinations, open the global settings and
1434 change the host key to <emphasis>None</emphasis>. This might be useful
1435 when using VirtualBox in a kiosk mode.</para>
1436
1437 <para>Furthermore, you can disallow certain actions when terminating a VM
1438 from the GUI. To disallow specific actions, type:</para>
1439
1440 <para><screen>VBoxManage setextradata "VM name" GUI/RestrictedCloseActions OPTION[,OPTION...]</screen></para>
1441
1442 <para>where <computeroutput>OPTION</computeroutput> is one of the
1443 following keywords:<glosslist>
1444 <glossentry>
1445 <glossterm><computeroutput>SaveState</computeroutput></glossterm>
1446
1447 <glossdef>
1448 <para>Don't allow the user to save the VM state plus terminate the
1449 VM.</para>
1450 </glossdef>
1451 </glossentry>
1452
1453 <glossentry>
1454 <glossterm><computeroutput>Shutdown</computeroutput></glossterm>
1455
1456 <glossdef>
1457 <para>Don't allow the user to shutdown the VM by sending the ACPI
1458 power off event to the guest.</para>
1459 </glossdef>
1460 </glossentry>
1461
1462 <glossentry>
1463 <glossterm><computeroutput>PowerOff</computeroutput></glossterm>
1464
1465 <glossdef>
1466 <para>Don't allow the user to power off the VM.</para>
1467 </glossdef>
1468 </glossentry>
1469
1470 <glossentry>
1471 <glossterm><computeroutput>Restore</computeroutput></glossterm>
1472
1473 <glossdef>
1474 <para>Don't allow the user to return to the last snapshot when
1475 powering off the VM.</para>
1476 </glossdef>
1477 </glossentry>
1478 </glosslist></para>
1479
1480 <para>Combinations of all of these options are allowed. If all options are
1481 specified, the VM cannot be shut down from the GUI.</para>
1482 </sect1>
1483
1484 <sect1 id="vboxwebsrv-daemon">
1485 <title>Starting <computeroutput>vboxwebsrv</computeroutput>
1486 automatically</title>
1487
1488 <para><computeroutput>vboxwebsrv</computeroutput> is used for controlling
1489 VirtualBox remotely. As the client base using this interface is growing,
1490 we added start scripts for the various operation systems we support. The
1491 following describes how to use them. <itemizedlist>
1492 <listitem>
1493 <para>On Mac OS X, launchd is used. An example configuration file
1494 can be found in
1495 <computeroutput>$HOME/Library/LaunchAgents/org.virtualbox.vboxwebsrv.plist</computeroutput>.
1496 It has to be enabled by changing the
1497 <computeroutput>Disabled</computeroutput> key from
1498 <computeroutput>true</computeroutput> to
1499 <computeroutput>false</computeroutput>. To manually start the
1500 service use the following command: <screen>launchctl load ~/Library/LaunchAgents/org.virtualbox.vboxwebsrv.plist</screen>
1501 For additional information on how launchd services could be
1502 configured see <literal><ulink
1503 url="http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPSystemStartup/BPSystemStartup.html">http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPSystemStartup/BPSystemStartup.html</ulink></literal>.</para>
1504 </listitem>
1505 </itemizedlist></para>
1506 </sect1>
1507</chapter>
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette