본문 바로가기
Applications/Virtualbox

Oracle VM Virtualbox 3.2.8 - Shared Folders 설정 (Windows Host - Linux Guest의 경우)

by 거인과난쟁이 2010. 9. 30.
아래의 영어 설명은 Virtualbox 3.2.8의 내용 설명서에서 발췌한 것입니다. 본인과 같은 초보들은 이 설명을 잘 이해를 못하기 때문에 다소 불편합니다. 중요 부분에 한국어 설명을 추가해봅니다.

4.3. Shared folders
With the "shared folders" feature of VirtualBox, you can access files of your host system from within the guest system. This is similar how you would use network shares in Windows networks -- except that shared folders do not need require networking, so long as the Guest Additions are installed. Shared Folders are supported with Windows (2000 or newer), Linux and Solaris guests.

Shared folders must physically reside on the host and are then shared with the guest; sharing is accomplished using a special service on the host and a file system driver for the guest, both of which are provided by VirtualBox. For Windows guests, shared folders are implemented as a pseudo-network redirector; for Linux and Solaris guests, the Guest Additions provide a virtual filesystem driver which handles communication with the host.

To share a host folder with a virtual machine in VirtualBox, you must specify the path of that folder and choose for it a "share name" that the guest can use to access it. Hence, first create the shared folder on the host; then, within the guest, connect to it.

There are several ways in which shared folders can be set up for a particular virtual machine:

In the graphical user interface of a running virtual machine, you can select "Shared folders" from the "Devices" menu, or click on the folder icon on the status bar in the bottom right corner of the virtual machine window.

If a virtual machine is not currently running, you can configure shared folders in each virtual machine's "Settings" dialog.  [본인이 원하는 곳에 공유폴더를 만들면 된다.]

From the command line, you can create shared folders using the VBoxManage command line interface; see Chapter 8, VBoxManage. The command is as follows:

VBoxManage sharedfolder add "VM name" --name "sharename" --hostpath "C:\test"
There are two types of shares:

VM shares which are only available to the VM for which they have been defined;

transient VM shares, which can be added and removed at runtime and do not persist after a VM has stopped; for these, add the --transient option to the above command line.

Shared folders have read/write access to the files at the host path by default. To restrict the guest to have read-only access, create a read-only shared folder. This can either be achieved using the GUI or by appending the parameter --readonly when creating the shared folder with VBoxManage.

Then, you can mount the shared folder from inside a VM the same way as you would mount an ordinary network share:
==============================================================
In a Linux guest, use the following command:

mount -t vboxsf [-o OPTIONS] sharename mountpoint

[이 부분을 유의해야 한다.
1. 'sharename'이라는 것은 앞서 만들었던 공유폴더의 이름이다. 긴 경로 모두를 쓸 필요는 없는듯하다. 공유폴더이름만 써도 작동한다. 공유폴더이름을 '2linux'라고 가정하자.
2. 'mountpoint'라는 것은 마운트지점을 적으라는 뜻이다. 일반적으로 '/mnt'라는 위치아래에, '/mnt/00000'처럼 배치된다. 우선 '00000'에 해당하는 디렉토리를 만들어야 한다. 마운트되는 폴더이름을 '2windows'라고 하자. 이 경우 'mkdir /mnt/2windows'라고 디렉토리를 먼저 만들어야 한다. '2windows'라는 디렉토리가 만들어진 다음,
mount -t vboxsf 2linux /mnt/2windows  <-- '2linux라는 공유폴더를 읽고 /mnt/2windows 라는 폴더(디렉토리)에서 열어라'라는 명령어로 이해하면된다.]

To mount a shared folder during boot, add the following entry to /etc/fstab:

sharename   mountpoint   vboxsf   defaults  0   0