Skip to content

Latest commit

 

History

History
135 lines (97 loc) · 5.76 KB

building.md

File metadata and controls

135 lines (97 loc) · 5.76 KB

Building

Tutorial: Build a Demo VHD or VHDX

In the previous tutorials, we configured your build machine, walked through how to add packages, and described how to modify the kernel. In this tutorial, we will put it altogether and build a VHD or VHD(X) image.

Build Derivate VHD or VHDX

Choose an image to build by invoking one of the following build commands from the CBL-MarinerTutorials/toolkit folder.

sudo make image CONFIG_FILE=../imageconfigs/demo_vhd.json 
sudo make image CONFIG_FILE=../imageconfigs/demo_vhdx.json

The first time make image is invoked the toolkit downloads the necessary toolchain packages from the CBL-Mariner repository at packages.microsoft.com. These toolchain packages are the standard set needed to build any local packages contained in the CBL-MarinerTutorials repo. Once the toolchain is ready, make automatically proceeds to build any local packages. In this case, the Hello World and OS-Subrelease packages will be compiled. After all local packages are built, make will assemble the packages to build an image. The resulting binaries (images and rpms) are placed in the CBL-MarinerTutorials/out folder

VHDX:       `CBL-MarinerTutorials/out/images/demo_vhdx/`
VHD:        `CBL-MarinerTutorials/out/images/demo_vhd/`
PACKAGES:   `CBL-MarinerTutorials/out/RPMS/x86_64/`

Use Hyper-V to Boot Your Demo Image

Copy your demo VHD or VHDX image to your Windows Machine and boot it with Hyper-V.

Create VHD(X) Virtual Machine with Hyper-V

  1. From Hyper-V Select Action->New->Virtual Machine.
  2. Provide a name for your VM and press Next >.
  3. For VHD select Generation 1. For VHDX select Generation 2, then press Next >.
  4. Change Memory size if desired, then press Next >.
  5. Select a virtual switch, then press Next >.
  6. Select Use an existing virtual hard disk, then browse and select your VHD(X) file.
  7. Press Finish.

[Gen2/VHDX Only] Fix Boot Options

  1. Right click your virtual machine from Hyper-V Manager
  2. Select Settings...
  3. Select Security and under Template: select Microsoft UEFI Certificate Authority.

Disable Secure Boot

Note: If you followed any of the previous tutorials in Working with packages, the kernel is no longer signed and secure boot must be disabled in order to boot your VHD(X) image.

  1. Right click your virtual machine from Hyper-V Manager
  2. Select Settings...
  3. Select Security and uncheck the "Enable Secure Boot" box

Boot and Sign-In to Your VHD(X) Image

  1. Right click your VM and select Connect....
  2. Select Start.
  3. Wait for CBL-Mariner to boot to the login prompt, then sign in with:
    root
    p@ssw0rd

Verify your Derivate Packages are Installed From the command line run the helloworld program

```
root@demo [~]# helloworld
Hello World Sample!
```

Now show the contents of the os-subrelease file

```
root@demo [~]# cat /etc/os-subrelease
BUILDER_NAME=My Builder Name
BUILD_DATE="YYYY-MM-DDTHH:MM:SSZ"
ID=my-product-id
VERSION_ID=my-version-id
NAME="My Product Name"
VERSION="my-version-id"
```

Congratulations you've built and launched your first CBL-Mariner derivative image!

Tutorial: Build a Demo ISO

In the previous tutorial, we learned how to create a simple VHD(X) image. In this tutorial, we will turn our attention to creating a bootable ISO image for installing CBL-Mariner to either a physical machine or virtual hard drive.

Let's jump right in. Run the following command to build a demo ISO:

cd CBL-MarinerTutorials/toolkit
sudo make iso CONFIG_FILE=../imageconfigs/demo_iso.json

Copy ISO Image to Your VM Host Machine

Copy your binary image(s) to your VM Host Machine using your preferred technique.

Create VHD(X) Virtual Machine with Hyper-V

  1. From Hyper-V Select Action->New->Virtual Machine.
  2. Provide a name for your VM and press Next >.
  3. Select Generation 1 (VHD) or Generation 2 (VHDX), then press Next >.
  4. Change Memory size if desired, then press Next >.
  5. Select a virtual switch, then press Next >.
  6. Select Create a virtual hard disk, choose a location for your VHD(X) and set your desired disk Size. Then press Next >.
  7. Select Install an operating system from a bootable image file and browse to your demo ISO.
  8. Press Finish.

[Gen2/VHDX Only] Fix Boot Options

  1. Right click your virtual machine from Hyper-V Manager
  2. Select Settings...
  3. Select Security and under Template: select Microsoft UEFI Certificate Authority.
  4. Select Firmware and adjust the boot order so DVD is first and Hard Drive is second.
  5. Select Apply to apply all changes.

Disable Secure Boot

Note: If you followed any of the previous tutorials in Working with packages, the kernel is no longer signed and secure boot must be disabled in order to boot your VHD(X) image.

  1. Right click your virtual machine from Hyper-V Manager
  2. Select Settings...
  3. Select Security and uncheck the "Enable Secure Boot" box

Boot ISO

  1. Right click your VM and select Connect....
  2. Select Start.
  3. Follow the Installer Prompts to Install your image
  4. When installation completes, select restart to reboot the machine. The installation ISO will be automatically ejected.
  5. When prompted sign in to your CBL-Mariner system using the user name and password provisioned through the Installer.