Share files between two SO is easy because there are different protocols for sharing resources (NFS, CIFS/SMB/Samba, FTP, …), but sharing files between two PCs with OS Linux based, and one of them as VM guest of another one is a bit more complicated. Here’s how to do it when we Mac OSX as HOST and CentOS as GUEST:
Steps
Mount DVD ISO image in CentOS VirtualBox guest
Install VirtualBox. Many of you may already have VirtualBox, but if you don’t, click here to download. Gotcha, this is CentOS 6.3 and yeah for some reason its not picking up the change in the virtual MAC address as configured in Virtualbox. Not a showstopper as its easy enough to fix, but when I have some time I'll poke around some CentOS boards and see if I can figure out why it acts this way, based on some of the things I read Ubuntu doesn't.
- Previously, I have download DVD ISO image, then I have copied to my Mac OSX Host.
- From Virtual Box menu, goes to Devices > CD/DVD Devices and mount selecting CentOS’s DVD ISO image (ISO previuosly added to VBox’s “Virtual Media Manager”).
- In CentOS guest now you can see DVD iso mounted as
/media/CentOS_5.5_Final
. - You can install packages directly off the mounted DVD ISO. Now, modify
/etc/yum.repos.d/CentOS-Media.repo
file, enter: - Make sure enabled is set to 1:
- Save and close the file. To install packages from only DVD media repo, do this:
Notes:
- –disablerepo=*: disable all yum repo
- -y: assume yes to any question which would be asked
- –enablerepo=c5-media: enable c5-media repo
Install Virtual Box Additions in CentOS guest
Before anything, It is necessary install some packages as compiler gcc, kernel libs and sources.
- Install the following packages with CentOS DVD ISO image mounted:
- Unmount CentOS DVD ISO image and mount Virtual Box Guest Additions in your CentOS guest:
- Restart CentOS guest
- Now, install VBoxGuestAdditions in CentOS guest:
- Restart CentOS guest again.
- Now you could use special functionalities as resize the guest windows, share files, etc…
Share files beetwen Mac OS X as Host and CentOS as Guest
- In your Host Linux box:
- In main menu of your Linux Guest’s Virtual Box:
- Go to
Devices > Shared Folders
… - In popup, add shared folder and select Host’s folder (
/Users/chilcano/files2share
), set up a name asfiles2share
and make permanent.
- Go to
- In your Guest Linux box opens a terminal window and create a new directory where you’ll mount shared folder
- In this terminal, enter the id command and look the output. We will use uid and gid:
- Now, we will mount shared folder from Host to Guest. From terminal in Guest Linux:
Make the Mounted Share permanent
You can make the shared folder mount automatically each time you start the CentOS guest by making an entry in /etc/fstab
.
- From the CentOS guest edit fstab:
- Add a line at the bottom of file, and that looks like this:
- Verify mounted folder: In Mac OS X (host):
In CentOS (guest):
Mac Virtualbox Centos Ssh
Hope it helps.
References :
- CentOS: Install Packages Via yum Command Using DVD / CD as Repo
- http://www.cyberciti.biz/faq/centos-linux-install-packages-from-dvd-using-yum/
- Implementing virtualbox shared folders between a Mac OS X host and Fedora guest
- http://davidherron.com/content/implementing-virtualbox-shared-folders-between-mac-os-x-host-and-fedora-guest
- http://forums.virtualbox.org/viewtopic.php?t=4960&highlight=install+guest+addition
- How to install Guest Additions in CentOS 5.1
- Share Folders Between a Linux Host and Linux Virtual Machine on VirtualBox
- http://tuxtweaks.com/2009/06/share-folders-linux-host-linux-virtual-machine-virtualbox/