Showing posts with label technology. Show all posts
Showing posts with label technology. Show all posts

Friday, June 23, 2017

Automating dual boot Deployments - Part Two - Native Boot

Windows Native Boot is a technology introduced in Windows 7 that allows a computer to boot directly into a virtual hard drive or VHD. My work leverages this functionality to load the KACE Boot Environment (KBE) on a Bootcamp partition. This provides the ability to perform a scripted installation from the K2000 appliance on the Bootcamp partition.

Many of the steps below are taken from the following MSDN article that details the Native Boot technology.
https://msdn.microsoft.com/en-us/windows/hardware/commercialize/manufacture/desktop/boot-to-vhd--native-boot--add-a-virtual-hard-disk-to-the-boot-menu

The process of creating the VHD containing the KBE requires that we first use the Bootcamp Assistant to create a Bootcamp partition and install Windows. This will help ensure that the partition is formatted correctly for the Apple hardware. 

After the Windows installation is complete we can create the VHD and apply our boot environment. In order to do this you will need the boot.wim file for that environment. To get a copy of this file for the Quest K2000:
  1. Login to the K2000 web interface
  2. Navigate to Deployments, Boot Environments
  3. Select the appropriate boot environment
    Note: I have found that a standard Windows 10 boot environment will boot to Apple hardware with the necessary drivers for deployment. If that is not the case in your environment you will have to build a custom KBE.
  4. On the boot environment detail page click the link to download a bootable ISO for this boot environment.
  5. Open the downloaded ISO file.
  6. Browse to the Sources folder in the ISO.
  7. Copy the boot.wim file to your computer.
Now that you have the boot.wim file we can create the VHD and apply the WIM image to it.

Creating the virtual hard drive


  1. Open a command prompt as administrator
  2. Run diskpart and execute the following commands
    1. create vdisk file=c:\vhdboot.vhd maximum=5000 type=fixed
      Note: I create the file at the root of the system drive to avoid and path issues. We also don't need a very large disk image and 5GB is still more than we need.
    2. attach vdisk
    3. create partition primary
    4. format quick label=vhd
    5. assign letter=v
    6. exit
There should now be a V: drive on your computer that maps to the virtual hard drive. 

Applying the WIM
The next step is to apply the WIM to that drive. While still in the administrative command prompt run this command:
dism /apply-image /imagefile:c:\boot.wim /index:1 /applydir:v:\


This command assumes that you placed the boot.wim file at the root of the C: drive. 

Booting to the Virtual Drive
Now that the image has been applied to the VHD we can add it to the boot menu and boot to the OS on the drive. While still in the administrative command prompt:
  1. v:
  2. cd \windows\system32
  3. bcdboot v:\windows
There should now be an entry in the boot configuration database that points to the V: drive. To verify this you can run bcdedit to list the boot options. When the computer is restarted you should see an options for Windows Pre-installation environment. Booting to that option should load the KACE Boot Environment.

In my next post I will describe how to manipulate the KBE to automatically deploy a desired scripted install.

Friday, January 29, 2016

Deploying Winclone Image Packages with DeployStudio

Background: 

As of DeployStudio version 1.7.2 it is not possible to create and deploy an image of Windows 10 on a Bootcamp partition. Due to this issue we purchased licenses of Winclone so that we can still deploy dual boot systems at Dickinson College. Winclone images have a few options which potentially make them a better solution for deploying Windows on Apple hardware so overall this isn't a bad decision in the long term. DeployStudio is capable of distributing Winclone images but the process is a little different. This documentation will serve as a guide to creating a workflow that images an Apple device with a dual boot setup using Winclone to create the Windows image for the Bootcamp partition. You will need a licensed copy of Winclone to complete this procedure.

I created a few scripts to help automate the imaging process. They are available on my GitHub repository:

Preparing a Mac Image: 

The process for preparing a MacOS image for a dual boot setup is not any different from before. Setup your image as desired and upload it to DeployStudio as you normally would. 

Preparing the Windows system: 

  1. Launch the Bootcamp assistant and use the wizard to create a Bootcamp partition.  Note: You will need a disk image of Windows 10. The size of the Bootcamp partition needs to be large enough to accommodate Windows and any applications you want to install. Winclone will be able to shrink the partition to a smaller footprint and also create a larger or smaller partition for restoration. 
  1. The computer should restart and proceed with installing Windows. Remember that you need to format the Bootcamp partition in order to select it and install the OS. 
  1. After installation is complete the Bootcamp installer should launch. Note: I have seen an issue with the RealTek audio drivers failing to install. If the Bootcamp installer stalls for a long period of time open Task Manager and kill the RealTek setup process. 
  1. Restart after installing the Bootcamp software. 
  1. Configure the computer as required with applications and settings.  
  1. Winclone uses text in c:\windows\system32\license.rtf to determine the operating system when creating an image. Check the file to make sure it contains "Windows 10". In my experience the Enterprise version does not have the text and it needs to be added. 
  1. Perform a sysprep on the computer. I have created a basic unattend.xml file that includes examples of several key settings and made it available on GitHub: https://github.com/csteelatgburg/scripts/blob/master/Windows/Win10Unattend.xml 

Creating the Bootcamp image: 

You will need a licensed copy of Winclone for this task. I was using version 5.5 when I wrote these instructions. 
  1. Boot the computer to MacOS. 
  1. Launch Winclone and load your license file if you have not already done so. 
  1. Select the Bootcamp partition. 
  1. In the Tools menu select Shrink Windows (NTFS) Filesystem. 
  1. After shrinking the partition click Save Image and give it a name. 
  1. After the image is saved, select it in the list on the left. 
  1. Click the Make Package button. 
  1. Select the appropriate option for the size of the Bootcamp partition. 
  1. Click Create package and choose a name and location. 

Getting the image to DeployStudio:

Depending on your environment you need to get the package to your DeployStudio server. Place it in the Packages folder of your Images share.

Creating your workflow: 

I have created several scripts that will assist in the automated deployment of Winclone packages. You will need to add these scripts to the workflow for imaging a dual boot computer using a Winclone package. You can download them from my GitHub repository:
These scripts need to be placed on your DeployStudio server in the Scripts folder of your Images share.

  1. Create a new workflow and name it appropriately. 
  1. Add the following tasks 
  1. Partition Target Volume: First Disk available Create one partition using the entire disk named Macintosh HD Check the Automate checkbox. Note: We do not need to create the partition for Windows at this point because the Winclone installer will handle that for us. 
  1. Restore Target Volume: Enter value, Macintosh HD Image: HFS, select the appropriate image for the MacOS partition Check the boxes for the following options: Don't check restoration, Rename ByHost prefs, Delete machine dependent files and caches, Set as default startup volume, Automate 
  1. Generic Select the disable_sip.sh shell script in the Command dropdown.  Note: The Winclone package can't run with SIP enabled.  You can read more about this on the Twocanoes website.Check the Automate checkbox. 
  1. Configure Target volume: Previous task target Check the boxes for the following options: Rename computer, Automate 
  1. Generic Select the copy_tools_local.sh shell script in the Command dropdown.  Check the Automate checkbox. Note: This copies the DeployStudio scripts to /etc/deploystudio on the Macintosh HD, we will need them after the computer reboots. 
  1. Generic Select the bootcamp_save_name_to_file.sh shell script in the Command dropdown. Check the Automate checkbox. Note: This is a script that I created that saves the computers Bootcamp name from the DeployStudio database in /etc/deploystudio/bootcampname on the Macintosh HD.  Check the Automate checkbox. 
  1. Package Install Target volume: Previous task target Package: Select the Winclone package that you created and placed in the Packages folder on the DeployStudio server. Check the boxes for the following options: Postponed Installation, Automate 
  1. Generic Select the bootcamp_set_name_from_file.sh shell script in the Command dropdown.  Check the Postponed Execution checkbox and select Previous Task Target for the target volume. Parameters: /dev/disk0s3 Note: This is the disk and partition that is typically used for Bootcamp in my configurations. If your partition scheme is different you will have to adjust this value accordingly. Check the Automate checkbox. Note: This script retrieves the computer name from /etc/deploystudio/bootcampname and then searches the Bootcamp partition for an unattend.xml line that contains the <computername>*</computername> directive. It replaces the * with the computer name so that the machine is named correctly after it completes the OOBE stage. 
  1. Add any other tasks for your image (additional software installs, active directory binding, etc.). 
  1. Click Save  

Applying the images to a computer: 

  1. NetBoot the computer to the DeployStudio server. 
  1. If you have not already added the computer to the DeployStudio database then do so now.  
  1. Run the workflow you created. 
  1. DeployStudio will perform the selected tasks. Note that it will copy the Winclone image to the local machine, this may take a long time depending on network speed. 
  1. After the tasks which run in the DeployStudio Runtime complete the computer will restart and then run the postponed tasks, including installing the Winclone package. 
  1. Once all of the postponed tasks are complete the computer will restart. 
  1. Login to MacOS and set the startup volume to the Bootcamp partition.  Note: Before restarting you can verify the naming scripts worked by browsing the Bootcamp partition to c:\windows\panther and checking the unattend.xml file. The <computername> directive should contain the name from the DeployStudio database. 
  1. Restart the computer and allow Windows to complete the sysprep OOBE process.