LoginSignup
26
24

More than 5 years have passed since last update.

Windows 7環境でのVirtualBox(vagrant)の共有フォルダーのトラブル2つ

Posted at

問題:Windows 7環境のVirtualBoxにて共有フォルダーに設定しているディレクトリ下にて

  • シンボリックリンクが作れない。
  • read-onlyファイルが削除できない。

環境

Windows 7 Professional
VirtualBox 5.0.10
Vagrant 1.7.4

ひとつめの問題

Windows 7環境のVirtualBoxにて共有フォルダーに設定しているディレクトリ下にて
シンボリックリンクが作れない。

VirtualBoxでの解決方法

1、コマンドプロンプトで、以下のコマンドを実行。

コマンドプロンプト
> VBoxManage.exe setextradata 仮想マシン名 VBoxInternal2/SharedFoldersEnableSymlinksCreate/共有フォルダ名 1

※共有フォルダ名はVirtualBox マネージャーの、仮想マシン>設定>共有フォルダー のところで確認可能です。

2、管理者権限でコマンドプロンプトを立ち上げ、以下のコマンドを実行。

コマンドプロンプト
> cd C:\Windows\system32

> fsutil behavior set SymlinkEvaluation L2L:1 R2R:1 L2R:1 R2L:1

3、VirtualBox マネージャーを管理者権限で立ち上げて仮想マシン起動

※管理者権限で立ち上げないと、2のコマンドが無意味となります。

vagrantの場合

1、Vagrantfileを編集

VirtualBoxでの1のコマンドは、Vagrantfileに以下のように書いておくと上手いようにやってくれます。

Vagrantfile
config.vm.provider "virtualbox" do |vb|
    vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/共有フォルダ名", "1"]
end

2、管理者権限でコマンドプロンプトを立ち上げ、以下のコマンドを実行。

コマンドプロンプト
> cd C:\Windows\system32

> fsutil behavior set SymlinkEvaluation L2L:1 R2R:1 L2R:1 R2L:1

3、仮想マシン起動(vagrant up)

仮想マシン起動は、管理者権限で立ち上げたコマンドプロンプトから vagrant up
※管理者権限で仮想マシンを起動しなくてはいけないところがハマりどころです。

もうひとつの問題

Windows 7環境のVirtualBoxにて共有フォルダーに設定しているディレクトリ下にて
read-onlyファイルが削除できない。

こちらはWindows側からも、仮想サーバー側からも削除できません。
ファイルに書き込み権限を付ければ削除できるようになります。

海外のサイトもたくさん見てまわり、この問題が報告されているのを目にしましたが解決方法が見つからず。
こうなると、普段は共有フォルダを使わないようにしたほうが楽かな。

26
24
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
26
24