Mac OS X: Mounting FAT32 external hard drive via Terminal command line

I have a 150GB USB external hard drive (IDE/Parallel ATA disk in an enclosure) which was formatted as one partition, FAT32 in Windows XP. I wanted to extract the files off of it using my Macbook Pro running Apple Macintosh Leopard (Mac OS X 10.5.6).

However, when I plug it in, I get a dialog box which says:

Disk Insertion
The disk you inserted was not readable by this computer.
Initialize…   Ignore   Eject

I saw many references to there being a 127GB or 128GB partition limit for FAT32 for Mac to successfully mount.

Also, a potential problem was that when using Disk Utility it shows up on my system incorrectly as formatted as a Windows NT Filesystem (NTFS-3G).

diskutil list disk3

Output:

/dev/disk3
#:                       TYPE NAME                    SIZE       IDENTIFIER
0:     FDisk_partition_scheme                        *149.1 Gi   disk3
1:               Windows_NTFS                         149.0 Gi   disk3s1

It did however mount automatically and show up when I was running a virtual machine, for example Parallels and Windows XP (I used VirtualBox and Windows 7), but copying over files this way proved to be very slow.

So, after spending a lot of time on the internet looking for solutions, I just tried mounting it from the Terminal (command line) with success!

First, make a mount point:

sudo mkdir /Volumes/EXT_HD

Now mount (your device numbers may be different, e.g. /dev/disk2s1 — you can determine what it is as it will the the highest number when you issue the command ‘ls /dev/disk*’):

sudo mount -t msdos /dev/disk3s1 /Volumes/EXT_HD/

It eventually showed up in Devices in Finder, but just to let you know, when I tried ejecting (unmounting) it when I was done, even though I had closed all programs I got the error:

The disk “USB_DRIVE” is in use and could not be ejected. Try quitting applications and try again.

Unmounting via he command line also failed:

sudo umount /Volumes/EXT_HD/
umount: unmount(/Volumes/EXT_HD): Resource busy

So I had to reboot.

I hope someone finds this information useful because I sure didn’t find any help…

EDIT (01 Oct, 2009): Apparently there is a way to enable native NTFS read/write support in 10.6 Snow Leopard (and this may work for Leopard). However, I would recommend not allowing write ability (and thus read only) when using this method as it may corrupt your NTFS files. To set to read only, follow the directions in the link but instead of using ‘rw’, use ‘ro’, e.g. UUID=123-456-789 none ntfs ro

How to handle deleting trash in Thunderbird when using IMAP Gmail

The Google team about a year ago added IMAP services to gmail. This is a great way to be able to manage your mail from several different places (e.g. client software at work, and web based gmail page on the road) and have everything automatically be in sync.

I’m also a big fan of the open source Thunderbird email client. But there is one annoying thing using these two together: when you have a message selected and press ‘delete’, normally this sends the message to Thunderbird’s trash (which completely removes it from Gmail), but in this case, you want to send it to Gmail’s trash.

There was a configuration setting you could try, to send the message to [Gmail]/Trash, but Google doesn’t recommend it (see ‘UPDATE 2, Nov 8th’ here). Instead you are supposed to move (e.g. drag-and-drop) the message to the [Gmail]/Trash folder manually.  Well, that’s not too convenient when you have a lot of folders. So, what I’ve found is an add-on QuickFolders which will easily make a shortcut to that folder (and others) so that you can more easily drag-n-drop to send that message to gmail’s ‘Trash’.

The Best Firefox Add-ons

I can’t use any other browser no matter how fast or cool because I’ve gotten so used to add-ons for firefox!

Here are mine, and in case you’re wondering, I have all these currently installed (Mac OS, is my current OS of choice) and Firefox runs at nearly the same speed as no add-ons:

——— These are INDISPENSIBLE: ———

DownloadStatusbar:  Simply a much better download manager.
http://downloadstatusbar.mozdev.org/

FlashBlock:  Replaces flash objects with a play button (‘>’) you must click before you can see it. Purpose is to lessen the amount of distracting things shown on most webpages.  You can add any website to a whitelist.
http://flashblock.mozdev.org/

NoScript:  Extra protection! You must explicitly opt-in to any javascript or java (and other plugins) for every website (permanently or for just this session). You can add any website to a whitelist.
http://noscript.net/

Tab Mix Plus:  Lots of fantastic tweaks for tabbed browsing.
http://tmp.garyr.net/  lastest (beta) versions here:
http://tmp.garyr.net/dev-builds/

Nuke Anything Enhanced:  Allows you to select any object (e.g. text, image) in a webpage and choose to remove it or remove everything else (can bring everything back with a simple page refresh).  Fantastic uses:  delete an annoying animated gif!, or clean up a page before printing!
https://addons.mozilla.org/en-US/firefox/addon/951

——— Adds lots of convienience: ———

MouseGestures:  Use your mouse for navigation. For example, holding the right mouse button while clicking the left, takes you back a page.
http://www.mousegestures.org/

LinkAlert:  Changes the cursor to indicate the target of a link (e.g. shows a small pdf image if it links to a pdf)
http://linkalert.googlepages.com/

ForecastFox: Displays the current weather (including radar/satellite) and forecast info constantly in your toolbar or statusbar. Nicely configurable.  Sure nice to have in a place where it actually rains!
http://users.rcn.com/shoofy/forecastfox_enhanced/

Fire.fm:  Brings last.fm audio streaming (free) to your browser with a handy small controller!!
http://sourceforge.net/projects/firefm/

Mac PDF: (Mac only) displays pdf documents in their own tab (instead of launching Mac’s built-in “Preview”)
http://code.google.com/p/firefox-mac-pdf/

GMarks:  Allows you to have access to your Google Bookmarks everywhere and easily.  I’m still getting use to this as I’m not a very organized bookmarker.  What’s cool about this is that you can search for text within the entire webpage of any bookmark you have – pretty powerful that is!
https://addons.mozilla.org/en-US/firefox/addon/2888   see also
http://www.google.com/bookmarks/

BugMeNot:  Allows anonymous logins to those annoying “free” websites (e.g. NY Times)
http://erichamiter.com/firefox/bugmenot/

——— KEY Webpage Development or Tweaking or Investigating Tools: ———

Firebug: Tons of tools; can edit, debug, and monitor CSS, HTML, and JavaScript live in any web page!
http://getfirebug.com/

Web Developer Toolbar:  Big and extremely helpful set of tools for messing with webpages.
http://chrispederick.com/work/web-developer/

TamperData:   View and modify HTTP/HTTPS headers, etc.
http://tamperdata.mozdev.org/

——— Some ‘niceties’ provided by lifehacker.com: ———
All these allow small tweaks to the way their respective websites are displayed:

better-youtube:
http://lifehacker.com/software/exclusive-lifehacker-download/better-youtube-firefox-extension-319925.php

better-google-reader:
http://lifehacker.com/software/exclusive-lifehacker-download/trick-out-google-reader-with-better-greader-262020.php

better gmail:
http://lifehacker.com/software/exclusive-lifehacker-download/better-gmail-2-firefox-extension-for-new-gmail-320618.php

better gcal:
http://lifehacker.com/software/exclusive-lifehacker-download/enhance-google-calendar-with-the-better-gcal-firefox-extension-260074.php

better amazon:
http://lifehacker.com/397946/better-amazon-firefox-extension-upgrades-amazoncom

——— Deactivated mine, but you may want to check out: ———

LiveHTTPHeaders: View HTTP headers of a page while browsing.
http://livehttpheaders.mozdev.org/

Nightly Tester Tools:  You’ll need this to allow add-ons to work if you’re using a beta version (i.e. Minefield) of Firefox.
http://www.oxymoronical.com/web/firefox/nightly

Google Pagerank Status:  Display the google pagerank for the currently viewed page. (VERY unfortunately, this add-on is not kept current)
http://www.tapouillo.com/firefox_extension/

libtiff error in Matlab when attempting to use ImageMagick

Trying to use the Imagemagick toolbox (for me, installed via MacPorts) sometimes doesn’t work (for example, converting a png image) in Matlab because Matlab for some reason uses the libraries in its path over those given in system call (this is for Mac, but probably for *nix and maybe even Windows).

This is an example call:

[s,w] = system([IMAGEMAGICK_PATH,'convert ',pwd,'/',outfile,'.png -rotate 90 ',pwd,'/',outfile,'.png']);

This is the error:

error:
dyld: Library not loaded: /opt/local/lib/libtiff.3.dylib
Referenced from: /opt/local/bin/convert
Reason: Incompatible library version: convert requires version 12.0.0 or later, but libtiff.3.dylib provides version 11.0.0

The work around is to replace the Matlab library with the ImageMagick one (only need to do this once and will stay until you upgrade Matlab):

cd /Applications/MATLAB74/bin/maci/   (or wherever your Matlab is installed)
mv libtiff.3.7.1.dylib  libtiff.3.7.1.dylib.MATLAB  (give it a different name)
ln -s /opt/local/lib/libtiff.3.dylib libtiff.3.7.1.dylib  (create a soft link to the Imagemagick library file)

EDIT: This is the much better way to handle this:

setenv(‘DYLD_LIBRARY_PATH’,['/opt/local/lib/:' getenv('DYLD_LIBRARY_PATH')])

Serial Port communications on Mac via Matlab

I have a rev B (Core 2 Duo from Dec, 2006) Apple MacBook Pro laptop running Leopard OS X (version 10.5.2) and have Matlab version 7.5.0.338 (R2007b). I’ve just found that I can NOT use the built-in serial port object, instead, I get the following error:

java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path thrown while loading gnu.io.RXTXCommDriver
??? Error using ==> serial.serial at 57
The serial port object is supported on the Solaris, 32-bit Windows and 32-bit Linux platforms only.

So, to get it successfully working, I downloaded these files: SerialComm.m, SerialComm.mexmac and SerialComm.mexmaci from http://svn.berlios.de/svnroot/repos/osxptb/stable/Psychtoolbox/PsychHardware/.

You can then use code like this:

PORT = 1;
% close (if previously open)
SerialComm( ‘close’, PORT)
% open
SerialComm(‘open’,PORT,’9600,n,8,1′)
% flush the buffers
SerialComm( ‘purge’, PORT)
% status
SerialComm( ‘status’, PORT)
% read
STR = SerialComm( ‘readl’, PORT);
% close
SerialComm( ‘close’, PORT)

[UPDATE 02 Apr, 2008]: Note, this same code didn’t seem to work on a recently purchased Macbook. Good luck.

[UPDATE 27 Mar, 2009]: I see that in Matlab version 7.8.0 (R2009a) if you go to ‘serial’ in Help docs it now says for Mac OS X and Mac OS X 64 you can use serial(‘/dev/tty.KeySerial1′); I don’t have a way of testing that right now, but it’s possible that you don’t need to use this third party toolkit anymore. If that’s true, please leave a note here.

Getting tcl via macports to compile on Leopard

With a fresh install of MacPorts version 1.6.0 on Mac OS X 10.5.2 Leopard, then issuing the command:

sudo port install tcl

returned:

/usr/local/include/mach-o/arch.h:35: error: nested redefinition of ‘enum NXByteOrder’
/usr/local/include/mach-o/arch.h:35: error: redeclaration of ‘enum NXByteOrder’
/usr/local/include/mach-o/arch.h:36: error: redeclaration of enumerator ‘NX_UnknownByteOrder’
/usr/include/architecture/byte_order.h:137: error: previous definition of ‘NX_UnknownByteOrder’ was here
/usr/local/include/mach-o/arch.h:37: error: redeclaration of enumerator ‘NX_LittleEndian’
/usr/include/architecture/byte_order.h:138: error: previous definition of ‘NX_LittleEndian’ was here
/usr/local/include/mach-o/arch.h:39: error: redeclaration of enumerator ‘NX_BigEndian’
/usr/include/architecture/byte_order.h:140: error: previous definition of ‘NX_BigEndian’ was here
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_tcl/work/tcl8.5.1/unix/../unix/tclLoadDyld.c: In function ‘TclpFindSymbol’:
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_tcl/work/tcl8.5.1/unix/../unix/tclLoadDyld.c:382: warning: ‘NSLookupSymbolInImage’ is deprecated (declared at /usr/include/mach-o/dyld.h:182)
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_tcl/work/tcl8.5.1/unix/../unix/tclLoadDyld.c:415: warning: ‘NSLinkEditError’ is deprecated (declared at /usr/include/mach-o/dyld.h:217)
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_tcl/work/tcl8.5.1/unix/../unix/tclLoadDyld.c:419: warning: ‘NSLookupSymbolInModule’ is deprecated (declared at /usr/include/mach-o/dyld.h:181)
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_tcl/work/tcl8.5.1/unix/../unix/tclLoadDyld.c:428: warning: ‘NSAddressOfSymbol’ is deprecated (declared at /usr/include/mach-o/dyld.h:188)
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_tcl/work/tcl8.5.1/unix/../unix/tclLoadDyld.c: In function ‘TclpUnloadFile’:
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_tcl/work/tcl8.5.1/unix/../unix/tclLoadDyld.c:493: warning: ‘NSUnLinkModule’ is deprecated (declared at /usr/include/mach-o/dyld.h:169)
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_tcl/work/tcl8.5.1/unix/../unix/tclLoadDyld.c: In function ‘TclpLoadMemory’:
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_tcl/work/tcl8.5.1/unix/../unix/tclLoadDyld.c:697: warning: ‘NSCreateObjectFileImageFromMemory’ is deprecated (declared at /usr/include/mach-o/dyld.h:146)
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_tcl/work/tcl8.5.1/unix/../unix/tclLoadDyld.c:730: warning: ‘NSLinkModule’ is deprecated (declared at /usr/include/mach-o/dyld.h:161)
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_tcl/work/tcl8.5.1/unix/../unix/tclLoadDyld.c:732: warning: ‘NSDestroyObjectFileImage’ is deprecated (declared at /usr/include/mach-o/dyld.h:147)
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_tcl/work/tcl8.5.1/unix/../unix/tclLoadDyld.c:740: warning: ‘NSLinkEditError’ is deprecated (declared at /usr/include/mach-o/dyld.h:217)
make: *** [tclLoadDyld.o] Error 1

I searched the web and found suggestions to deactivate odcctools, but the problem in my case is that odcctools wasn’t even installed. So, instead what I did was temporarily move the arch.h file, rerun the install command, and it worked fine!

sudo mv /usr/local/include/mach-o/arch.h /usr/local/include/mach-o/arch.h.RENAMED

Installing odcctools on Leopard

Instructions for installing odcctools in Mac OS X 10.5 Leopard (on Intel Macbook Pro Core 2 Duo) via macports:

I was attempting to get matplotlib, the python plotting library, installed via macports and the first problem is that the library is dependent on odcctools (20061117_0), which fails to build in the x86_64 environment.

But, we can get it to build…:

1) (clean the slate)

$sudo port -v selfupdate;sudo portindex
$sudo port clean –all odcctools

2) (this part will fail)

$sudo port install odcctools

Output:

—> Fetching odcctools
—> Verifying checksum(s) for odcctools
—> Extracting odcctools
—> Configuring odcctools
—> Building odcctools with target default
Error: Target org.macports.build returned: shell command ” cd “/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_odcctools/work/odcctools/odcctools” && make default ” returned error 2
Command output: cd libstuff && make
/usr/bin/gcc-4.0 -Wall -Wno-long-double -Wno-import -DHAVE_CONFIG_H -I/opt/local/include -I../include -I../include -O2 -fno-builtin-round -fno-builtin-trunc -no-cpp-precomp -mdynamic-no-pic -c -o allocate.o allocate.c
In file included from ../include/libkern/OSByteOrder.h:70,
from ../include/mach/ndr.h:94,
from ../include/mach/clock_priv.h:7,
from ../include/mach/mach_interface.h:37,
from ../include/mach/mach.h:62,
from allocate.c:26:
../include/libkern/machine/OSByteOrder.h:45: error: redefinition of ‘_OSSwapInt16′
/usr/include/libkern/i386/_OSByteOrder.h:49: error: previous definition of ‘_OSSwapInt16′ was here
../include/libkern/machine/OSByteOrder.h:54: error: redefinition of ‘_OSSwapInt32′
/usr/include/libkern/i386/_OSByteOrder.h:58: error: previous definition of ‘_OSSwapInt32′ was here
../include/libkern/machine/OSByteOrder.h:63: error: redefinition of ‘_OSSwapInt64′
/usr/include/libkern/i386/_OSByteOrder.h:69: error: previous definition of ‘_OSSwapInt64′ was here
make[1]: *** [allocate.o] Error 1
make: *** [libstuff] Error 2
Error: Status 1 encountered during processing.

3)
(hint from http://code.google.com/p/iphone-dev/issues/detail?id=106#c1 )
From this path,
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_odcctools/work/odcctools/odcctools
in each subdirectory, look for a “Makefile”. IF the file has a “MYINCLUDES” line, add this after the equals ( = ) sign:
“-isysroot /Developer/SDKs/MacOSX10.4u.sdk” (w/o quotes). If the Makefile doesn’t contain a line which starts with MYINCLUDES, then ignore it.

e.g. This is how the line will look after putting in:

MYINCLUDES = -isysroot /Developer/SDKs/MacOSX10.4u.sdk -I$(builddir) -I$(srcdir) -I$(top_builddir)/include \
-I$(top_srcdir)/include $(INCPRIVEXT) $(FORHDRS)

4) (continue installation)

$sudo port install odcctools

Output:

—> Building odcctools with target default
—> Staging odcctools into destroot
—> Installing odcctools 20061117_0
—> Activating odcctools 20061117_0
—> Cleaning odcctools

Done.

Next, I tried to continue the installation of matplotlib (e.g. sudo port install py25-matplotlib ), but <sigh> now g95 won’t compile…

[UPDATE 22 Sat, 2007: py25-matplotlib, including g25 now installs via Macports!!]

Leopard Broke SMB Tunnel Mounting via Finder

In Mac OS X 10.4 Tiger, you could use Finder (GUI) to mount an SMB mount which was being tunneled through ssh
For example:

  • From Terminal establish the tunnel:

    ssh -L 139:remote_machine:139 user@remote_machine

  • Then, in Finder, Go ? Connect to Server…
  • In “Server Address”, smb://localhost/mountpoint

However, this doesn’t work in Mac OS X 10.5 Leopard anymore!
The workaround is instead of using Finder, to use the mount_smbfs command in Terminal:

mount_smbfs //samba_user_name@localhost/samba_share /local/mount/point/

For example:
After establishing the tunnel (see above), I first made a mount point:

cd ~; mkdir sambamount

Then mounted it:

mount_smbfs //samba_user_name@localhost/data ~/sambamount

Once mounted, you should see the volume appear on your desktop, and you can drag it to the trash (or use ‘umount’) to unmount it.

**** UPDATE 25 Mar, 2009 ****

I’m getting many hits for this post, so I’m adding a little more detail for my setup specifically.

My work blocks almost all ports to incoming traffic. In order to log into a machine from the outside (for example from my home computer) I must first ssh into a firewall computer and setup a tunnel, or can ssh or telnet to another computer (you can do nothing on the firewall computer except ssh or telnet).

So, here’s my setup for tunnelling the SMB traffic within a ssh session (and still mount via Finder):

home <-ssh/tunnel-> firewall.example.com <-smb traffic-> smb_server.example.com

My work account credentials are the same on both the firewall computer and the SMB server.

You can add your modified version of the following to the file ‘/Users/mac_username/.ssh/config’:

#------------------------------------------------------
# For mounting smb shares locally from home:
#-- This is the name of this alias to this specific
#  configuration:
Host smb_tunnel_from_home

#-- Work's firewall computer (can also use IP number here)
Hostname firewall.example.com

#-- In place of 'work_username', your firewall username goes
#  here:
User work_username

#-- 127.0.0.2 is your computer, the second (where there are
#  x's) is the SMB server. Seems like I have to use the IP
#  number (instead of smb_server.example.com for this!):
LocalForward 127.0.0.2:139 xxx.xxx.xxx.xxx:139
LocalForward 127.0.0.2:445 xxx.xxx.xxx.xxx:445

#------ TO USE: ------
#--Using Terminal, at the prompt type (this creates an alias
#  of 127.0.0.1 at 127.0.0.2):
#    sudo ifconfig lo0 alias 127.0.0.2 up
#--Now start the ssh session:
#    sudo ssh work_username@smb_tunnel_from_home \
#    -F /Users/mac_username/.ssh/config
#--Then, in finder, Go->Connect to Server (Cmd-K), in the
#  box type:
#       smb://127.0.0.2/work_username
#--In the box which pops up, enter your work_username
#  and work_password.
#--Be sure to unmount the volume in finder when done using.
#------------------------------------------------------