Automate Boot Camp Installation *Now with BitTorrent!

Bryan S. Lee A Legal Use For Torrents Or How I Learned To Push Windows Images The Fun Way History & Background

• Clemson University holds Student Computer workshops throughout the summer for entering freshmen during orientation sessions • Prefer to use automated installers for and software deployment on non- university systems History & Background • 2007: Used a combination of netbooting and imaging • 2008: Developed a separate, web-based for Windows XP

* Manually installed drivers for various hardware • 2009: Changed to * Pre-installed Boot Camp drivers utilizing sysprep for hardware setup History & Background

• Download time increasing during workshops (45 minutes vs. 4 minutes) • 2009 Fall: Began testing BitTorrent delivery • 2010-Present: BitTorrent based installer Ingredients

• Windows installation media • Windows Automated Installation Kit • Apple PackageMaker • Winclone • Various BitTorrent software (Vuze, BTPD, ctorrent) Ingredients

• Web • MAMP • Rivet Tracker • iHook • Favorite Script Editor Build Windows Image

• Install and patch • Install software • Set creature comforts Audit Mode

• Enter for editing a sysprep image before login, unless first image creation • Use shift-ctrl-F3 to access audit mode on sysprepped image Modify Windows Image

• Prepare drivers provided by Apple • RAR Expander • Add new drivers as necessary and install Boot Camp software • Additional cleanup Modify Windows Image • Add prepared Boot Camp drivers

C:\drivers • Add Registry Redirect for Drivers

HKLM\Software\ \Windows\CurrentVersion \DevicePath REG_EXPAND_SZ %SystemRoot%\inf;C:\drivers Modify Windows Image

• Use Windows Automated Installation Kit (WAIK) to create sysprep.xml

• Add sysprep.xml c:\windows\system32\sysprep\

Modify Windows Image • Add cmd script to

C:\Windows\system32\Clemson \del_drivers.cmd

Which contains the following command:

rmdir /s /Q c:\drivers

• Modify registry to engage command on first boot: HKLM\Software\Microsoft\Windows \CurrentVersion\RunOnce

Name: del_drivers Type: string Path: C:\Windows\system32\Clemson \del_drivers.cmd Initiate Sysprep

• From Administrative Command Prompt:

cd c:\windows\system32\sysprep\

sysprep /generalize /oobe /shutdown /unattend:sysprep.xml

• Wait for sysprep to complete and computer to shutdown Back to the Mac Winclone

• Install Winclone • Run commands: touch /tmp/emptyfile

• diskutil unmount /dev/ disk0s3

• path/to/ntfscp /dev/disk0s3 / tmp/emptyfile pagefile.sys

• diskutil mount /dev/disk0s3 Winclone

• Change prefs to make smaller image file

• Shrink Windows partition • Create Image Vuze

• Create Torrent file of image • Set announce URL • 4 MB pieces • Private tracker PackageMaker

• Familiar deployment for user • Small delivery size • Check System Requirements • Provide choices for partition size • Customize setup

Installer Script

• Downloads Windows image • Partitions hard drive • Clones Windows image

http://bigmaconcampus.wordpress.com Installer Script

• Engages BitTorrent client locally (BTPD) • If unsuccessful with BitTorrent, switches to direct HTTP download • HTTP vs. BitTorrent can be controlled server-side • Provides feedback via iHook Installer Script

• Apply choice for partition size • Partition hard drive • Must account for Windows image being on 4th partition on Lion systems • Provides feedback via iHook Installer Script

• Engage Winclone for cloning • Must account for Windows image being on 4th partition on Lion systems winclone.perl -ntfs_partition=/dev/disk0s4 --self-extract & • Provides feedback via iHook Modifications to winclone.perl

• Alter winclone.perl to send output to file to monitor for communication with installer script if (-e "${image_dir}/boot.img.gz") { unmount_volume($ntfs_partition); do_command("=====restoring image======","/usr/bin/gunzip -c \"$ {image_dir}/boot.img.gz\"| \"$ntfstools_dir/ntfsclone\" --restore-image --rescue --overwrite \"$ntfs_partition\" - 2>&1 > /private/tmp/clemson/windows7/ winclone_progress.txt"); • Alter winclone.perl to create a flag file to communicate with parent script that MBR has been set do_command("=====Syncing GPT with MBR Partition Table, setting partition to bootable, and restoring boot sector======","\"$gpt_refresh_path/gptrefresh\" ${arg_string}"); open(TEXT,'>/tmp/clemson/windows7/update_mbr_complete'); Web Server

• Xserve • Apache web server • Internal use only Torrent Server

• MAMP • Rivet Tracker • cTorrent • Internal use only Rivet Tracker Torrent Seed

• cTorrent • Flexibility • Multiple seeds • Seed strategy

Want a larger Windows partition? Click Customize. Check the box. Click Install.

If you chose to customize, select a size.

Sysprep

• Several reboots • Configures Hardware • Finalizes Windows Setup Reboots

• chkdsks • Hardware setup • Operating system Setup Conclusions

• Sysprep is a must for universal image creation • Dependent on Apple Boot Camp updates Conclusions

• HTTP download times are faster but vary depending on number of simultaneous connections (range from 4 minutes to - 45 minutes) • BitTorrent downloads are slower but consistent (8-10 minutes) irregardless of number of simultaneous connections Direct HTTP download BitTorrent download Conclusions

BitTorrent is: • less intensive on the server network bandwidth • less intensive on the infrastructure network bandwidth • less intensive on the server CPU • more secure The Future The Future Mountain Lion Compatibility Winclone 3 Rebuild For Better Feedback • Apple PackageMaker http://www.apple.com

• Windows Automated Installation Kit http://www.microsoft.com

• RAR Expander http://rarexpander.sourceforge.net/

• Winclone http://twocanoes.com/ • BitTorrent Clients: Vuze, BTPD, ctorrent http://www.vuze.com https://github.com/btpd/ http://www.rahul.net/dholmes/ctorrent

• Rivet Tracker http://www.rivetcode.com

• MAMP http://www.mamp.info

• iHook http://sourceforge.net/projects/ihook/ Bryan S. Lee

[email protected] • twitter.com/bryan_lee • http://bigmaconcampus.wordpress.com