Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread Display Modes
Old Feb 4, 2013, 06:40 AM   #1
macrumors 65816
Dalton63841's Avatar
Join Date: Nov 2010
Location: SEMO, USA
SSD Tweaks shell script

Here's the deal... I am working on a package to handle setting up my SSD + HDD configuration. Instead of building a Fusion Drive, I am opting for just mounting /Users on the HDD. Along with that I will be moving the sleepimage, swapfiles, and /tmp over to the HDD.

The MAIN reason I build this is so that I can set it up manually once, and then if I need to reinstall the OS in the future, I can just install, enable root and log in, install this app, and be right back to where I left off. Anywho, I haven't actually done much shell scripting in several months, and was hoping someone could double-check my postinstall script.


UUID="$( diskutil info /dev/disk1s2 | sed -nE 's/.*Volume UUID: +([-A-F0-9]+).*/\1/p' )" # get UUID from HDD /Users partition

mv /Users /UsersOld											# changes /Users directory to prevent deletion

diskutil unmount ${UUID}

touch /etc/fstab
cp /etc/fstab /etc/fstab.orig								# backup original fstab

echo "UUID=${UUID} /Users hfs auto" >> /etc/fstab			# add UUID and mount point to fstab

diskutil mount "/dev/disk1s2"								# mount new HDD-based /Users
diskutil enableOwnership /Users

rmdir /UsersOld												# delete old Users directory

cp /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/UsersFolderIcon.icns /Users/.VolumeIcon.icns	# gives back proper icon for /Users folder

rm -rf /Users/.vm/											# remove sleep/swap files from previous install
pmset -a hibernatefile /Users/.vm
rm -rf /private/var/vm/sleep*
rm -rf /private/var/vm/swapfile*										#Move sleepfile, swapfiles, and tmp files
rm -rf /private/tmp
ln -s /Users/.tmp /private/tmp

exit 0
Also, right now this script gets the UUID for disk1s2, which is where the HDD main partition will USUALLY be. If there is a better, more bullet-proof way to ensure it gets the UUID for the proper partition, that would be great.
mid-2009 13" Macbook Pro, 2.26Ghz, 8GB RAM, 120GB SSD + 1TB HDD
Dalton63841 is offline   0 Reply With Quote

MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -5. The time now is 08:52 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013,, LLC