View Single Post
  (#1) Old
CodF4ther CodF4ther is offline
Member
 
Posts: 93
Join Date: Apr 2009
Default How-To: Mounting a SDHC card to /Users via fstab - 05-14-2009, 04:20 PM

This borrows heavily from the following sites:OS X Firewire Mount Point

I have an 8Gb Mini which I was finding very tight on space. Having some experience with fstab on linux, I decided to try and mount a SDHC card that I had lying around as part of the file system. This worked out very well for me, and can easily be adapted to mount other parts of the filesystem from SDHC (ie /Applications). I have successfully used this method on Leopard 10.5.6 and Snow Leopard 10.6.2.

Notes:
#1) After completing these changes you won't be able to swap your SDHC card in and out. It basically becomes a permanent part of your machine. If swapping SDHC cards is important to you, you'll need a external card reader.
#2) You need to have basic vi skills to use vifs. There should be lots of guides available if you do a bit of searching with Google.
#3) I've also been warned by meklort that the SDHC drivers are buggy. It has worked for me without issue for over 7 months, but your mileage may vary.
#4) This guide assumes that you have a HFS (journaled) formatted SDHC card with permissions enabled. The journaling probably isn't necessary (and may even be a bad idea, most similar guides on Linux recommend ext2 over ext3). You can partition and format the SDHC card using diskutil.
#5) SDHC cards aren't loaded by default in safe boot, meaning if you follow this guide you won't have access to your profile directory. I was able to login, but couldn't access my downloads directory etc. I have added a new optional step to the guide to make the SDHC required by the OS on safe boot, but I'm leaving this as optional for now. You make the call if you want/need it.

Part 1: Enable OSX to Mount your SDHC on Boot (normally OSX only mounts SDHC cards at login)

1. Open the Terminal app and enter the following command:

Code:
sudo nano /Library/Preferences/SystemConfiguration/autodiskmount.plist
2. Paste in the following into the nano editor (the file should be blank). If you get a file with some existing settings, make sure the value that follows the "AutomountDisksWithoutUserLogin" key is <true/>.

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>AutomountDisksWithoutUserLogin</key>
    <true/>
</dict>
</plist>
3. Quit the editor (ctrl-X) and save the file (Y)

Part 2: Modify your mount points

1. Insert your SDHC card and then log in to your favorite account to mount the card.
2. Get the UUID of the drive in Terminal ("<MySDHCDrive>" is the name of your SDHC card):

Code:
diskutil info /Volumes/MySDHCDrive|grep UUID
The diskutil command is going to spew out a lot of info, using grep narrows it down a bit. The stuff you want is on the line that starts: "Volume UUID:". You want the long identifier afterwords. E.g.: A740D396-D42D-3348-BD87-709342F87840

3. Edit your /etc/fstab file the OS X approved way with vifs (in Terminal):

Code:
sudo vifs
And add the equivalent to this line:

Code:
UUID=A740D396-D42D-3348-BD87-709342F87840 /Users hfs rw 1 1
4. Save the file and quit the editor

Part 3: Copy the contents from the original /Users folder to the SDHC card

1. Open terminal again and enter the following command:

Code:
sudo ditto -rsrcFork -V /Users /Volumes/MySDHCDrive
2. Rename the original /Users folder

Code:
sudo mv /Users /Users.orig
3. Recreate the /Users folder for a mount point

Code:
sudo mkdir -P /Users
4. Now, reboot your mac verify that it still boots properly

Code:
sudo shutdown -r now
5. At this your SHDC card should be mounted to /Users. Any reads and writes to that folder will actually happen to your SDHC card. You can verify the mounting with the following:

Code:
cd /
sudo df -k
6. Remove the /Users.orig folder that we are no longer using:

Code:
sudo rm -dr /Users.orig
Part 4: (Optional but recommended) Modify the SDHC driver so that it gets loaded in safe boot

1. Edit the Info.plist for the SDHC driver:
Code:
sudo nano /Extra/Mini9Ext/IOSDHCIBlockDevice.kext/Contents/Info.plist
2. modify the first part of the file from:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>CFBundleDevelopmentRegion</key>
        <string>English</string>
to:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>OSBundleRequired</key>
        <string>Safe Boot</string>
        <key>CFBundleDevelopmentRegion</key>
        <string>English</string>
3. Manually regenerate the extension cache by running:

Code:
sudo kextcache -a i386 -m /Extra/Extensions.mkext /Extra/Mini9Ext/