Shell Script to create an image file for your boot camp installation.
Submitted by tlarkin on Sun, 08/17/2008 - 18:19
This script assumes that you have partitioned your Mac into two partitions. One for OS X and one for Windows. You must also have the NTFS3G tools to be able to read/write to NTFS. By default OS X can only read NTFS local partitions. You also need a binary called gtprefresh, which allows your Mac to refresh the MBR since Windows boxes use legacy BIOS instead of EFI. Those files can be found here from Mike Bombich's site:
http://www.bombich.com/software/files/
The gtprefresh you just need in your standard $PATH. I tossed it in /usr/sbin when I did my image. The NTFS.progs should be a pkg file and should be able to be installed from the GUI. Once that is in place and your boot camp partition is set up and installed we can go on to creating the image file with the script below. However, first let us make sure your disk slices match up that of the script, since the script assumes you only have two partitions, one for OS X and one for Windows.
A simple diskutil list from the terminal prompt yields these results:
If you look at the results of the command in terminal.app you will see that my Windows partition does in fact reside on /dev/disk0s3 and is 28.1 Gi in size.
So let us take a look at the script that JAMF software provided me when I was creating my dual boot image.
#!/bin/sh## SCRIPT PARAMETERSvolume='disk0'sector='s3'windowsImageLoc='~/Desktop/BootCamp.ntfs'## DO NOT EDIT ANYTHING BELOW THIS LINEecho "Unmounting disk at /dev/${volume}${sector}..."/usr/sbin/diskutil unmount "/dev/${volume}${sector}"echo "Cloning Boot Camp Image..."/usr/local/sbin/ntfsclone --save-image --overwrite "/private/tmp/BootCamp.ntfs" "/dev/${volume}${sector}"/bin/mv /private/tmp/BootCamp.ntfs "$windowsImageLoc"echo "Mounting /dev/${volume}${sector}..."/usr/sbin/diskutil mount "/dev/${volume}${sector}"
As you can see the script is set to run on disk0 and slice 3 just like I have it set up. Run the script and in a few moments you will have your Windows image ready to go.
- Login to post comments
