Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the '10.4: Move Users directory to another partition' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Move Users directory to another partition
Authored by: pinguru on Apr 20, '07 02:42:01AM

A quick script I wrote for those too lazy to open Disk Utility or run diskutil...

As usual, run at your own risk, don't use it if you don't understand it...

# This script gets the UUID for a given volume name on OS X

#!/bin/bash -
# Get a list of all devices from diskutil, grep for the one we want
# and pass to awk to print that column, assign the result to $DEVNAME
DEVNAME=`diskutil list | grep $1 | awk '{print $6}'`

# Get diskutil's info for DEVNAME, grep for the UUID and print it
diskutil info $DEVNAME | grep UUID | awk '{print $2}'


[ Reply to This | # ]
10.4: Move Users directory to another partition
Authored by: ScottRussell2 on May 02, '07 03:38:54PM

This is exactly the way to do it. In fact, as part of every new machine I build for my clients, I include the following in the /etc/rc.local script (note that my 2nd partition is named "Data" by default):

### BEGIN CODE ###

if [[ ! -e /etc/fstab ]] ; then
logger "RC.LOCAL: /etc/fstab DOES NOT exist - creating to mount /Users as /Volumes/Data"

DRIVE=`df`
INDEX=1
while [[ "$DRIVE" != *"/Volumes/Data"* && "$INDEX" -le 5 ]] ## get the device ID to pass to diskutil
do
sleep 2
DRIVE=`df` && logger "RC.LOCAL: Get device ID of /Volumes/Data, Attempt # $INDEX"
let INDEX+=1
done

DRIVE=`df | grep /Volumes/Data | /usr/bin/awk {'print $1'}` && logger "RC.LOCAL: Drive = ${DRIVE}"
UUID=`diskutil info "${DRIVE}" | grep UUID | /usr/bin/awk {'print $2'}` ## this method is slightly faster
echo "UUID=${UUID} /Users hfs rw 1 1" >> /etc/fstab ## create /etc/fstab with this line
niload -m fstab / < /etc/fstab ## merge /etc/fstab into NetInfo database
logger "RC.LOCAL: restarting computer for /etc/fstab import to complete"
shutdown -r now ## RESTART THE COMPUTER SO THIS NEW /etc/fstab WORKS
fi

### END CODE ###

---
Best wishes,
Scott



[ Reply to This | # ]