Skip to content

Instantly share code, notes, and snippets.

@koseki
Last active September 14, 2021 01:18
Show Gist options
  • Save koseki/033a5359eb5ea3842908 to your computer and use it in GitHub Desktop.
Save koseki/033a5359eb5ea3842908 to your computer and use it in GitHub Desktop.
VirtualBox はどこにファイルを保存するか

VirtualBox マニュアルメモ - 10.1. VirutalBox はどこにファイルを保存するか

10.1. Where VirtualBox stores its files

In VirtualBox, a virtual machine and its settings are described in a virtual machine settings file in XML format.

VM の設定は XML 形式で書いてある。

In addition, most virtual machine have one or more virtual hard disks, which are typically represented by disk images (e.g. in VDI format).

加えて、大抵の VM には1つ以上のバーチャルハードディスクがあり、 たいていディスクイメージで表現される (e.g. VDI フォーマット)。

Where all these files are stored depends on which version of VirtualBox created the machine.

VirtualBox のバージョンによって、これらのファイルが保存される場所が違う。

10.1.1. Machines created by VirtualBox version 4.0 or later

Starting with version 4.0, by default, each virtual machine has one directory on your host computer

VirtualBox 4.0 から、各 VM は、ホストマシン上に1つディレクトリを持っている。

where all the files of that machine are stored -- the XML settings file (with a .vbox file extension) and its disk images.

そこには、XML設定ファイル (*.vbox) やディスクイメージといった、VM が格納された全ファイルが入っている。

By default, this "machine folder" is placed in a common folder called "VirtualBox VMs",

デフォルトでは、この マシンフォルダVirtualBox VMs と呼ばれる共通のフォルダの中に入る。

which VirtualBox creates in the current system user's home directory.

VirtualBox はホームディレクトリに VirtualBox VMs フォルダを作る。

The location of this home directory depends on the conventions of the host operating system:

ホスト OS によって、これがどこに作られるか違う。

  • On Windows, this is %HOMEDRIVE%%HOMEPATH%; typically something like C:\Documents and Settings\Username\.
  • On Mac OS X, this is /Users/username.
  • On Linux and Solaris, this is /home/username.

For simplicity, we will abbreviate this as $HOME below. Using that convention, the common folder for all virtual machines is $HOME/VirtualBox VMs.

以降 $HOME として説明する。

As an example, when you create a virtual machine called "Example VM", you will find that VirtualBox creates

"Example VM" を作った場合 VirtualBox が作るのは:

  • the folder $HOME/VirtualBox VMs/Example VM/ and, in that folder,
    • the settings file Example VM.vbox and
    • the virtual disk image Example VM.vdi.

This is the default layout if you use the "Create new virtual machine" wizard as described in Section 1.7, “Creating your first virtual machine”.

ウィザードで VM 作ると上記ファイルができる。

Once you start working with the VM, additional files will show up:

VM を起動すると、追加でファイルができる。

  • you will find log files in a subfolder called Logs,
  • and once you have taken snapshots, they will appear in a Snapshots subfolder.

For each VM, you can change the location of its snapsnots folder in the VM settings.

VM の設定でスナップショットフォルダの場所を変えられる。

You can change the default machine folder by selecting "Preferences" from the "File" menu in the VirtualBox main window. > Then, in the window that pops up, click on the "General" tab.

ファイルメニューの Preferences でマシンフォルダのデフォルトを変えられる。

Alternatively, use VBoxManage setproperty machinefolder; see Section 8.27, “VBoxManage setproperty”.

または VBoxManage setproperty machinefolder で変えられる。

10.1.2. Machines created by VirtualBox versions before 4.0

If you have upgraded to VirtualBox 4.0 from an earlier version of VirtualBox, you probably have settings files and disks in the earlier file system layout.

4.0 以前だと配置が違う。

Before version 4.0, VirtualBox separated the machine settings files from virtual disk images.

バーチャルディスクイメージと、設定ファイルを分けていた。

The machine settings files had an .xml file extension and resided in a folder called "Machines" under the global VirtualBox configuration directory (see the next section).

マシン設定ファイルは .xml 拡張子で、グローバル VirtualBox 設定ディレクトリ (次のセクション参照) 以下の Machines フォルダに保存されていた。

So, for example, on Linux, this was the hidden $HOME/.VirtualBox/Machines directory.

Linux だと $HOME/.VirtualBox/Machines ディレクトリに隠れていた。

The default hard disks folder was called "HardDisks" and resided in the .VirtualBox folder as well.

デフォルトのハードディスクフォルダは、同じように .VirtualBox フォルダの下の HardDisks にあった。

Both locations could be changed by the user in the global preferences.

どちらの場所も、グローバルな設定で変更できた。

(The concept of a "default hard disk folder" has been abandoned with VirtualBox 4.0, since disk images now reside in each machine's folder by default.)

デフォルトハードディスクフォルダというコンセプトは 4.0 から無くなった。ディスクイメージはそれぞれのマシンフォルダに保存されるようになったため。

The old layout had several severe disadvantages.

旧レイアウトには欠点があった。

  1. It was very difficult to move a virtual machine from one host to another

VM をあるホストから別のホストに移動させるのが非常に難しかった。

because the files involved did not reside in the same folder.

関係あるファイルが同じフォルダに入ってなかったから。

In addition, the virtual media of all machines were registered with a global registry in the central VirtualBox settings file ($HOME/.VirtualBox/VirtualBox.xml).

さらに、全マシンのバーチャルメディアが VirtualBox.xml に登録されていた。

To move a machine to another host, it was therefore not enough to move the XML settings file and the disk images (which were in different locations),

マシンを別のホストに動かすには、(別々の場所にある)XML設定ファイルとディスクイメージを引っ越すだけではダメで、

but the hard disk entries from the global media registry XML had to be meticulously copied as well,

グローバルなXML に登録されたハードディスクエントリも細心の注意を払ってコピーする必要があり、

which was close to impossible if the machine had snapshots and therefore differencing images.

マシンがスナップショットを撮っていて、差分のイメージを持っていたりすると不可能に近かった。

  1. Storing virtual disk images, which can grow very large, under the hidden .VirtualBox directory (at least on Linux and Solaris hosts) made many users wonder where their disk space had gone.

巨大なバーチャルディスクイメージが隠しディレクトリ .VirtualBox に入っており、多くのユーザに、どこにディスク容量が消えたのか不審に思わせてしまっていた。

Whereas new VMs created with VirtualBox 4.0 or later will conform to the new layout,

4.0 以降、VirutalBox は新しいレイアウトに従うが、

for maximum compatibility, old VMs are not converted to the new layout.

互換性を極力維持するため、旧VM は新レイアウトに変換されない。

Otherwise machine settings would be irrevocably broken if a user downgraded from 4.0 back to an older version of VirtualBox.

でないと、4.0 から古いバージョンにダウングレードしたときに、マシンの設定が決定的 irrevocably に壊れてしまう。

10.1.3. Global configuration data

In addition to the files of the virtual machines, VirtualBox maintains global configuration data.

VM 関連のファイルに加えて、グローバルな設定データがある。

On Linux and Solaris as of VirtualBox 4.3, this is in the hidden directory $HOME/.config/VirtualBox, although $HOME/.VirtualBox will be used if it exists for compatibility with earlier versions;

Linux / Solaris は VirtualBox 4.3 から、$HOME/.config/VirtualBox ディレクトリに保存される。$HOME/.VirtualBox は旧バージョンの互換性のために使われる。

on Windows (and on Linux and Solaris with VirtualBox 4.2 and earlier) this is in $HOME/.VirtualBox;

Windows (と Linux / Solaris の 4.2 以前) では、$HOME/.VirtualBox ディレクトリが、

on a Mac it resides in $HOME/Library/VirtualBox.

Mac は $HOME/Library/VirtualBox ディレクトリが使われる。

VirtualBox creates this configuration directory automatically if necessary.

VirtualBox はこれらのディレクトリを自動で作る。

Optionally, you can supply an alternate configuration directory by setting the VBOX_USER_HOME environment variable,

VBOX_USER_HOME 環境変数で、このディレクトリを変更できる。

or additionally on Linux or Solaris by using the standard XDG_CONFIG_HOME variable.

または、Linux / Solaris は標準の XDG_CONFIG_HOME 変数も使える。

(Since the global VirtualBox.xml settings file points to all other configuration files, this allows for switching between several VirtualBox configurations entirely.)

(VirtualBox.xml には全部書いてあるので、設定を丸ごとスイッチできる。)

Most importantly, in this directory, VirtualBox stores its global settings file, another XML file called VirtualBox.xml.

このディレクトリには VirtualBox.xml グローバル設定ファイルが保存されている。

This includes global configuration options and the list of registered virtual machines with pointers to their XML settings files.

このファイルにはグローバルな設定と、VM の一覧が XML 設定ファイルへのポインタと一緒に書いてある。

(Neither the location of this file nor its directory has changed with VirtualBox 4.0.)

(4.0 で VirtualBox.xml の場所も名前も変わってない)

Before VirtualBox 4.0, all virtual media (disk image files) were also contained in a global registry in this settings file.

4.0 以前では、全バーチャルメディア (ディスクイメージファイル) がこのファイルのグローバルレジストリに書かれていた。

For compatibility, this media registry still exists if you upgrade VirtualBox and there are media from machines which were created with a version before 4.0.

互換性のため、4.0 にバージョンを上げてもバーチャルメディアの設定は残っている。

If you have no such machines, then there will be no global media registry; with VirtualBox 4.0, each machine XML file has its own media registry.

4.0 からは、マシン XML がメディアレジストリを持っている。

Also before VirtualBox 4.0, the default "Machines" folder and the default "HardDisks" folder resided under the VirtualBox configuration directory

また、4.0 以前では、Machine フォルダと HardDisk フォルダが VirtualBox 設定ディレクトリの下にあった。

(e.g. $HOME/.VirtualBox/Machines on Linux).

Linux の例。

If you are upgrading from a VirtualBox version before 4.0, files in these directories are not automatically moved in order not to break backwards compatibility.

後方互換のため、これらのディレクトリは 4.0 にバージョンアップしても移動されない。

10.1.4. Summary of 4.0 configuration changes

まとめの表。略。

10.1.5. VirtualBox XML files

VirtualBox uses XML for both the machine settings files and the global configuration file, VirtualBox.xml.

VirtualBox は、マシン設定とグローバル設定(VirutalBox.xml) の両方で XML を使っている。

All VirtualBox XML files are versioned.

全 XML ファイルはバージョン管理されている。

When a new settings file is created (e.g. because a new virtual machine is created), VirtualBox automatically uses the settings format of the current VirtualBox version.

(新しい VM を作るなどして) 新しい設定ファイルが作られると、VirtualBox は自動的に今の VirtualBox のバージョンの設定形式を使う。

These files may not be readable if you downgrade to an earlier version of VirtualBox.

VirtualBox のバージョンを落とすと、このファイルは読めなくなってしまう。

However, when VirtualBox encounters a settings file from an earlier version (e.g. after upgrading VirtualBox), it attempts to preserve the settings format as much as possible.

しかしながら、VirtualBox は、古い形式の設定ファイルを見つけると、その設定フォーマットを可能な限り維持しようとする。

It will only silently upgrade the settings format if the current settings cannot be expressed in the old format,

古い形式で表現できない場合に限って、黙って設定をアップグレードする。

for example because you enabled a feature that was not present in an earlier version of VirtualBox.[42]

例えば、過去のバージョンに無かった機能を有効にした場合に。

In such cases, VirtualBox backs up the old settings file in the virtual machine's configuration directory.

そんなときはバックアップをとる。

If you need to go back to the earlier version of VirtualBox, then you will need to manually copy these backup files back.

元に戻したかったら手動でコピーすればよい。

We intentionally do not document the specifications of the VirtualBox XML files, as we must reserve the right to modify them in the future.

XML のドキュメントは意図的に作っていない。将来仕様を変えられるように。

We therefore strongly suggest that you do not edit these files manually.

だから、手動で編集するな。

VirtualBox provides complete access to its configuration data through its the VBoxManage command line tool (see Chapter 8, VBoxManage) and its API (see Chapter 11, VirtualBox programming interfaces).

設定はコマンドラインツールから完全に操作できる。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment