Showing posts with label k2000. Show all posts
Showing posts with label k2000. 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 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.