VirtualBox

Changeset 91502 in vbox for trunk/src


Ignore:
Timestamp:
Sep 30, 2021 8:32:24 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
147191
Message:

Main/Unattended: Add UEFI support (needed for Windows 11 which this also adds), and make it work for the Windows case. This requires moving the aux files to a DVD image, because Windows booted in UEFI mode is unable to access a legacy floppy drive (hardcoded by Microsoft). The partitioning needs to be very different with UEFI and follows Microsoft's recommendations. Needs also a bit more flexibility with knowing on which drive letter the script will end up. Additionally contains registry tweaking to skip the TPM and secure boot checks in the Windows 11 installer (just in Windows PE, for later upgrading the same needs to be applied in the final install).

Location:
trunk/src/VBox/Main
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/VBox/Main/UnattendedTemplates/win_nt6_unattended.xml

    r68257 r91502  
    2727                    <DiskID>0</DiskID>
    2828                    <WillWipeDisk>true</WillWipeDisk>
     29@@VBOX_COND_IS_NOT_FIRMWARE_UEFI@@
    2930                    <CreatePartitions>
     31                        <!-- TODO: Use the standard partitioning scheme at starting with Windows 8 maybe, using 2 partitions as described by Microsoft? -->
    3032                        <CreatePartition>
    3133                            <Order>1</Order>
     
    3436                        </CreatePartition>
    3537                    </CreatePartitions>
     38@@VBOX_COND_END@@
     39@@VBOX_COND_IS_FIRMWARE_UEFI@@
     40                    <CreatePartitions>
     41                        <CreatePartition wcm:action="add">
     42                            <Order>1</Order>
     43                            <Type>Primary</Type>
     44                            <Size>300</Size>
     45                        </CreatePartition>
     46                        <CreatePartition wcm:action="add">
     47                            <Order>2</Order>
     48                            <Type>EFI</Type>
     49                            <Size>100</Size>
     50                        </CreatePartition>
     51                        <CreatePartition wcm:action="add">
     52                            <Order>3</Order>
     53                            <Type>MSR</Type>
     54                            <Size>128</Size>
     55                        </CreatePartition>
     56                        <CreatePartition wcm:action="add">
     57                            <Order>4</Order>
     58                            <Type>Primary</Type>
     59                            <Extend>true</Extend>
     60                        </CreatePartition>
     61                    </CreatePartitions>
     62                    <ModifyPartitions>
     63                        <ModifyPartition wcm:action="add">
     64                            <Order>1</Order>
     65                            <PartitionID>1</PartitionID>
     66                            <Label>WINRE</Label>
     67                            <Format>NTFS</Format>
     68                            <TypeID>de94bba4-06d1-4d40-a16a-bfd50179d6ac</TypeID>
     69                        </ModifyPartition>
     70                        <ModifyPartition wcm:action="add">
     71                            <Order>2</Order>
     72                            <PartitionID>2</PartitionID>
     73                            <Label>EFI</Label>
     74                            <Format>FAT32</Format>
     75                        </ModifyPartition>
     76                        <ModifyPartition wcm:action="add">
     77                            <Order>3</Order>
     78                            <PartitionID>3</PartitionID>
     79                        </ModifyPartition>
     80                        <ModifyPartition wcm:action="add">
     81                            <Order>4</Order>
     82                            <PartitionID>4</PartitionID>
     83                            <Label>Windows</Label>
     84                            <Letter>C</Letter>
     85                            <Format>NTFS</Format>
     86                        </ModifyPartition>
     87                    </ModifyPartitions>
     88@@VBOX_COND_END@@
    3689                </Disk>
    3790            </DiskConfiguration>
     
    57110                    <InstallTo>
    58111                        <DiskID>0</DiskID>
     112@@VBOX_COND_IS_NOT_FIRMWARE_UEFI@@
    59113                        <PartitionID>1</PartitionID>
     114@@VBOX_COND_END@@
     115@@VBOX_COND_IS_FIRMWARE_UEFI@@
     116                        <PartitionID>4</PartitionID>
     117@@VBOX_COND_END@@
    60118                    </InstallTo>
    61119                    <WillShowUI>OnError</WillShowUI>
     
    67125                <DisplayReport>OnError</DisplayReport>
    68126            </ComplianceCheck>
     127
     128            <!-- Apply registry tweaks to Windows PE, skipping the checks in the Windows 11 setup program. This will not make it to the final install, and should do no harm with older Windows versions. -->
     129            <RunAsynchronous>
     130                <RunAsynchronousCommand>
     131                    <Order>1</Order>
     132                    <Path>reg.exe add HKEY_LOCAL_MACHINE\SYSTEM\Setup\LabConfig /v BypassCPUCheck /t REG_DWORD /d 1</Path>
     133                    <Description>Windows 11 disable CPU check</Description>
     134                </RunAsynchronousCommand>
     135                <RunAsynchronousCommand>
     136                    <Order>2</Order>
     137                    <Path>reg.exe add HKEY_LOCAL_MACHINE\SYSTEM\Setup\LabConfig /v BypassRAMCheck /t REG_DWORD /d 1</Path>
     138                    <Description>Windows 11 disable RAM check</Description>
     139                </RunAsynchronousCommand>
     140                <RunAsynchronousCommand>
     141                    <Order>3</Order>
     142                    <Path>reg.exe add HKEY_LOCAL_MACHINE\SYSTEM\Setup\LabConfig /v BypassSecureBootCheck /t REG_DWORD /d 1</Path>
     143                    <Description>Windows 11 disable Secure Boot check</Description>
     144                </RunAsynchronousCommand>
     145                <RunAsynchronousCommand>
     146                    <Order>4</Order>
     147                    <Path>reg.exe add HKEY_LOCAL_MACHINE\SYSTEM\Setup\LabConfig /v BypassStorageCheck /t REG_DWORD /d 1</Path>
     148                    <Description>Windows 11 disable Storage check</Description>
     149                </RunAsynchronousCommand>
     150                <RunAsynchronousCommand>
     151                    <Order>5</Order>
     152                    <Path>reg.exe add HKEY_LOCAL_MACHINE\SYSTEM\Setup\LabConfig /v BypassTPMCheck /t REG_DWORD /d 1</Path>
     153                    <Description>Windows 11 disable TPM check</Description>
     154                </RunAsynchronousCommand>
     155            </RunAsynchronous>
    69156
    70157        </component>
     
    144231                    <Order>2</Order>
    145232                    <Description>VirtualBox post guest install steps </Description>
    146                     <CommandLine>cmd.exe /c A:\VBOXPOST.CMD --vista-or-newer</CommandLine>
     233                    <CommandLine>cmd.exe /c @@VBOX_INSERT_AUXILIARY_INSTALL_DIR@@VBOXPOST.CMD --vista-or-newer</CommandLine>
    147234                </SynchronousCommand>
    148235            </FirstLogonCommands>
  • TabularUnified trunk/src/VBox/Main/include/UnattendedImpl.h

    r90828 r91502  
    7373    Utf8Str const &i_getPostInstallScriptTemplatePath() const;
    7474    Utf8Str const &i_getPostInstallCommand() const;
     75    /** The directory where the unattended install config and script is
     76     * located, from the perspective of the running unattended install. */
     77    Utf8Str const &i_getAuxiliaryInstallDir() const;
    7578    Utf8Str const &i_getExtraInstallKernelParameters() const;
    7679
    7780    bool           i_isRtcUsingUtc() const;
    7881    bool           i_isGuestOs64Bit() const;
     82    bool           i_isFirmwareEFI() const;
    7983    VBOXOSTYPE     i_getGuestOsType() const;
    8084    Utf8Str const &i_getDetectedOSVersion();
     
    8993    bool            mfRtcUseUtc;            /**< Copy of IMachine::RTCUseUTC (locking reasons). */
    9094    bool            mfGuestOs64Bit;         /**< 64-bit (true) or 32-bit guest OS (set by prepare). */
     95    FirmwareType_T  menmFirmwareType;       /**< Firmware type BIOS/EFI (set by prepare). */
    9196    VBOXOSTYPE      meGuestOsType;          /**< The guest OS type (set by prepare). */
    9297    UnattendedInstaller *mpInstaller;       /**< The installer instance (set by prepare, deleted by done). */
  • TabularUnified trunk/src/VBox/Main/include/UnattendedInstaller.h

    r91312 r91502  
    6565     * IUnattended. */
    6666    Utf8Str                     mStrDefaultExtraInstallKernelParameters;
     67    /** The directory of the post install script in the unattended install
     68     * environment, i.e. when it gets started by the unattended installer
     69     * of the respective guest OS. */
     70    Utf8Str                     mStrAuxiliaryInstallDir;
    6771
    6872private:
     
    179183    const Utf8Str &getAuxiliaryFloppyFilePath() const   { return mStrAuxiliaryFloppyFilePath; }
    180184    const Utf8Str &getDefaultExtraInstallKernelParameters() const { return mStrDefaultExtraInstallKernelParameters; }
     185    const Utf8Str &getAuxiliaryInstallDir() const       { return mStrAuxiliaryInstallDir; }
    181186
    182187    /*
     
    377382                              "win_nt5_unattended.sif", "win_postinstall.cmd",
    378383                              "WINNT.SIF",              "VBOXPOST.CMD")
    379     { Assert(isOriginalIsoNeeded()); Assert(isAuxiliaryFloppyNeeded()); Assert(isAuxiliaryIsoIsVISO()); Assert(!bootFromAuxiliaryIso()); }
     384    {
     385        Assert(isOriginalIsoNeeded()); Assert(isAuxiliaryFloppyNeeded()); Assert(isAuxiliaryIsoIsVISO()); Assert(!bootFromAuxiliaryIso());
     386        mStrAuxiliaryInstallDir = "A:\\";
     387    }
    380388    ~UnattendedWindowsSifInstaller()        {}
    381389
     
    397405                              "win_nt6_unattended.xml", "win_postinstall.cmd",
    398406                              "autounattend.xml",       "VBOXPOST.CMD")
    399     { Assert(isOriginalIsoNeeded()); Assert(isAuxiliaryFloppyNeeded()); Assert(isAuxiliaryIsoIsVISO()); Assert(!bootFromAuxiliaryIso()); }
     407    {
     408        Assert(isOriginalIsoNeeded()); Assert(isAuxiliaryFloppyNeeded() != isAuxiliaryIsoNeeded()); Assert(isAuxiliaryIsoIsVISO()); Assert(!bootFromAuxiliaryIso());
     409        if (isAuxiliaryFloppyNeeded())
     410            mStrAuxiliaryInstallDir = "A:\\";
     411        else if (bootFromAuxiliaryIso())
     412            mStrAuxiliaryInstallDir = "D:\\";
     413        else
     414            mStrAuxiliaryInstallDir = "E:\\";
     415    }
    400416    ~UnattendedWindowsXmlInstaller()      {}
    401417
    402     bool isAuxiliaryFloppyNeeded() const    { return true; }
     418    bool isAuxiliaryFloppyNeeded() const    { return !mpParent->i_isFirmwareEFI(); }
     419    bool isAuxiliaryIsoNeeded() const       { return mpParent->i_isFirmwareEFI(); }
     420    bool isAuxiliaryIsoIsVISO() const       { return true; }
    403421    bool bootFromAuxiliaryIso() const       { return false; }
    404422};
  • TabularUnified trunk/src/VBox/Main/src-server/UnattendedImpl.cpp

    r90692 r91502  
    507507                    *penmOsType = (VBOXOSTYPE)((*penmOsType & VBOXOSTYPE_x64) | VBOXOSTYPE_Win10);
    508508                }
     509                else if (RTStrNICmp(pBuf->sz, RT_STR_TUPLE("co_release")) == 0)
     510                {
     511                    pszVersion = "21H2";    // ??
     512                    *penmOsType = VBOXOSTYPE_Win11_x64;
     513                }
    509514                else
    510515                    LogRel(("Unattended: sources/idwbinfo.txt: Unknown: BuildBranch=%s\n", pBuf->sz));
     
    740745
    741746    /** @todo look at the install.wim file too, extracting the XML (easy) and
    742      *        figure out the available image numbers and such.   The format is
    743      *        documented.  */
     747     *        figure out the available image numbers and such. The format is
     748     *        documented. It would also provide really accurate Windows
     749     *        version information without the need to guess. The current
     750     *        content of mStrDetectedOSVersion is mostly useful for human
     751     *        consumption. Long term it should be possible to have version
     752     *        conditionals (expr style, please) in the templates, which
     753     *        would make them a lot easier to write and more flexible at the
     754     *        same time. */
    744755
    745756    return S_FALSE;
     
    12211232        return hrc;
    12221233
     1234    FirmwareType_T enmFirmware = FirmwareType_BIOS;
     1235    hrc = ptrMachine->COMGETTER(FirmwareType)(&enmFirmware);
     1236    if (FAILED(hrc))
     1237        return hrc;
     1238
    12231239    /*
    12241240     * Write lock this object and set attributes we got from IMachine.
     
    26582674}
    26592675
     2676Utf8Str const &Unattended::i_getAuxiliaryInstallDir() const
     2677{
     2678    Assert(isReadLockedOnCurrentThread());
     2679    /* Only the installer knows, forward the call. */
     2680    AssertReturn(mpInstaller != NULL, Utf8Str::Empty);
     2681    return mpInstaller->getAuxiliaryInstallDir();
     2682}
     2683
    26602684Utf8Str const &Unattended::i_getExtraInstallKernelParameters() const
    26612685{
     
    26742698    Assert(isReadLockedOnCurrentThread());
    26752699    return mfGuestOs64Bit;
     2700}
     2701
     2702bool Unattended::i_isFirmwareEFI() const
     2703{
     2704    Assert(isReadLockedOnCurrentThread());
     2705    return menmFirmwareType != FirmwareType_BIOS;
    26762706}
    26772707
  • TabularUnified trunk/src/VBox/Main/src-server/UnattendedScript.cpp

    r90828 r91502  
    371371    else if (IS_PLACEHOLDER_MATCH("POST_INSTALL_COMMAND"))
    372372        rValue = mpUnattended->i_getPostInstallCommand();
     373    else if (IS_PLACEHOLDER_MATCH("AUXILIARY_INSTALL_DIR"))
     374        rValue = mpUnattended->i_getAuxiliaryInstallDir();
    373375    else if (IS_PLACEHOLDER_MATCH("IMAGE_INDEX"))
    374376        rValue.printf("%u", mpUnattended->i_getImageIndex());
     
    475477        *pfOutputting = mpUnattended->i_getPostInstallCommand().isNotEmpty();
    476478    else if (IS_PLACEHOLDER_MATCH("HAS_NO_POST_INSTALL_COMMAND"))
    477         *pfOutputting = !mpUnattended->i_getPostInstallCommand().isNotEmpty();
     479        *pfOutputting = mpUnattended->i_getPostInstallCommand().isEmpty();
    478480    /* Product key: */
    479481    else if (IS_PLACEHOLDER_MATCH("HAS_PRODUCT_KEY"))
    480482        *pfOutputting = mpUnattended->i_getProductKey().isNotEmpty();
    481483    else if (IS_PLACEHOLDER_MATCH("HAS_NO_PRODUCT_KEY"))
    482         *pfOutputting = !mpUnattended->i_getProductKey().isNotEmpty();
     484        *pfOutputting = mpUnattended->i_getProductKey().isEmpty();
    483485    /* Minimal installation: */
    484486    else if (IS_PLACEHOLDER_MATCH("IS_MINIMAL_INSTALLATION"))
     
    486488    else if (IS_PLACEHOLDER_MATCH("IS_NOT_MINIMAL_INSTALLATION"))
    487489        *pfOutputting = !mpUnattended->i_isMinimalInstallation();
     490    /* Is firmware UEFI: */
     491    else if (IS_PLACEHOLDER_MATCH("IS_FIRMWARE_UEFI"))
     492        *pfOutputting = mpUnattended->i_isFirmwareEFI();
     493    else if (IS_PLACEHOLDER_MATCH("IS_NOT_FIRMWARE_UEFI"))
     494        *pfOutputting = !mpUnattended->i_isFirmwareEFI();
    488495    /* Is RTC using UTC (i.e. set to UTC time on startup): */
    489496    else if (IS_PLACEHOLDER_MATCH("IS_RTC_USING_UTC"))
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette