The title says it all. I want to use a USB drive formatted with ext4 on Snow Leopard. I mostly use the drive with Linux but sometimes I wish to mount it on my iMac at work to transfer a large amount of data (the wired network is just much faster there…).
My solution is to install Debian Squeeze on the iMac using VirtualBox, mount the ext4 formatted USB drive on the guest Linux, and export the partition over NSF to the host iMac. I had shied away from any virtualization up until this point, but it was actually quit trivial to set it up, so no installation note here. Just download and install VirtualBox on iMac, install an OS by popping in an install media, following the standard Debian install procedure, and that was it. The Debian installer has gotten easier to use so this should be very trivial.
Configure VirtualBox for Detect a USB Drive
Here I follow this article.
On VirtualBox, select the Debian I just installed. Go to Settings -> Ports -> USB. Check “Enable USB Controller” and “Enable USB 3.0 (EHCI) Controller.” Add a new USB filter with all fields initially set to empty strings. This is important so that the ext4 formatted USB drive gets detected before OS X does. (When OS X detects such a device, it thinks the device is unreadable and gives me an option to either initialize (omg), ignore, or eject. When this happens, make sure to choose “ignore.”)
Configure Network between Host and Guest
Here I follow this article.
On VirtualBox, select the Debian I just installed. Go to Settings -> Network -> Adapter 2. Check “Enable Network Adapter.” For “Attached to,” choose “Host-only Adapter” and “vboxnet0″ for its name. I may leave the default advanced settings.
On iMac host, find out the IP address of vboxnet0:
host$ sudo ifconfig ... vboxnet0: ... ... inet 192.168.56.1 netmask 0xffffff00 broadcast 192.168.56.255
So the host machine is at 192.168.56.1.
Now, login to Debian guest as a regular user. I configure the second network adapter that I created as follows. Edit /etc/network/interfaces to have the following lines:
auto eth1 iface eth1 inet static address 192.168.56.10 netmask 255.255.255.0
so that the guest machine is at 192.168.56.10. Do
guest$ sudo ifup eth1
and try to login to guest from host:
host$ ssh 192.168.56.10
Make sure everything works fine through this point.
Mount the USB Drive in Debian
I just follow a standard procedure for mounting a USB drive, but here goes. Start the guest Linux system. Once logged in as a regular user, plug in the USB drive to iMac. Find out which node the device has been attached:
guest$ dmesg | tail ... scsi 3:0:0:1: Attached scsi generic sg3 type 13 ... sdb: sdb1 ...
This is how it looks like on my system. Create a mount point and mount it:
guest$ mkdir ~/usb guest$ sudo mount /dev/sdb1 /home/username/usb guest$ ls /home/username/usb ... should see the content of the usb drive ...
If this works, the next step is to set up the NFS.
Setting up NFS on Debian Guest
On iMac host, find out the uid and gid of myself as a regular user:
host$ id uid=501(username) gid=20(staff) ...
Take a note of these numbers.
On Debian, install some packages:
guest$ sudo aptitude install nfs-kernel-server nfs-common portmap
In /etc/exports, have the following line:
[NOTE: THIS ACTUALLY DOESN'T WORK AS I THOUGHT.] Here, use the uid and gid of my regular user on iMac for anonuid and anongid; this is important so that the NFS mounted filesystem can be used as a regular user on iMac host. Then execute:
guest$ sudo exportfs -a
Now /home/username/usb should be mountable on iMac.
Mounting the NFS Partition on iMac Host
host$ mkdir usb host$ sudo mount_nfs -P 192.168.56.10:/home/username/usb usb host$ ls usb ... should see the content of the usb drive ...