Scenario

This TID details a scenario where desktops and laptops are built using a single Imaging Toolkit project but different partition configuration are required on each, as shown in the table below;

Laptop Configuration Desktop Configuration
100 MB System Partition 100 MB System Partition
60GB OS Partition Remainder of disk as OS Partition
Remainder of disk as D: drive  


In this example the base image has been created with a System and OS Partition using the Project Settings in Build Console. This means that desktops will already build with the required partitions. In order to create a data partition on the laptop machines it is simply a matter of updating the zim.cfg as detailed in this TID.


By using this TID as a guideline it should be possible to modify the scenario to meet your own specific requirements.

Procedure

Done Task
 
1. Lookup Partition size from the projects.ini file
 
2. Create ddrive.zmg file
 
3. UEFI machines - Update zim.cfg to Configure Partitions and Restore images to the correct partitions
 
4. BIOS machines - Update zim.cfg to Configure Partitions and Restore images to the correct partitions
 
5. Test


WARNING! Changes should be tested in a non-production environment and all files backed up before making any alterations.


  1. Lookup Partition size from the projects.ini file

    The script changes made in this TID will use the information in the projects.ini file to determine the size of the OS partition required. The information in the projects.ini is set in the Windows Unattended settings of the project.

    Update zim.cfg to read the partition size information from the projects.ini file by adding the following lines shown in green;

    ; Read in project specific information
    File:Ini,Get,"%_ZimDir%projects.ini","%Lookup_Project%","Project_Image_Path",Project_Image_Path
    File:Ini,Get,"%_ZimDir%projects.ini","%Lookup_Project%","Project_OS",Project_OS
    File:Ini,Get,"%_ZimDir%projects.ini","%Lookup_Project%","Partition_Count",Partition_Count
    File:Ini,Get,"%_ZimDir%projects.ini","%Lookup_Project%","Driver_OS",Project_Driver_OS
    File:Ini,Get,"%_ZimDir%projects.ini","%Lookup_Project%","Base_Image",Base_Image
    File:Ini,Get,"%_ZimDir%projects.ini","%Lookup_Project%","Ztoolkit",Project_Ztoolkit
    File:Ini,Get,"%_ZimDir%projects.ini","%Lookup_Project%","Novcomp",Project_novcomp
    File:Ini,Get,"%_ZimDir%projects.ini","%Lookup_Project%","Efi_boot_image",Efi_boot_image
    File:Ini,Get,"%_ZimDir%projects.ini","%Lookup_Project%","Partition1_size",Partition1_size
    File:Ini,Get,"%_ZimDir%projects.ini","%Lookup_Project%","Partition2_size",Partition2_size
    
  2. Create ddrive.zmg file


    • Boot a machine using Windows PE media
    • Launch diskpart
    • Run the following diskpart commands to clear the disk and create a 400 MB NTFS partition
      select disk 0
      clean
      create partition primary size=400
      format fs=ntfs quick
      exit

      WARNING! These commands will wipe the entire disk! Do not run them on a production machine.
    • PXE boot machine to ZENworks Imaging Environment 
    • At the Zim menu, select Maintenance Menu and then Exit to Prompt 
    • At the bash prompt run the following command to create a d-drive image
      img -m -p projects/[project-folder]/ddrive.zmg
  3. UEFI machines - Update zim.cfg to Configure Partitions and then Restore images to the correct partitions

    Establish if the base image was created with one or two partitions to correctly determine the size of the OS partition required and create an additional partition if the machine type is a Laptop. Update zim.cfg with the lines shown in green;

    If:EFI,EXIST
        ; EFI machines
        ; Clear all partitions
        File:Run,"img -pd -all",verbose
    
        ; Create D:\ if the machine type is a laptop
        If:Var,machine_type,EQ,"laptop"
            File:Run,"img -pc 1 -type=FAT32 -size=260 -guid=ESP",verbose
            File:Run,"img -pc 2 -type=1 -size=128 -guid=MRP",verbose
            ; Check how many partitions the base image has a use the correct OS partition size
            If:var,Partition_count,eq,1
                File:Run,"img -pc 3 -type=NTFS -guid=MBD -size=%Partition1_size%",verbose
            Else:
                File:Run,"img -pc 3 -type=NTFS -guid=MBD -size=%Partition2_size%",verbose
            End:
            File:Run,"img -pc 4 -type=NTFS -guid=MBD",verbose
            File:Run,"cat imglogr >> /zimbin/zim.log",verbose
            ; Restore ddrive.zmg file
            File:Run,"img %ImgRestoreCmd%projects/%Project_Image_Path%/ddrive.zmg -ap=a1:p4",verbose
            File:Run,"cat imglogr >> /zimbin/zim.log",verbose
        Else:
    
            ; Create EFI boot, MSR and data partitions
            File:Run,"img -pc 1 -type=FAT32 -size=260 -guid=ESP",verbose
            File:Run,"img -pc 2 -type=1 -size=128 -guid=MRP",verbose
            File:Run,"img -pc 3 -type=NTFS -guid=MBD",verbose
                End:
        ; Activate EFI and MSR partitions
        File:Run,"img -pa1",verbose
        File:Run,"img -pa2",verbose
        ...
  4. BIOS machines - Update zim.cfg to Configure Partitions and then Restore images to the correct paritions

    Establish if the base image was created with one or two partitions to correctly determine the size of the OS partition required and create an additional partition if the machine type is a Laptop. Update zim.cfg with the lines shown in green;

    ; Partition restore section
    If:EFI,EXIST
        ...
        ...
        ...
    Else:
        ; BIOS Machines
                    ;Clear all partitions
        File:Run,"img -pd 3",verbose
        File:Run,"cat imglogr >> /zimbin/zim.log",verbose
        File:Run,"img -pd 2",verbose
        File:Run,"cat imglogr >> /zimbin/zim.log",verbose
        File:Run,"img -pd 1",verbose
        File:Run,"cat imglogr >> /zimbin/zim.log",verbose
        ; Create D:\ if the machine type is a laptop
        If:Var,machine_type,eq,"laptop"
            File:Run,"img -pc 1 -type=ntfs -size=%Partition1_size%",verbose
            File:Run,"cat imglogr >> /zimbin/zim.log",verbose
            File:Run,"img -pc 2 -type=ntfs -size=%Partition2_size%",verbose
            File:Run,"cat imglogr >> /zimbin/zim.log",verbose
            File:Run,"img -pc 3 -type=ntfs",verbose
            File:Run,"cat imglogr >> /zimbin/zim.log",verbose
            ; Restore ddrive.zmg file
            File:Run,"img %ImgRestoreCmd%projects/%Project_Image_Path%/ddrive.zmg -ap=a1:p3",verbose
            File:Run,"cat imglogr >> /zimbin/zim.log",verbose
        End:
        ; Set System partition as active
        File:Run,"img -pa1",verbose
        File:Run,"cat imglogr >> /zimbin/zim.log",verbose
        ; Restore images into the correct partitions
        If:Var,machine_type,eq,"laptop"
            If:Var,Partition_count,eq,1
                File:Run,"img %ImgRestoreCmd%os/%Project_OS%/%Base_Image%",verbose
                File:Run,"cat imglogr >> /zimbin/zim.log",verbose
            Else:
                File:Run,"img %ImgRestoreCmd%os/%Project_OS%/%Base_Image% -ap=a1:p1",verbose
                File:Run,"cat imglogr >> /zimbin/zim.log",verbose
                File:Run,"img %ImgRestoreCmd%os/%Project_OS%/%Base_Image% -ap=a2:p2",verbose
                File:Run,"cat imglogr >> /zimbin/zim.log",verbose
            End:
        Else:
            File:Run,"img %ImgRestoreCmd%os/%Project_OS%/%Base_Image%",verbose
            File:Run,"cat imglogr >> /zimbin/zim.log",verbose
        End:
        File:Run,"img %ImgRestoreCmd%projects/%Project_Image_Path%/hotfixes.zmg %Project_Partition%",verbose
        ...
     Save the changes to zim.cfg.

    NOTE: Review ENGL TID-2011007 "Capture img error codes to zim.log file" for more information on using the command line: File:Run,"cat imglogr >> /zimbin/zim.log",verbose
  5. Test

    Review the partition structure on the machine once the machine has built.

    • PXE boot a machine into Zim 
    • Select the Restore menu 
    • Select the project 
    • Continue to restore all images and allow the machine to build 
    • Once the machine has built successfully go into Disk Management and examine the partition structure 
  6.  If there are issues with the process review both the zim.log and ztoolkit.log to troubleshoot the problem. For more information about the log files review ENGL TID-2013016

    If you have any problems or questions about the steps in this TID please contact the ENGL support team