Thursday, October 27, 2011

Creating an External Windows Volume

This process I took while trying to create a imaging and restore procedure for our MacBook Pro lab for both Windows and Mac bootable partitions.  The technique will be geared to the Mac side of things, but can potentially be applied to any OS using UNIX and has access to the dd command.  

The dd command is a very powerful tool.  You can make a bit by bit copy of data from one media to another without any problems by using this technique.  The only drawback is the time it takes to make the copy and the backup, which is why I have ultimately chosen to not use this method.  But, as a side effect, it made it possible to restore a bootable Windows image to an external hard drive. 

##CAUTION!!  Any misstep in this process can destroy your drive completely, making it difficult to restore back again.  That's why I don't recommend it as a restoration process.  I'd highly recommend you use another process for backing up your Bootcamp volume.  You can use Winclone 2.3, though only if you turn just about everything off, or CloneZilla Live (which I am still testing, though they say it can be done).

  1. First, start with a prepared computer/drive.  In this case, I had a MacBook Pro with OS X Lion on one partition and Windows 7 on another.  
  2. Mount the computer/drive as an external drive.  Macs are able to boot into Target Disk Mode, which turns it into a very expensive Firewire or Thunderbolt drive.
  3. Open Terminal (or your command line) and run the command to identify your hard drives on the computer.  For the Mac, this command is: 
    diskutil list
  4.  Identify your drive.  Most often drives on a UNIX system would be in the /dev/ directory.  On the Mac, they are identified as /dev/disk1.  For other UNIX computers, you will probably see them as /dev/hda. 
  5. Run this command to back up your drive to an ISO file:
     sudo dd if=/dev/disk1 of=image.iso conv=noerror
    1. sudo is for super user do (run it as root)
    2. dd is the command
    3. if is the input file, or the drive (or partition) you are going to copy
    4. of is the output file, or the location the copy will go.  In this case, we are copying the drive as an ISO file in the current working directory
    5. conv=noerror will check for errors
    6. Expect this command to run for a long time.   It took 9 hours for a 100 GB drive with two partitions for me!
  6. Mount your new drive.  For me, I unmounted the MacBook Pro, and mounted an external hard drive.  The new drive needs to be equal or greater than the previous drive in order for this process to work. 
  7. Wipe the drive, for convenience sake.  I'm not sure if this is required, but I would still recommend it.  To do so, run the following command: 
    sudo dd if=/dev/zero of=/dev/disk1 conv=noerror
    Again, expect it to take a long time to run.  
  8.  Once finished, you can restore the image using the following command:
    sudo dd if=image.iso of=/dev/disk1 conv=error

After a long imaging process, about as long as it took to copy and wipe out, you should have a fully restored system to an external drive that will boot to Mac or Windows.  

So, what I learned from this was finding a great way to back up and restore a hard drive using an ISO.  What I also learned from this is that bit by bit copying takes forever, and is not time effective enough for mass deployment.  So the search continues for a usable deployment system for a Mac with a Bootcamp partition. 

No comments: