Share via


Create a Stand-Alone Virtual Hard Disk for Virtual CEPC (Compact 7)

3/12/2014

You continue the process of creating a stand-alone virtual CEPC by creating a stand-alone virtual hard disk (VHD). This is a VHD that has both a boot loader and your stand-alone OS run-time image, so that your virtual CEPC can boot without having to download an OS image from Platform Builder.

After you create a stand-alone OS image, as described in Create a Stand-Alone OS Design for Virtual CEPC, use the following procedures on a computer running Windows 7 to create a custom VHD to use with your virtual CEPC. If you are using the boot loader that is included with Compact 7, you can use the DiskPrep tool to create your VHD. If you want to use your own custom boot loader, then you must create your VHD image manually.

Creating a Stand-Alone VHD with DiskPrep

The easiest way to create a stand-alone VHD image is to use the DiskPrep tool to create a VHD that contains the Compact 7 boot loader and your OS image. You can download DiskPrep from Windows Embedded CE DiskPrep PowerToy on MSDN Code Gallery. You can use DiskPrep to create a new VHD or use an existing VHD, but you cannot use DiskPrep on a VHD that is in use by a running virtual machine. As a safety precaution, DiskPrep will not present your boot, system, or swap volumes as possible target disks. Although DiskPrep runs on Windows 7 and Windows Vista, it requires Windows 7 to create a VHD.

To create a stand-alone VHD on Windows 7 

  1. Download the DiskPrep tool from MSDN Code Gallery.

  2. Double-click DiskPrep.exe.

  3. In the Disk Selection list of the DiskPrep window, select <VHD I create or specify when I click OK>.

  4. In the Use File System Format list, select FAT32.

  5. Select the Boot.ini options that are appropriate for your device. You can edit the Boot.ini file on the disk after you create it to change these settings.

    Warning

    Your virtual CEPC may not work correctly, or work at all, if the value for Physical Video Mode is not set correctly. If you do not have a preference, use 640x480.

  6. Click Load specific image file copied from, and then click Browse.

  7. Navigate to the KITL-disabled OS image (NK.bin) that you created earlier, click Open, and then click ok.

  8. In the Create or Select Virtual Disk dialog box, click Create a new Virtual Hard Disk (VHD).

  9. Type the name of the new VHD file. For example, if your virtual CEPC OS design folder resides at %_WINCEROOT%\OSDesigns\VIRTUAL CEPC, you could use the following path for your VHD: %_WINCEROOT%\OSDesigns\VIRTUAL CEPC\custom.vhd.

  10. In the Size in Megabytes box, enter a size of at least 255 MB for the VHD. You may need a larger size depending on the number of additional files that you intend to copy to your VHD.

  11. Click Static Size, and then click OK. Depending on the speed of your computer, DiskPrep may take a few seconds to begin the VHD creation process.

  12. When the Confirm Dangerous Action dialog box appears, click OK.

  13. When DiskPrep displays the message, Disk Preparation Completed ok, click OK.

After you have completed these steps, your VHD can be used to boot a virtual CEPC virtual machine without Platform Builder.

Creating a Stand-Alone VHD Manually

The most general way to create a stand-alone VHD image is to use the Compact 7 Disk Management tool to create your VHD and use the cesys tool to embed a boot loader in your VHD. Use this method if you do not want to use DiskPrep or if you need to create a VHD with your own boot loader.

To manually create a stand-alone VHD on Windows 7 

  1. On your host computer, click Start, and then click Run.

  2. In the Open box, type diskmgmt.msc, and then press Enter to start the Disk Management tool.

  3. On the Action menu, click Create VHD.

  4. In the Create and Attach Virtual Hard Disk dialog box, type the location on your host computer where you want the VHD file to be stored. For example, if your virtual CEPC OS design folder resides at %_WINCEROOT%\OSDesigns\VIRTUAL CEPC, you could use the following path for your VHD: %_WINCEROOT%\OSDesigns\VIRTUAL CEPC\custom.vhd.

  5. In the Virtual hard disk size box, enter a size of at least 255 MB for the VHD. You may need a larger size depending on the number of additional files that you intend to copy to your VHD.

  6. Under Virtual hard disk format, select Fixed size (Recommended) as shown in the following example, and then click OK.

    Create and Attach Virtual Hard Disk

The new VHD appears in the list of drives, marked as Not Initialized and containing an empty partition marked as Unallocated as shown in the following figure.

New Virtual Hard Disk Partition

To create the volume on the VHD

  1. In the Disk Management tool, right-click the new VHD, and then select Initialize Disk.

  2. When the Initialize Disk dialog box appears, verify that the selected disk is the one that you created.

  3. Click MBR (Master Boot Record) for the partition style, and then click OK.

  4. Right-click the unallocated disk partition, and then select New Simple Volume as shown in the following figure.

    New Simple Volume

  5. In the New Simple Volume Wizard, click Next until you reach the Format Partition page, and then do the following:

    1. In the File System list, select FAT32.
    2. Clear the Volume label box to make the volume label blank. The New Simple Volume Wizard appears as shown in the following example.

    New Simple Volume Wizard

    Important

    If Volume label is not blank, you will be unable to embed a boot loader in this VHD in the next series of steps. You can set the volume label after you have embedded the boot loader.

  6. Click Next, and then click Finish.

To activate the VHD

  1. In the Disk Management tool, right-click the partition that you created, and then select Mark Partition as Active.

  2. To exit the Disk Management tool, click the File menu, and then click Exit.

  3. Click Start, and then click Computer to view the drives on your host computer to verify that you succeeded in activating your VHD. After you activate the VHD, the new VHD displays with a new drive letter as shown in the following example.

New VHD Drive

You may see a different drive letter depending on the number of other drives in your host computer. Remember the drive letter assigned to your VHD so that you can use it in the following procedure.

To add the boot loader to the VHD

  1. Click Start, click All Programs, click Accessories, right-click Command Prompt, and then select Run as administrator.

  2. Add %_WINCEROOT%\platform\VirtualPC\src\boot\i386 to your PATH environment variable. For example, if your Compact 7 installation is located at the default path C:\WINCE700, you would enter the following command in the Command Prompt window:

    PATH = %PATH%;C:\WINCE700\platform\VirtualPC\src\boot\tools\bin\i386

  3. Open the release folder for your virtual CEPC. If you named your virtual CEPC OS design "VIRTUAL CEPC" as shown in examples throughout this development guide, you can enter the following command in the Command Prompt window:

    chdir /D C:\WINCE700\OSDesigns\VIRTUAL CEPC\VIRTUAL CEPC\RelDir\VirtualPC_x86_Release
    
  4. Use the cesys tool to embed the boot loader in your VHD, passing it the drive letter for the VHD that you created. For example, if your VHD has the drive letter G:, enter the following command:

    cesys G: wceldrC -f

    When the cesys command successfully installs the boot loader, you will see a message similar to the following:

    Boot Loader transferred on drive G:

  5. If message, Cannot obtain exclusive access to drive . . . displays, close all other windows and applications, and retry the cesys command. Typically, this error occurs if the Disk Management tool is still running or if a Windows Explorer window is open. If this message continues to display after closing all windows and applications, then your antivirus application may be the cause.

After you have completed these steps, your VHD will have a boot loader that your virtual CEPC can use to boot from the VHD. This boot loader, when it starts, will check for the existence of the file NK.bin (your OS image) in the VHD partition, copy it to virtual CEPC memory, and transfer control to this OS image to start Compact 7.

Note

You must embed the boot loader in your VHD before you copy any files to the VHD. If you attempt to embed the boot loader after copying files to the VHD, you will see a message similar the following when you attempt to boot your virtual CEPC:

Microsoft Windows CE XLDR Version 1.0 (Built Apr 20 2011 15:44:40)
BootLoader Record Checksum Verification Failed!
*** Spin For Ever ***

You can remedy this error by using the Disk Management tool to reformat the VHD disk partition as described in the To Activate the VHD procedure, and then re-embedding the boot loader by using the cesys command, as described in this procedure.

In the next series of steps, you will add your NK.bin (OS image) to your VHD.

To add an OS image to the VHD

  1. Locate the OS image file for your OS design (NK.bin). For example, if your OS design resides in %_WINCEROOT%\OSDesigns\VIRTUAL CEPC, the path to the NK.bin file is:

    C:\WINCE700\OSDesigns\VIRTUAL CEPC\VIRTUAL CEPC\RelDir\VirtualPC_x86_Release\NK.bin

  2. Copy NK.bin to your VHD. For example, if your NK.bin resides at the path in the previous example and your VHD has drive letter G:, you would use the following commands:

    chdir /D C:\WINCE700\OSDesigns\VIRTUAL CEPC\VIRTUAL CEPC\RelDir\VirtualPC_x86_Release
    copy NK.bin G:
    

Note

By default, the OS image name used by the boot loader is NK.bin. If the file name for your OS image is not NK.bin, you must rename it to NK.bin before copying it to your VHD drive.

After you have completed these steps, you can use your VHD to boot a virtual CEPC virtual machine without Platform Builder. Next, you will prepare your virtual CEPC to use this VHD.

See Also

Concepts

Create a Stand-Alone Virtual CEPC