VMWare Fusion and system_profiler fail

VMWare Fusion and system_profiler fail

février 19, 2013 Add Comment
One of the newest additions to my toolset is VMWare Fusion 5. While I've attempted to use VMs in the past for development and testing, I've never really liked the environment. It always seemed slow and difficult to manage when I attempted to bend it to my needs. Luckily, I've had plenty of spare Macs to test on when needed.

I decided to give the tool another shot, as I really think the rollback feature would be helpful when testing software packages. It certainly seems quicker to revert to a snapshot instead of re-installing the OS every time I need to test an installer.

I started my test of VMWare Fusion 5 by booting from a USB drive to restore an OS disk image. I followed this article from VMWare on booting from an external USB drive. Once completed, the machine rebooted as I expected. However, what I didn't expect was the failure of my first boot script to correctly install a few packages.

Looking closer at the logs, I noticed that my script used this line to set the internal drive variable "HD_Path", which is used to tell the installer command the path to install the packages to:
HD_Path=`system_profiler SPSerialATADataType|awk -F': ' '/Mount Point/ { print $2}'|head -n1`
(Side Note: The above command has always worked to get the internal disk of a Mac, even when multiple internal and external disks were present OR even if booted from a the network!)

Running the system_profiler command in the terminal of the virtual machine showed me why it failed. Because "system_profiler SPSerialATADataType" returns blank for virtual machines! I found a bug posted here from 2008 that discusses the problem, but does not provide a solution.

So, I may still try to find a place that using VMWare works for me, this doesn't seem to be it. I am not currently wanting to re-writing scripts just to take advantage of snapshots, although I may find it necessary eventually.

If you're in this spot, try using tools like 'diskutil list' and 'df' to get the disk lists.