Spacer http://macenterprise.org MacResource.org - Mac OS X enterprise deployment project Spacer
Site Map Contact Us Top Background
 
Search
 
 
Running Parallels with Shadow files E-mail
Written by Lance Ogletree   
Wednesday, 11 April 2007
Alex Schaefer's article on Deploying Parallels with Shadow files got me thinking about my own use of Parallels.

I just recently switched from a desktop mac to a MacBook Pro. The downside in this switch has been the smaller amount of hard drive space I have available. This makes it especially difficult when wanting to run multiple Parallels OS environments.
All of those expanding drive containers eat up a good portion of usable hard drive space. I found that in my daily routine I would only be accessing my Parallels XP environment the most, while all of the other OS's sat idle most of the time.
This caused me to examine other methods for storing these OS's other than on my hard drive. The one I settled on was to store & access them remotely.
This also allows for other admins in our department to "test drive" the various OS's that have been pre-built without having to devote the time needed to prep the OS on their own. 
The basic premise is similar to Alex's in that you create a disk image of the folder containing your Parallels OS. In my case, I chose not to create Read Only disk images but went with Sparse Disk images. This allows me to have growing room, either within the master image for easy updating and also within my shadow file for adding/deleting apps. It also allows others to mount the image in a multi-user environment.
 
Not everyone will be in a position to take full advantage of this, but since we were installing a new network that was providing gigabit ethernet to the desktop I decided it was worth trying out.

For this example I will use Parallels_XP has my source folder containing the drive container files.
 
Create initial image:
 
hdiutil create -srcfolder Parallels_XP
 
Convert to Spare Disk: 
 
hdiutil convert -format UDSP -o Parallels_XP.dmg Parallels_XP.dmg
 
Resize the disk image: ( I decided to give myself additional room of about 5-6GB on top of the max size of the drive container. Since Vista defaults to a 32GB drive file in the Parallels setup, I resized the image to 37-38GB. )
 
hdiutil resize -size 38g Parallels_XP.dmg.sparseimage
 
I moved the the sparseimage up to our NAS and deleted both the original .dmg and sparseimage from my system.
 
The next task was developing a means for people to easily mount the images and start the Parallels OS.
With the help of Philip Rinehart and John Welch working with me to provide and test code, I finally settled on an automator approach. My initial automator action was set to automatically connect to the remote storage location, but I eventually changed it to allow the user to pick the image to mount with a shadow file. This gave the option of keeping the spareimages locally and still mounting with shadows.
 
The shell script code of the action is pretty basic.
I first create a Shadows directory in /Library/Application\ Support/ to store the shadow files that I create.
The rest of it is just a loop( since some may want to launch more than one OS at a time ) that just mounts each selection with a shadow and stores the shadow in the Shadows directory.
 
The last part I perform is to open all instances of .pvs files I find in the mounted volumes. This is where I cheat a bit and make sure that all sparseimages are named with the same prefix, in our case Rice_ 
This made it easier to script the opening of all *.pvs files in /Volumes/Rice_*/
 (If someone knows a better way, please contribute) 
 
Here's the code:
 
if [ ! -d "/Library/Application Support/Shadows" ]; then
   mkdir "/Library/Application Support/Shadows"
fi
for f in "$@"
do
name=$(basename "$f")
hdiutil mount "$f" -shadow /Library/Application\ Support/Shadows/"$name".shadow
open /Volumes/Rice_*/*.pvs
done
 
 
You can download the Automator workflow and use as you wish:
 
Last Updated ( Friday, 15 June 2007 )
 
< Prev   Next >