Showing posts with label deploystudio. Show all posts
Showing posts with label deploystudio. Show all posts

Thursday, April 26, 2018

Dualboot imaging macOS 10.13 and Windows 10 with Deploystudio and the Quest K2000 SDA


Introduction

This is the workflow I developed for deploying DualBoot Apple systems with macOS 10.13 and Windows 10. The workflow will only run on hardware that has been updated with a firmware version high enough to support 10.13 if using the APFS option. The HFS option does not require the firmware updates, although installing the latest firmware is always best practice.

Background

At Dickinson we use the Quest Systems Deployment Appliance (K2000) to run scripted installs of Windows. In the interest of having uniform configurations for all Windows systems I wanted to develop a system that would allow us to leverage the K2000 for BootCamp situations. This also allows us to save a lot of time by avoiding the need to create Windows images for those systems. The method I am using below should be adaptable to other WinPE based installation workflows.

Workflow steps

1.     Partition Disk
a.     If using APFS
                                               i.     Target Volume: First Disk Available
                                              ii.     Entire disk, Macintosh HD
b.     If using HFS
                                               i.     Target Volume: First Disk Available
                                              ii.     I use Macintosh HD 50%, BOOTCAMP 50% and KBE 5GB for the partitions
                                             
2.     Apply image
a.     Target Volume: Macintosh HD
b.     Image: APFS or HFS
c.      Image created using AutoDMG
3.     Disable SIP
We use rEFInd to provide a boot choice to users at startup, it requires SIP to be disabled to install.
4.     If using APFS you can now create the other required partitions using a ResizeAndAddPartitions shell script
This command will reduce the size of the APFS container to 50% of the drive, create an ms-dos partition named BOOTCAMP that is 100GB in size and create an ms-dos partition named KBE that is 6GB in size:
diskutil apfs resizecontainer disk0s2 50% ms-dos BOOTCAMP 100G ms-dos KBE 6G
I created a new DeployStudio shell script and the command is in the script.
5.     Copy Files – KBE files to KBE partition
The KACE Boot Environment files were generated by the KACE Media Manager. I copied them to the deployment share in the Files folder.
a.     Target Volume: /Volumes/KBE
b.     File/Folder: KBE
This folder contains the contents of the boot environment
c.      Path: /
d.     Exclude root folder: checked
6.     Additional tasks
At this point your DeployStudio workflow can include any other tasks required for configuring the macOS environment. We have a set of standard workflows for configuring our standard settings and installing our standard software.
7.     Install rEFInd
a.     If you are using a boot picker like rEFInd I recommend installing it as the last option.

Windows installation on BOOTCAMP partition

As far as the Deploystudio workflow goes, that is all there is to it. Once the workflow is applied to a machine and it finishes the process you should have a machine with the three partitions. Booting to the KBE partition, either through rEFInd or by holding in the option key at boot, should boot the system into the KACE Boot Environment. From there you can apply a scripted installation of Windows onto the Bootcamp partition.
It is important to note that the workflow for installing Windows should not include any partitioning steps. The BOOTCAMP partition should appear as the C: drive but won’t be formatted. The only pre-installation task in our scripted install formats the drive as NTFS.

I also include a last task in the post-installation tasks that deletes the KBE partition from the computer and expands the BOOTCAMP partition into that space using the diskpart command.

Further automation of the Windows installation

The developers of the K2000 have created an application called Default Deploy that allows you to automate the selection of an image or scripted install. More information about the tool can be found on the ITNinja Website (https://www.itninja.com/blog/view/k2000-default-deploy). Adding the tool to the boot environment requires the use of the KBE Manipulator application. Normally, you would add a custom command line to launch the default_deploy.bat file that launches the default_deploy.exe along with the correct parameters to begin the imaging process.
Rather than just launching the application, I modified the startnet.cmd command in the KBE to check for the presence of the default_deploy folder at the root of the KBE partition. This allows for the addition of a file copy task in the Deploystudio workflow that will automate the BOOTCAMP setup process.

In this case, I am copying a version of the default_deploy folder that has been configured to run the scripted installation for our Library’s pool of student loaners. After selecting the KBE boot option from the rEFInd menu I can walk away from the computer and it will automatically install Windows on the BOOTCAMP partition and be ready to go.

Friday, June 30, 2017

Automating dual boot Deployments - Part Three - KBE Automation

This is part three of my series on automating dual boot deployments with Deploystudio and the Quest K2000. In parts one and two I covered my motivation for the project and the creation of a virtual hard drive that contains the KACE Boot Environment. In part three I will be covering how to automate deploying an image from the K2000.

Although the K2000 has an automated deployment mechanism in the interface their method works best for computers that are already in the database. One of the K2000 engineers also developed a separate application called "Default Deploy" that can be added to the boot environment via the KBE Manipulator. In our case we can boot to the KBE and add the Default Deploy pieces manually, this is more advantageous because the method can be repeated more easily than using the KBE Manipulator and without the need of uploading our modified KBE to the K2000 appliance.


  1. Download the Default Deploy files from the link on the ITNinja site
  2. Copy the Default Deploy files to a USB drive
  3. Boot to the KBE on your Bootcamp machine.
    At this point you should have an Apple device setup to dual boot with Windows, that Bootcamp partition should also have a boot menu option for the Windows Pre-install environment. Booting into that environment should take you to the KACE K2000 deployment screen.
  4. Click on Recovery and then Command prompt
  5. Insert the USB drive
  6. Change to the drive letter for your USB drive
  7. Create a folder on the x: drive called applications:
    mkdir x:\applications
  8. Copy the default deploy files to x:\applications
  9. Edit the startnet.cmd file to add the default deploy command:
    1. notepad x:\windows\system32\startnet.cmd
    2. Find the section before this line:
      @echo **Performing local startup
    3. Add the default deploy command before this section:
      x:\applications\default_deploy.bat /inifile:t:\default_deploy.ini
    4. Save the startnet.cmd file and exit Notepad
  10. Change to the T: drive
    Note: The T: drive maps to your K2000 petemp share. This is a hidden share that is used for temporary files and you can use it to store other files that you may need for deployment tasks. In this case the default_deploy.ini file will be placed there.
  11. Copy the default_deploy.ini file from your USB drive to the T: drive
  12. Edit the default_deploy.ini file according to the instructions to deploy your scripted install for your Bootcamp machine
At this point you can save your files and shutdown the KBE environment and upload an image of the Bootcamp environment to Deploystudio. Before uploading I do recommend removing the Windows installation files from the C: drive as there is no need for them at this point. Just be sure to leave the VHD file present. You can also use bcdedit to remove the boot option for Windows.

An advantage of using this method to automate deployment is that we can now easily customize the KBE for different scenarios. The default deploy tools can be set to use a custom ini file which enables you to have multiple default_deploy.ini files on the T: drive. This means that you will be able to create multiple images of your Bootcamp partition that when applied to the system contain different instructions for which image to apply to the computer. In a more advanced scenario you could also have the default_deploy.bat look for a file on the C: drive of the Bootcamp partition and use the Deploystudio tools to replace that file at imaging time with a default_deploy.ini that contains the instructions for the image you want to use. This would allow you to have one image uploaded to Deploystudio with the ability to set the image for the Bootcamp partition as part of your imaging workflow.

In Part four of this series I will cover how to setup the workflow for Deploystudio and the K2000.

Friday, June 23, 2017

Automating Dual Boot Deployments - Part 1 - Introduction

I have been putting a lot of effort into the automation of dual boot deployments on Apple hardware and I am ready to start publishing that work. This first post in the series will cover my motivation for this work and future posts will include the details on my approach and methodology.

Trend 1 - Higher Demand
Dickinson College has seen a growth in the demand for dual boot Apple devices in recent years. I personally support three dual boot labs and many classrooms which total to almost 100 devices that need to be configured and re-imaged on an annual basis.

Trend 2 - Imaging Problems
With newer versions of macOS and Windows the benefits of creating "golden master" images are quickly fading and moving towards scripted installations/thin imaging is becoming a more preferred method of deployment. The tools used to create those images are also becoming more difficult to work with. In particular, changes in the macOS architecture have made creating images of Bootcamp partitions more difficult, if not impossible in some scenarios. The differences in hardware also make moving an image from one platform to another very difficult, also. For instance, creating an image on a Dell and applying it to an Apple device is fraught with peril.

Trend 3 - Thin Imaging/Scripted Installation
We have already made the transition to thin imaging on our Apple hardware for macOS and scripted installations for configuring Windows on our Dell systems. There was not a method for replicating this technique for Windows on Apple hardware in a dual boot scenario.

Motivator 1 - Desire for consistency
This divergence of configuration management resulted in a lack of consistency across devices. For example, imagine two classrooms with instructor computers. Classroom A has an iMac that is configured with macOS and Windows. Classroom B has a Dell with just Windows. If a professor teaches in classroom A using Windows she should expect the same experience in classroom B. Having the ability to create the same configuration on both platforms is highly desirable.

Motivator 2 - Making the most of current resources
With the move to thin imaging and scripted installations the desktop support team has put a large amount of time into packaging applications for deployment. This work could not be leveraged effectively when configuring Windows on dual boot systems.

Motivator 3 - Laziness
Let's be honest, I don't want to spend time configuring computers by hand, especially at a large scale. I have found that it is worth putting the time into developing a system that will save countless hours of clicking and typing.

Combining these trends and motivators led me to the work that I will be detailing in the next several posts. The broad strokes of my technique leverage Windows Native Boot to a virtual hard drive that contains the imaging environment for our Quest K2000 appliance. An image containing this virtual hard drive is placed onto the Bootcamp partition of a dual boot Apple device and when booted a scripted installation is performed. The end result is a Deploystudio workflow that completely automates the configuration of a dual boot system for both platforms that is consistent with other deployments across campus.

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.