2016-04-26 7 views
2

多くの新しいVMの基礎として以下のVagrantファイルを使用します(私は新しいディレクトリにコピーします)。エラーVERR_ALREADY_EXISTS。ディスク・ファイル(ローカル・バリアント 'tmp'ディレクトリ内のsource_code_disk.vdi)は、最初は存在しませんでしたが、実際には不具合起動時に作成されますが、 'createhd'はFileExistsチェックにもかかわらず存在していたと考えられます'createhd'が呼び出されたときに存在します。面白いことに、私が新しいVMを「荒廃させる」とすると、ディスクファイルも削除されません。同じVagrantfileに基づいた別のインストールでは、ディスクファイルは "迷惑な人"の間に作成され、 "迷惑な人は破壊する"という形で削除されます。実行中の "vagrant up --debug"は余分な情報を出力しませんでした。簡潔さのためにここに出力を含めませんでした。新しいVMでVERR_ALREADY_EXISTSというエラーが発生したcreatehdを呼び出すときに、不具合が失敗する

FIXED
# -*- mode: ruby -*- 
# vi: set ft=ruby : 

file_to_disk = './tmp/source_code_disk.vdi' 

Vagrant.configure("2") do |config| 

    config.vm.box = "ubuntu/trusty32" 
    config.vm.network "private_network", ip: "192.168.33.11" 
    config.vm.hostname = "testdisk" 
    config.ssh.forward_agent = true 
    config.ssh.shell = "/bin/bash -l" 

    config.vm.provision :shell do |shell| 
     shell.inline = "sudo chsh -s /bin/bash vagrant" 
    end 

    # create a disk for the source code 
    config.vm.provider "virtualbox" do | v | 
     unless File.exist?(file_to_disk) 
      v.customize ['createhd', '--filename', file_to_disk, '--size', 50 * 1024] 
      v.customize ['storageattach', :id, '--storagectl', 'SATAController', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk] 
     end 
    end  

end 

答えて

3

:./

file_to_disk = 'tmp/source_code_disk.vdi' 

をリードする削除するには、相対パス名を変更することによって、私は、ディスクファイルへのパスに「./」を削除し、確実に失敗し、今完了インストール元のファイルが私の作品: - 問題なく、私は疑ういくつかのタイミングの問題と組み合わせパスチェックの失敗は無害な区切り文字な./

# -*- mode: ruby -*- 
# vi: set ft=ruby : 

file_to_disk = 'tmp/source_code_disk.vdi' 

Vagrant.configure("2") do |config| 

    config.vm.box = "ubuntu/trusty32" 
    config.vm.network "private_network", ip: "192.168.33.11" 
    config.vm.hostname = "testdisk" 
    config.ssh.forward_agent = true 
    config.ssh.shell = "/bin/bash -l" 

    config.vm.provision :shell do |shell| 
     shell.inline = "sudo chsh -s /bin/bash vagrant" 
    end 

    # create a disk for the source code 
    config.vm.provider "virtualbox" do | v | 
     unless File.exist?(file_to_disk) 
      v.customize ['createhd', '--filename', file_to_disk, '--size', 50 * 1024] 
      v.customize ['storageattach', :id, '--storagectl', 'SATAController', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk] 
     end 
    end  

end 

NOTEで始まる相対パスを使用している場合がありますほとんどの場合ですが、今は毎回、新しいディレクトリにファイルをコピーして「迷惑な人」を試みると、VMをプロビジョニングすることができません。私はそれが起こりそうにないと知っているが、それは本当であり、ここでは、私が「迷い抹消」して、ファイルパスから「./」だけを削除すると、失敗することを示すデバッグがある。

==> default: Running 'pre-boot' VM customizations... 
INFO subprocess: Starting process: ["/usr/bin/VBoxManage", "createhd", "--filename", "./tmp/source_code_disk.vdi", "--size", "51200"] 
INFO subprocess: Command not in installer, restoring original environment... 
DEBUG subprocess: Selecting on IO 
DEBUG subprocess: stderr: 0%... 
DEBUG subprocess: stderr: 10%...20%...30%...40%...50%...60%...70%...80%...90%... 
DEBUG subprocess: stderr: 
Progress state: NS_ERROR_INVALID_ARG 
DEBUG subprocess: stderr: VBoxManage: error: Failed to create medium 
DEBUG subprocess: stderr: VBoxManage: error: Cannot register the hard disk '/home/stg38/vagrant/vstb/./tmp/source_code_disk.vdi' {0c2aa882-a1ef-427e-b7c4-85ef86c0f819} because a hard disk '/home/stg38/vagrant/vstb/./tmp/source_code_disk.vdi' with UUID {17da2b81-dd91-44a3-b60e-6c4921d8e75a} already exists 
VBoxManage: error: Details: code NS_ERROR_INVALID_ARG (0x80070057), component VirtualBoxWrap, interface IVirtualBox 
VBoxManage: error: Context: "RTEXITCODE handleCreateMedium(HandlerArg*)" at line 449 of file VBoxManageDisk.cpp 
DEBUG subprocess: Waiting for process to exit. Remaining to timeout: 32000 
DEBUG subprocess: Exit status: 1 
INFO retryable: Retryable exception raised: #<Vagrant::Errors::VBoxManageError: There was an error while executing `VBoxManage`, a CLI used by Vagrant 
for controlling VirtualBox. The command and stderr is shown below. 

Command: ["createhd", "--filename", "./tmp/source_code_disk.vdi", "--size", "51200"] 

Stderr: 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%... 
Progress state: NS_ERROR_INVALID_ARG 
VBoxManage: error: Failed to create medium 
VBoxManage: error: Cannot register the hard disk '/home/stg38/vagrant/vstb/./tmp/source_code_disk.vdi' {0c2aa882-a1ef-427e-b7c4-85ef86c0f819} because a hard disk '/home/stg38/vagrant/vstb/./tmp/source_code_disk.vdi' with UUID {17da2b81-dd91-44a3-b60e-6c4921d8e75a} already exists 
VBoxManage: error: Details: code NS_ERROR_INVALID_ARG (0x80070057), component VirtualBoxWrap, interface IVirtualBox 
VBoxManage: error: Context: "RTEXITCODE handleCreateMedium(HandlerArg*)" at line 449 of file VBoxManageDisk.cpp 
> 
INFO subprocess: Starting process: ["/usr/bin/VBoxManage", "createhd", "--filename", "./tmp/source_code_disk.vdi", "--size", "51200"] 
INFO subprocess: Command not in installer, restoring original environment... 


Please fix this customization and try again. 
A customization command failed: 

["createhd", "--filename", "./tmp/source_code_disk.vdi", "--size", 51200] 

The following error was experienced: 

#<Vagrant::Errors::VBoxManageError: There was an error while executing `VBoxManage`, a CLI used by Vagrant 
for controlling VirtualBox. The command and stderr is shown below. 

Command: ["createhd", "--filename", "./tmp/source_code_disk.vdi", "--size", "51200"] 

Stderr: 0%... 
Progress state: VBOX_E_FILE_ERROR 
VBoxManage: error: Failed to create medium 
VBoxManage: error: Could not create the medium storage unit '/home/stg38/vagrant/vstb/./tmp/source_code_disk.vdi'. 
VBoxManage: error: VDI: cannot create image '/home/stg38/vagrant/vstb/./tmp/source_code_disk.vdi' (VERR_ALREADY_EXISTS) 
VBoxManage: error: Details: code VBOX_E_FILE_ERROR (0x80bb0004), component MediumWrap, interface IMedium 
VBoxManage: error: Context: "RTEXITCODE handleCreateMedium(HandlerArg*)" at line 449 of file VBoxManageDisk.cpp 
> 

Please fix this customization and try again. 
+0

これは私にとっても役立ちました。ホストを再起動した後にボックスを起動しようとすると、「Vagrant up」がこのエラーを生成します。 – mjuopperi

関連する問題