How to sysprep a VMware image and retain the additional hard drive

answer-filesysprepwindows-server-2008

I am creating a base VM as the start of what I hope to be a VM tree of all the machine configurations that I regularly use.

On this base machine I have a small system drive of 10GB and a larger data drive of 40GB. When I sysprep the VM it removes the additional hard drive. Well it still appears but Server Manager reports it as offline.

I have the following in my answer file

<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="specialize">
    <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <ComputerName></ComputerName>
        <RegisteredOrganization>XXXXXX</RegisteredOrganization>
        <RegisteredOwner>XXXXXX</RegisteredOwner>
        <ShowWindowsLive>false</ShowWindowsLive>
    </component>
    <component name="Microsoft-Windows-Security-Licensing-SLC-UX" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <SkipAutoActivation>true</SkipAutoActivation>
    </component>
    <component name="Microsoft-Windows-IE-ESC" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <IEHardenAdmin>false</IEHardenAdmin>
        <IEHardenUser>false</IEHardenUser>
    </component>
</settings>
<settings pass="oobeSystem">
    <component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <InputLocale>0809:00000809</InputLocale>
        <SystemLocale>en-GB</SystemLocale>
        <UILanguage>en-GB</UILanguage>
        <UserLocale>en-GB</UserLocale>
    </component>
    <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <RegisteredOrganization>Company Name</RegisteredOrganization>
        <RegisteredOwner>Company Name</RegisteredOwner>
        <UserAccounts>
            <AdministratorPassword>
                <Value>cwBoAEAAcgBlAHAAbwAxAG4AdABBAGQAbQBpAG4AaQBzAHQAcgBhAHQAbwByAFAAYQBzAHMAdwBvAHIAZAA=</Value>
                <PlainText>false</PlainText>
            </AdministratorPassword>
        </UserAccounts>
        <AutoLogon>
            <Password>
                <Value>cwBoAEAAcgBlAHAAbwAxAG4AdABQAGEAcwBzAHcAbwByAGQA</Value>
                <PlainText>false</PlainText>
            </Password>
            <Domain>WORKGROUP</Domain>
            <Enabled>true</Enabled>
            <LogonCount>2</LogonCount>
            <Username>Administrator</Username>
        </AutoLogon>
        <OOBE>
            <HideEULAPage>true</HideEULAPage>
            <NetworkLocation>Work</NetworkLocation>
            <ProtectYourPC>3</ProtectYourPC>
        </OOBE>
        <Display>
            <ColorDepth>32</ColorDepth>
            <HorizontalResolution>1440</HorizontalResolution>
            <VerticalResolution>900</VerticalResolution>
        </Display>
        <TimeZone>GMT Standard Time</TimeZone>
    </component>
</settings>
<settings pass="generalize">
    <component name="Microsoft-Windows-ServerManager-SvrMgrNc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <DoNotOpenServerManagerAtLogon>true</DoNotOpenServerManagerAtLogon>
    </component>
    <component name="Microsoft-Windows-OutOfBoxExperience" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <DoNotOpenInitialConfigurationTasksAtLogon>true</DoNotOpenInitialConfigurationTasksAtLogon>
    </component>
</settings>
<settings pass="windowsPE">
    <component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <DiskConfiguration>
            <WillShowUI>OnError</WillShowUI>
            <Disk wcm:action="add">
                <ModifyPartitions>
                    <ModifyPartition wcm:action="modify">
                        <Active>true</Active>
                        <Letter>D</Letter>
                        <PartitionID>1</PartitionID>
                        <Label>Data</Label>
                        <Order>1</Order>
                    </ModifyPartition>
                </ModifyPartitions>
                <DiskID>1</DiskID>
                <WillWipeDisk>false</WillWipeDisk>
            </Disk>
        </DiskConfiguration>
    </component>
</settings>
<cpi:offlineImage cpi:source="catalog:c:/users/chalee/desktop/install_windows server 2008 r2 serverenterprise.clg" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>

I had assumed that the ModifyPartition section would set my second drive to online, but no dice!

Can anyone help with this? How should be answer file be configured to enable this second drive?

Best Answer

I solved this by writing a diskpart script.

The script was really simple:

select disk 1
online disk

I saved this as c:\windows\setup\scripts\partdisk.txt

I then created a cmd script like this:

partdisk /s c:\windows\setup\scripts\partdisk.txt

This was added to the Setupcomplete.cmd file in c:\windows\setup\scripts (create it if it does not exist) this script is executed after the Windows installation has completed when the sysprepped machine is first booted up.

This solved the problem, but it will be the first of many problems on the road to a smooth tree of usable and useful VM images.