Well I'll tell you how. I was hoping that parallels was using something like chroot to partition the drive, mount it with the requested file system and then virtualize the OS in a jail. This is, rather unfortunately not the case. What parallels actually does is creates an 8.4 GB file in the /users/<username>/Library/Parallels/<name of virtual machine>/ folder named <name of virtual machine>.hdd. Crazy.
So there is no way you're going to copy and paste files in and out of the jail locally, not even with the terminal and the old standard cp command. So how do I share or access files in between Mac OS X and Ubuntu? Well there are three ways depending on what you want to share or access.
1. SSH
If you actually want to move files from Ubuntu to OS X, or from OS X to Ubuntu you'll need to do it through SSH's SFTP program. This is actually relatively easy to set up, though my set up will require that you have a router (I think you can get around this by editing the hosts files in Ubuntu and OS X to resolve to the proper IP without any routing, but I havn't tested that).
First you'll need to bring down the active network device. If you are connected to your network via a wired ethernet connection, your primary connection device is most likely eth0, if connected by your airport card it is most likely ath0 (though possibly eth1, and definitely eth1 if you're still running Breezy Badger).
To bring down the wired connection:
shell~$ sudo ifdown eth0
To bring down the wireless connection:
shell~$ sudo ifdown ath0
Then We're going to set Ubuntu up with a static IP. Edit the /etc/network/interfaces file:
shell~$ sudo nano /etc/network/interfaces
For a wired connection, find the section for eth0, should look something like this:
auto eth0
iface eth0 inet dhcp
We need to modify this to give it a static IP:
auto eth0
iface eth0 inet static
# this defines the interface eth0 to have a static IP
address 192.168.0.150
# this defines the static IP of the interface
gateway 192.168.0.1
# this defines the default gateway (its the IP of your router)
netmask 255.255.255.0
# this is the subnet mask of the device (probably 255.255.255.0)
# if your setup is so advanced that it isn't 255.255.255.0 you
# then you probably know what this value is anyway
broadcast 192.168.0.255
# if your netmask is 255.255.255.0, your broadcast is the first
# 3 values of the IP address of the router followed by
# 255, X.X.X.255 if its not this, see the above netmask comment
For a wireless interface you'll need to find your wireless section, which should look something like this:
auto ath0
iface ath0 inet dhcp
And change it to have a static IP:
auto ath0
iface ath0 inet static
# This defines the interface ath0 to have a static IP
address 192.168.0.50
# This defines the static IP of the interface ath0
gateway 192.168.0.1
# This defines the default gateway of ath0 (Router IP)
netmask 255.255.255.0
# Subnet mask of ath0
broadcast 192.168.0.255
# Broadcast address of ath0
wireless-essid BEER
# Name of Wireless Network Connected to
wireless-mode managed
# mode of wireless network connected to
wireless-key H3X1SFUN
# WEP-key for wireless Network connection (or ASCII key)
Then bring the connection back up with the new configuration.
For a wired connection:
shell~$ sudo ifup eth0
For a wireless connection:
shell~$ sudo ifup ath0
To see if your static IP is working properly you'll need to perform a couple of tests. First check to make sure the proper device is representing the ip.
For a wired connection:
shell~$ sudo ifconfig eth0
For a wireless connection:
shell~$ sudo ifconfig ath0
A working device will output the values that you set in the interfaces file for each of the address, netmask and broadcast fields. Next you'll want to ping the router to make sure you're connected to the LAN:
shell~$ ping <router ip>
Then ping a site on the internet to make sure you have proper WAN access (assuming you have WAN access at all):
shell~$ ping www.google.com
Awesome, now we have a static ip on our ubuntu OS running inside of the parallels. To SSH to the ubuntu OS, you'll next have to install SSH on ubuntu:
shell~$ sudo aptitude install ssh
After the installation, make sure the ssh daemon is up and running:
shell~$ ps aux | grep sshd
At this point you should be able to use SFTP from Mac OS X to Ubuntu, in order to put and get files. To make sure, switch over to your OS X partition and open a terminal:
shell~$ sftp <ubuntu-ip>
sftp-> get testfile.sh
sftp-> put testfile.sh
sftp-> exit
To be thoughrough you should also start up the ssh daemon on OS X. To do this go to System Preferences -> Sharing and turn on personal file sharing. To test this switch back to your Ubuntu OS and run the same commands above only using the OS X ip instead of the ubuntu ip. If you don' know the OS X ip, just switch back to OS X and use ifconfig to get it:
shell~$ ifconfig
That about wraps it up for SSH.
2. HTTP Sharing
For some stuff SSH just doesn't make sense. For example if for some reason you want to listen to your music, or watch your movies from the OS X area in the Ubuntu area, or vice versa, you just don't want to have to copy those large files from one OS to the other, especially with the movies. So for this purpose we're going to set up HTTP servers to stream media from one OS to the other. Incidentally, as a cool side-effect of this you'll be able to stream this to any machine on your LAN, virtual or otherwise. Though this is because anyone on the LAN will be able to stream or download any file that you share via HTTP, and therefore if you want to securely share files, make sure you do it with sftp, not http.
Before we continue, I should point out that I am assuming you are on a LAN for this, and understand that if you stream copyrighted content (even legally aquired) over the WAN you are in violation of several laws, however bogus they may be.
Onward . . . you will most likely be streaming from OS X into Ubuntu, so we'll start there. To turn on your apache server just go to System Preferences -> Sharing and turn on personal web sharing. With one click of a button apache is up and running (though it apache 1.3 unfortunately) and they even poke a hole in the firewall on port 80 and 443 for you as well. Lets all just take a minute here to thank the folks at apple for being so friggin' awesome . . .
The document root for the apache server is: /Library/WebServer/Documents/ and you'll need to put all of your files into this folder in order to serve them. But of course we don't want to take up unnecissary space so just soft link the files or folders you want into the document root.
For example, my movies are in /Volumes/FATMATT/Movies, so . . .
shell~$ ln -s /Volumes/FATMATT/Movies /Library/WebServer/Documents/
Make sure the permissions are ok for the www user to read the files that you want to stream:
shell~$ ls -l /Library/WebServer/Documents/Movies/
shell~$ chmod -R 755 /Library/WebServer/Documents/Movies
Now we need to switch to Ubuntu and use a web browser to browse to the folder that we just set up, found at <ip of OS X>/Movies. If you want to download the files shared over HTTP, you can just browse to the folder and click on the file to download and save it. If you want to stream the files however (if they are media files) you'll need to download and install VLC. To install VLC in Ubuntu you'll first need to edit the /etc/apt/sources.list file:
shell~$ sudo nano /etc/apt/sources.list
And uncomment all of the universal repositories. Then perform and apt update, and install the program:
shell~$ sudo aptitude update
shell~$ sudo aptitude install vlc
To stream with VLC, browse to the shared folder and right click on the file, copy the link location. Then open VLC, go to open file, and paste the link location into the MRL text bar. And now you stream files to your Ubuntu OS wihtout having to take up vital disk space on that 8.4 GB file system.
To share files via HTTP from Ubuntu to OS X we'll need to set up an apache server on the Ubuntu OS. To do this install apache2:
shell~$ sudo aptitude install apache2-mpm-prefork
This will take a little while, but while it goes just sit back and enjoy the glory of apt, and take a moment to thank the developers at debian for allowing us to never have to hand-resolve dependancies ever again. Once this has finished apache should be running, but make sure:
shell~$ ps aux | grep apache2
The document root for apache in ubuntu is /var/www/, so linkng files in will look like this:
shell~$ ln -s /target/directory/ /var/www/
Once you've done that switch to OS X and browse to the folder: <ip address of ubuntu OS>/<folder name>. You can again download the files by clicking on them, or stream them in VLC using the same technique discussed above. To get VLC for mac go to their website (offsite) and download it.
3. SAMBA
The third option will allow you to read and write files on a samba share, without having to move the file from one to the other. This option will also allow you to copy files in and out of your samba shares on either OS and you'll be able to move files in between the two using this.
Most likely you'll be accessing the files on OS X with Ubuntu, so first we'll go through how to mount a samba share in Ubuntu. First you'll need to initialize the Samba server on OS X. You do this by going to System Preferences -> Sharing, and then you turn on Windows File Sharing. Doing this will prompt you for a user name and password, and OS X will conveniently let you know that the way Samba stores your password is less secure than the way the OS X stores your password, but it is still sufficiently secure for a LAN. Once you've done this your home directory in OS X will be up on a network Samba share, you can verify this in the finder, in the network section.
To mount the share in Dapper Drake go to Places -> Network Servers and then click on the share that has the name of your OS X box. My box is called MINIMATT, so I go to Places -> Network Servers -> MINIMATT to access my Samba share. If you need to configure additional samba shares on OS X, please refer to my previous post Setting Up External Hard Drive Samba Shares On OS X.
There is no real need to configure a samba server on your Ubuntu machine, as you can copy and paste what you need into and out of Ubuntu using the OS X samba server share. However to be thorough I should probably put this information up here as well. Unfortunately I don't have the desire to do this at the moment, so at some point in the future I'll put up a post covering how to set up a samba server in Ubuntu.
Enjoy!
No comments:
Post a Comment