3.16.7.2. Using a Modified Kickstart File

Because partitioned image creation is driven by the kickstart file, it is easy to affect image creation by changing the parameters in the file. This next example demonstrates that through modification of the directdisk-gpt kickstart file.

As mentioned earlier, you can use the command wic list images to show the list of existing kickstart files. The directory in which the directdisk-gpt.wks file resides is scripts/lib/image/canned-wks/, which is located in the Source Directory (e.g. poky). Because available files reside in this directory, you can create and add your own custom files to the directory. Subsequent use of the wic list images command would then include your kickstart files.

In this example, the existing directdisk-gpt file already does most of what is needed. However, for the hardware in this example, the image will need to boot from sdb instead of sda, which is what the directdisk-gpt kickstart file uses.

The example begins by making a copy of the directdisk-gpt.wks file in the scripts/lib/image/canned-wks directory and then by changing the lines that specify the target disk from which to boot.

     $ cp /home/stephano/poky/scripts/lib/wic/canned-wks/directdisk-gpt.wks \
          /home/stephano/poky/scripts/lib/wic/canned-wks/directdisksdb-gpt.wks
                    

Next, the example modifies the directdisksdb-gpt.wks file and changes all instances of "--ondisk sda" to "--ondisk sdb". The example changes the following two lines and leaves the remaining lines untouched:

     part /boot --source bootimg-pcbios --ondisk sdb --label boot --active --align 1024
     part / --source rootfs --ondisk sdb --fstype=ext4 --label platform --align 1024 --use-uuid
                    

Once the lines are changed, the example generates the directdisksdb-gpt image. The command points the process at the core-image-minimal artifacts for the Next Unit of Computing (nuc) MACHINE the local.conf.

     $ wic create directdisksdb-gpt -e core-image-minimal
     INFO: Building wic-tools...
                .
                .
                .
     Initialising tasks: 100% |#######################################| Time: 0:00:01
     NOTE: Executing SetScene Tasks
     NOTE: Executing RunQueue Tasks
     NOTE: Tasks Summary: Attempted 1161 tasks of which 1157 didn't need to be rerun and all succeeded.
     INFO: Creating image(s)...

     INFO: The new image(s) can be found here:
       ./directdisksdb-gpt-201710090938-sdb.direct

     The following build artifacts were used to create the image(s):
       ROOTFS_DIR:                   /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/rootfs
       BOOTIMG_DIR:                  /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share
       KERNEL_DIR:                   /home/stephano/build/master/build/tmp-glibc/deploy/images/qemux86
       NATIVE_SYSROOT:               /home/stephano/build/master/build/tmp-glibc/work/i586-oe-linux/wic-tools/1.0-r0/recipe-sysroot-native

     INFO: The image(s) were created using OE kickstart file:
       /home/stephano/poky/scripts/lib/wic/canned-wks/directdisksdb-gpt.wks
                    

Continuing with the example, you can now directly dd the image to a USB stick, or whatever media for which you built your image, and boot the resulting media:

     $ sudo dd if=directdisksdb-gpt-201710090938-sdb.direct of=/dev/sdb
     140966+0 records in
     140966+0 records out
     72174592 bytes (72 MB, 69 MiB) copied, 78.0282 s, 925 kB/s
     $ sudo eject /dev/sdb