In this post I am going to talk about a BitLocker solution that myself, Richard Smith and others from Avanade/Accenture - Chris Bird, Jonathan Goulding, Chris Urwin and Steven Westwell - put together for a customer. I should point out that enabling and applying BitLocker via OSD on SMS 2003 SP3 is not supported. So think carefully before implementing this in your environment.
First I want to quickly review the process of applying BitLocker via LiteTouch. There are three stages to this;
- Create a partition for the system files
- Move the boot files to the new system partition and mark that as active
- Boot from the new partition and initialise BitLocker encryption
So what are the problems with doing this process under OSD?
- OSD only supports a single partition
- the disk partition script needs a location to write the diskpart answer file to
- We can not reboot in the middle of the OSD/ZeroTouch task sequence.
Taking these one by one we can break the problem down a bit more and start to deliver solutions.
OSD and Multiple Partitions
The script that is used by LiteTouch to create multiple partitions requires a location to write the diskpart.txt file to. Now LiteTouch uses WinPE2.x which has a built in RAM drive so this is no problem. Under OSD we use a 'legacy' version of WinPE which does not. We could write the diskpart answer file to the hard disk but that would be lost as we used it to wipe the disk so that is no good. Really there are only two options open to us;
a) write the file to a network location
b) hard code the partition sizes
If using the latter option you have some challenges around coping with changes in disk size. You could create the BitLocker 2GB partition first and then create the OS partition in the remaining space - you just have to be careful that Windows Vista does not try to install itself into the 2GB Bitlocker partition – As this will be seen as the first installable partition and Windows Vista will not fit into this size of partition.
In our solution we chose option a. The main reason for doing this was that we were also having to support an OEM solution in the same image/task sequence. The OEM solution can only cope with one partition on the hard disk when it boots up - this meant we could not pre-create the BitLocker partition. So now we have to write the diskpart answer file to a network location - but where? In a large organisation spread around the globe you do not really want all 100,000 systems writing their answer file back to a single server somewhere. Luckily there is a server in OSD that is always close to the client system; or should be anyway. This is the SMS Deployment server. We used the SMS Deployment Point server to store the additional scripts, drivers and other files used by the solution (resourceroot=\\%SMSDP%\BDDResource$ - you have to create this package yourself - make sure you specify a fixed share to access it on all DPs). It was easy to create a sub-directory in our SMS package that was writeable by the SMS account to host the answer file. Each answer file is given the name of the computer that will use it, ensuring uniqueness, and not wanting to clog this directory up over time we delete the answer file once used.
So now we can create multiple partitions and define their sizes from values in the backend database. What's the next problem?
Moving the Boot Files
This is not so hard as it might seem. We use a slightly modified version of the normal BDEHDCfg.vbs script to do this. Although when it runs you see an error in the BDD.log file saying it wanted to reboot but OSD blocked it. That is fine. The boot files have been moved to the system partition and the partition marked as active.
Re-Boot and start BitLocker
So this gets pretty complex and even, may I say, a little messy. I have already covered off forcing OSD to reboot in a previous blog. We are now going to build on that process. In the previous post I described how we setup the system to autologon and run a job to reboot the system. Now we need to go one step further and have it run a script once it has rebooted. We have to copy the script down from the framework location (on the SMS Deployment Point Server) to a location on the hard disk that will not get deleted when OSD completes. In fact we need everything that will be required post reboot to be on the local hard disk. Remember OSD has completed so there is no BDD/MDT framework to use any more. In the previous blog post the second script that ran cleaned out the auto-logon entries before forcing the reboot - we need to do other things. So in the second script configure the system to run the third script once the machine has logged back on. This carries out all the tasks we need to initialise BitLocker running. Once BitLocker has started running we reboot the system again.
NOTE: We changed the shell at reboot to be the third script - this helps to make to solution a bit more secure in that there is no desktop for the user to interact with. However while you are developing the solution you might want to place a shortcut in the start up folder as this will make debugging easier. We also show a warning dialogue on the screen, BuildWarning.hta, informing the user that the system is still building.
Scripts and Task Sequence
Partitioning the disk
Because we needed to support an OEM solution we re-worked the disk partitioning script quite a bit. The script ZTIDiskPartOSD.wsf, in the zip linked below, actually has to be run twice. Each time it is run you need to specify a switch on the command line. This switch tells it if it is going to create the OS partition or the BitLocker partition. So in your task sequence you need to create two tasks - one to create the OS partition to other to create the BitLocker Partition. The screen shot below shows the two task sequences. The zipped file, link at the end of this post, has a file TS-snippets.txt that contains these two steps that you can cut and paste into your task sequence.
NOTE: You could use the normal script that comes with BDD however you still need to make sure this writes to a network location.
So now we have the two partitions created. The OS image is laid down onto the disk and mini-setup runs before rebooting to start the Zerotouch part of setup.
Moving the system files and rebooting
So by this time we have two partitions on the disk and the OSD process is running. Any custom tasks you have defined, including installing applications happen in this stage. Before this stage completes we need to do two things;
- move the boot files to the system partition
- configure the system to reboot and initialise BitLocker.
The modified BDE script (ZTIBdeOSD.wsf) does not try to start BitLocker - it just moves the boot files across to the BitLocker partition. It then asks for a reboot - you will see errors in the BDD log files saying that OSD has suppressed the reboot.
Next we need to re-boot from the new partition so BitLocker can be initiated.
As mentioned I covered off the basics of how force a reboot in an earlier post - I'll outline the process again here as it has changed a little to accommodate more than just rebooting the system. The OSD part of a ZTI process runs before the system has logged on for the first time. So before we can reboot the system we need to logon. However once we logon ZTI has completed and we no longer have the ZTI framework to rely on. So any scripts or files we need are going to have to be copied to the local hard disk for execution post re-boot. We essentially have three phases;
- copy scripts locally and prepare for reboot
- auto-logon once OSD completes and reboot
- carry out post reboot tasks.
The script z-osdpart1.wsf copies the required files (z-OSDPart2.vbs, z-OSDPart3 and Buildwarning.HTA) locally and configures the auto-logon settings. Once OSD completes the system auto-logons, runs z-OSDpart2.vbs which configures the system to run z-OSDPart3.vbs after reboot and then z-OSDPart2.vbs initiates the reboot. Because ZTI has completed there is no minint directory to use we copy the required files to c:\OSDTemp, if we copied them to the c:\minint directory they would be deleted by the ZTI cleanup process.
The screen shot below shows the two tasks as part of a much larger task sequence. As you can see they are placed towards the end of the task sequence.
The zipped file, link at the end of this post, has a file TS-snippets.txt that contains these two steps that you can cut and paste into your task sequence.
Post Re-Boot
So the system should have rebooted and be running Z-OSDPart3.vbs as the shell. This is quite a simple script that carries out the steps required to initialise encryption of the hard disk. It runs the BuildWarning splash screen, ejects the optical disk, (this is required because if a bootable disk is left in the optical drive then BitLocker cannot start), then starts BitLocker, cleans out the auto-logon information and resets the shell back to the normal desktop before rebooting.
We use the manage-bde.wsf script to initialise BitLocker once the system has restarted. For our client there was no requirement for a startup PIN - thy just wanted the hard disk encrypting and the recovery key stored in the Active Directory. We used a group Policy to make sure the BitLocker recovery password is stored in AD. The command line we used in Z-OSDPart3.vbs is given below. This turns on BitLocker on drive C: with a recovery password (-RP)
cscript.exe %windir%\system32\manage-bde.wsf -On c: -RP
So now you should have a system that has been built using OSD and is BitLockerd. Simple wasn't it! ;-)
Scripts
The link below takes you to the zipped archive of the files required for this solution.
This post was contributed by Richard Trusson a Senior Consultant with Microsoft Services, UK.