PDA

View Full Version : SSD Tweaks shell script




Dalton63841
Feb 4, 2013, 06:40 AM
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.

#!/bin/sh

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.