VirtualBoxでゲストOS−ホストOS間でファイルをやりとりするケースは多い。ファイルのやりとりだけなら、VirtualBoxの共有フォルダを利用するのが簡単。
利用するためには、VirtualBoxのGuest Additionsをインストールし、共有フォルダの設定を行う。
Guest Additionsのインストール
準備
Guest Additionsのインストールに必要なファイルのインストール
# yum install gcc make kernel-devel
Guest Additions導入
- VirtualBoxのツールバーから、[デバイス(D)]から[Guest Additionsのインストール(I)] を選択し、Guest Additions CD-ROMイメージのマウント。
- LinuxでCDROMドライブをマウントする。
# mkdir -p /mnt/cdrom # mount -r /dev/cdrom /mnt/cdrom/ # cd /mnt/cdrom/ # ls -l 合計 52898 dr-xr-xr-x. 2 root root 2048 7月 4 23:19 2013 32Bit dr-xr-xr-x. 2 root root 2048 7月 4 23:19 2013 64Bit -r-xr-xr-x. 1 root root 647 9月 13 21:57 2012 AUTORUN.INF dr-xr-xr-x. 2 root root 2048 7月 4 23:19 2013 OS2 -r-xr-xr-x. 1 root root 9133518 7月 4 23:18 2013 VBoxLinuxAdditions.run -r-xr-xr-x. 1 root root 19089408 7月 5 00:10 2013 VBoxSolarisAdditions.pkg -r-xr-xr-x. 1 root root 15999344 7月 4 23:04 2013 VBoxWindowsAdditions-amd64.exe -r-xr-xr-x. 1 root root 9611144 7月 4 22:56 2013 VBoxWindowsAdditions-x86.exe -r-xr-xr-x. 1 root root 311568 7月 4 22:55 2013 VBoxWindowsAdditions.exe -r-xr-xr-x. 1 root root 6966 7月 4 23:14 2013 autorun.sh dr-xr-xr-x. 2 root root 2048 7月 4 23:19 2013 cert -r-xr-xr-x. 1 root root 5523 7月 4 23:14 2013 runasroot.sh #./VBoxLinuxAdditions.run
インストール後、reboot
共有フォルダの設定
まずは、対象のゲストマシンの共有フォルダを設定する。
対象の仮想マシンを選択 -> [設定] -> [共有フォルダタブ] -> [新規共有フォルダの追加]
フォルダ名を控えておく。ここでは、VmSharedにした。
ゲストOS上でこの追加した共有フォルダをマウントする。
# mkdir -p /mnt/shared # chmod 777 /mnt/shared # mount -t vboxsf VmShared /mnt/shared # ls -l /mnt/shared
ホストOSの共有フォルダが見えているはず。