wic.rst 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731
  1. .. SPDX-License-Identifier: CC-BY-SA-2.0-UK
  2. Creating Partitioned Images Using Wic
  3. *************************************
  4. Creating an image for a particular hardware target using the
  5. OpenEmbedded build system does not necessarily mean you can boot that
  6. image as is on your device. Physical devices accept and boot images in
  7. various ways depending on the specifics of the device. Usually,
  8. information about the hardware can tell you what image format the device
  9. requires. Should your device require multiple partitions on an SD card,
  10. flash, or an HDD, you can use the OpenEmbedded Image Creator, Wic, to
  11. create the properly partitioned image.
  12. The ``wic`` command generates partitioned images from existing
  13. OpenEmbedded build artifacts. Image generation is driven by partitioning
  14. commands contained in an OpenEmbedded kickstart file (``.wks``)
  15. specified either directly on the command line or as one of a selection
  16. of canned kickstart files as shown with the ``wic list images`` command
  17. in the
  18. ":ref:`dev-manual/wic:generate an image using an existing kickstart file`"
  19. section. When you apply the command to a given set of build artifacts, the
  20. result is an image or set of images that can be directly written onto media and
  21. used on a particular system.
  22. .. note::
  23. For a kickstart file reference, see the
  24. ":ref:`ref-manual/kickstart:openembedded kickstart (\`\`.wks\`\`) reference`"
  25. Chapter in the Yocto Project Reference Manual.
  26. The ``wic`` command and the infrastructure it is based on is by
  27. definition incomplete. The purpose of the command is to allow the
  28. generation of customized images, and as such, was designed to be
  29. completely extensible through a plugin interface. See the
  30. ":ref:`dev-manual/wic:using the wic plugin interface`" section
  31. for information on these plugins.
  32. This section provides some background information on Wic, describes what
  33. you need to have in place to run the tool, provides instruction on how
  34. to use the Wic utility, provides information on using the Wic plugins
  35. interface, and provides several examples that show how to use Wic.
  36. Background
  37. ==========
  38. This section provides some background on the Wic utility. While none of
  39. this information is required to use Wic, you might find it interesting.
  40. - The name "Wic" is derived from OpenEmbedded Image Creator (oeic). The
  41. "oe" diphthong in "oeic" was promoted to the letter "w", because
  42. "oeic" is both difficult to remember and to pronounce.
  43. - Wic is loosely based on the Meego Image Creator (``mic``) framework.
  44. The Wic implementation has been heavily modified to make direct use
  45. of OpenEmbedded build artifacts instead of package installation and
  46. configuration, which are already incorporated within the OpenEmbedded
  47. artifacts.
  48. - Wic is a completely independent standalone utility that initially
  49. provides easier-to-use and more flexible replacements for an existing
  50. functionality in OE-Core's :ref:`ref-classes-image-live`
  51. class. The difference between Wic and those examples is that with Wic
  52. the functionality of those scripts is implemented by a
  53. general-purpose partitioning language, which is based on Redhat
  54. kickstart syntax.
  55. Requirements
  56. ============
  57. In order to use the Wic utility with the OpenEmbedded Build system, your
  58. system needs to meet the following requirements:
  59. - The Linux distribution on your development host must support the
  60. Yocto Project. See the ":ref:`system-requirements-supported-distros`"
  61. section in the Yocto Project Reference Manual for the list of
  62. distributions that support the Yocto Project.
  63. - The standard system utilities, such as ``cp``, must be installed on
  64. your development host system.
  65. - You must have sourced the build environment setup script (i.e.
  66. :ref:`structure-core-script`) found in the :term:`Build Directory`.
  67. - You need to have the build artifacts already available, which
  68. typically means that you must have already created an image using the
  69. OpenEmbedded build system (e.g. ``core-image-minimal``). While it
  70. might seem redundant to generate an image in order to create an image
  71. using Wic, the current version of Wic requires the artifacts in the
  72. form generated by the OpenEmbedded build system.
  73. - You must build several native tools, which are built to run on the
  74. build system::
  75. $ bitbake wic-tools
  76. - Include "wic" as part of the
  77. :term:`IMAGE_FSTYPES`
  78. variable.
  79. - Include the name of the :ref:`wic kickstart file <openembedded-kickstart-wks-reference>`
  80. as part of the :term:`WKS_FILE` variable. If multiple candidate files can
  81. be provided by different layers, specify all the possible names through the
  82. :term:`WKS_FILES` variable instead.
  83. Getting Help
  84. ============
  85. You can get general help for the ``wic`` command by entering the ``wic``
  86. command by itself or by entering the command with a help argument as
  87. follows::
  88. $ wic -h
  89. $ wic --help
  90. $ wic help
  91. Currently, Wic supports seven commands: ``cp``, ``create``, ``help``,
  92. ``list``, ``ls``, ``rm``, and ``write``. You can get help for all these
  93. commands except "help" by using the following form::
  94. $ wic help command
  95. For example, the following command returns help for the ``write``
  96. command::
  97. $ wic help write
  98. Wic supports help for three topics: ``overview``, ``plugins``, and
  99. ``kickstart``. You can get help for any topic using the following form::
  100. $ wic help topic
  101. For example, the following returns overview help for Wic::
  102. $ wic help overview
  103. There is one additional level of help for Wic. You can get help on
  104. individual images through the ``list`` command. You can use the ``list``
  105. command to return the available Wic images as follows::
  106. $ wic list images
  107. genericx86 Create an EFI disk image for genericx86*
  108. beaglebone-yocto Create SD card image for Beaglebone
  109. qemuriscv Create qcow2 image for RISC-V QEMU machines
  110. mkefidisk Create an EFI disk image
  111. qemuloongarch Create qcow2 image for LoongArch QEMU machines
  112. directdisk-multi-rootfs Create multi rootfs image using rootfs plugin
  113. directdisk Create a 'pcbios' direct disk image
  114. efi-bootdisk
  115. mkhybridiso Create a hybrid ISO image
  116. directdisk-gpt Create a 'pcbios' direct disk image
  117. systemd-bootdisk Create an EFI disk image with systemd-boot
  118. sdimage-bootpart Create SD card image with a boot partition
  119. qemux86-directdisk Create a qemu machine 'pcbios' direct disk image
  120. directdisk-bootloader-config Create a 'pcbios' direct disk image with custom bootloader config
  121. Once you know the list of available
  122. Wic images, you can use ``help`` with the command to get help on a
  123. particular image. For example, the following command returns help on the
  124. "beaglebone-yocto" image::
  125. $ wic list beaglebone-yocto help
  126. Creates a partitioned SD card image for Beaglebone.
  127. Boot files are located in the first vfat partition.
  128. Operational Modes
  129. =================
  130. You can use Wic in two different modes, depending on how much control
  131. you need for specifying the OpenEmbedded build artifacts that are used
  132. for creating the image: Raw and Cooked:
  133. - *Raw Mode:* You explicitly specify build artifacts through Wic
  134. command-line arguments.
  135. - *Cooked Mode:* The current
  136. :term:`MACHINE` setting and image
  137. name are used to automatically locate and provide the build
  138. artifacts. You just supply a kickstart file and the name of the image
  139. from which to use artifacts.
  140. Regardless of the mode you use, you need to have the build artifacts
  141. ready and available.
  142. Raw Mode
  143. --------
  144. Running Wic in raw mode allows you to specify all the partitions through
  145. the ``wic`` command line. The primary use for raw mode is if you have
  146. built your kernel outside of the Yocto Project :term:`Build Directory`.
  147. In other words, you can point to arbitrary kernel, root filesystem locations,
  148. and so forth. Contrast this behavior with cooked mode where Wic looks in the
  149. :term:`Build Directory` (e.g. ``tmp/deploy/images/``\ machine).
  150. The general form of the ``wic`` command in raw mode is::
  151. $ wic create wks_file options ...
  152. Where:
  153. wks_file:
  154. An OpenEmbedded kickstart file. You can provide
  155. your own custom file or use a file from a set of
  156. existing files as described by further options.
  157. optional arguments:
  158. -h, --help show this help message and exit
  159. -o OUTDIR, --outdir OUTDIR
  160. name of directory to create image in
  161. -e IMAGE_NAME, --image-name IMAGE_NAME
  162. name of the image to use the artifacts from e.g. core-
  163. image-sato
  164. -r ROOTFS_DIR, --rootfs-dir ROOTFS_DIR
  165. path to the /rootfs dir to use as the .wks rootfs
  166. source
  167. -b BOOTIMG_DIR, --bootimg-dir BOOTIMG_DIR
  168. path to the dir containing the boot artifacts (e.g.
  169. /EFI or /syslinux dirs) to use as the .wks bootimg
  170. source
  171. -k KERNEL_DIR, --kernel-dir KERNEL_DIR
  172. path to the dir containing the kernel to use in the
  173. .wks bootimg
  174. -n NATIVE_SYSROOT, --native-sysroot NATIVE_SYSROOT
  175. path to the native sysroot containing the tools to use
  176. to build the image
  177. -s, --skip-build-check
  178. skip the build check
  179. -f, --build-rootfs build rootfs
  180. -c {gzip,bzip2,xz}, --compress-with {gzip,bzip2,xz}
  181. compress image with specified compressor
  182. -m, --bmap generate .bmap
  183. --no-fstab-update Do not change fstab file.
  184. -v VARS_DIR, --vars VARS_DIR
  185. directory with <image>.env files that store bitbake
  186. variables
  187. -D, --debug output debug information
  188. .. note::
  189. You do not need root privileges to run Wic. In fact, you should not
  190. run as root when using the utility.
  191. Cooked Mode
  192. -----------
  193. Running Wic in cooked mode leverages off artifacts in the
  194. :term:`Build Directory`. In other words, you do not have to specify kernel or
  195. root filesystem locations as part of the command. All you need to provide is
  196. a kickstart file and the name of the image from which to use artifacts
  197. by using the "-e" option. Wic looks in the :term:`Build Directory` (e.g.
  198. ``tmp/deploy/images/``\ machine) for artifacts.
  199. The general form of the ``wic`` command using Cooked Mode is as follows::
  200. $ wic create wks_file -e IMAGE_NAME
  201. Where:
  202. wks_file:
  203. An OpenEmbedded kickstart file. You can provide
  204. your own custom file or use a file from a set of
  205. existing files provided with the Yocto Project
  206. release.
  207. required argument:
  208. -e IMAGE_NAME, --image-name IMAGE_NAME
  209. name of the image to use the artifacts from e.g. core-
  210. image-sato
  211. Using an Existing Kickstart File
  212. ================================
  213. If you do not want to create your own kickstart file, you can use an
  214. existing file provided by the Wic installation. As shipped, kickstart
  215. files can be found in the :ref:`overview-manual/development-environment:yocto project source repositories` in the
  216. following two locations::
  217. poky/meta-yocto-bsp/wic
  218. poky/scripts/lib/wic/canned-wks
  219. Use the following command to list the available kickstart files::
  220. $ wic list images
  221. genericx86 Create an EFI disk image for genericx86*
  222. beaglebone-yocto Create SD card image for Beaglebone
  223. qemuriscv Create qcow2 image for RISC-V QEMU machines
  224. mkefidisk Create an EFI disk image
  225. qemuloongarch Create qcow2 image for LoongArch QEMU machines
  226. directdisk-multi-rootfs Create multi rootfs image using rootfs plugin
  227. directdisk Create a 'pcbios' direct disk image
  228. efi-bootdisk
  229. mkhybridiso Create a hybrid ISO image
  230. directdisk-gpt Create a 'pcbios' direct disk image
  231. systemd-bootdisk Create an EFI disk image with systemd-boot
  232. sdimage-bootpart Create SD card image with a boot partition
  233. qemux86-directdisk Create a qemu machine 'pcbios' direct disk image
  234. directdisk-bootloader-config Create a 'pcbios' direct disk image with custom bootloader config
  235. When you use an existing file, you
  236. do not have to use the ``.wks`` extension. Here is an example in Raw
  237. Mode that uses the ``directdisk`` file::
  238. $ wic create directdisk -r rootfs_dir -b bootimg_dir \
  239. -k kernel_dir -n native_sysroot
  240. Here are the actual partition language commands used in the
  241. ``genericx86.wks`` file to generate an image::
  242. # short-description: Create an EFI disk image for genericx86*
  243. # long-description: Creates a partitioned EFI disk image for genericx86* machines
  244. part /boot --source bootimg-efi --sourceparams="loader=grub-efi" --ondisk sda --label msdos --active --align 1024
  245. part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024 --use-uuid
  246. part swap --ondisk sda --size 44 --label swap1 --fstype=swap
  247. bootloader --ptable gpt --timeout=5 --append="rootfstype=ext4 console=ttyS0,115200 console=tty0"
  248. Using the Wic Plugin Interface
  249. ==============================
  250. You can extend and specialize Wic functionality by using Wic plugins.
  251. This section explains the Wic plugin interface.
  252. .. note::
  253. Wic plugins consist of "source" and "imager" plugins. Imager plugins
  254. are beyond the scope of this section.
  255. Source plugins provide a mechanism to customize partition content during
  256. the Wic image generation process. You can use source plugins to map
  257. values that you specify using ``--source`` commands in kickstart files
  258. (i.e. ``*.wks``) to a plugin implementation used to populate a given
  259. partition.
  260. .. note::
  261. If you use plugins that have build-time dependencies (e.g. native
  262. tools, bootloaders, and so forth) when building a Wic image, you need
  263. to specify those dependencies using the :term:`WKS_FILE_DEPENDS`
  264. variable.
  265. Source plugins are subclasses defined in plugin files. As shipped, the
  266. Yocto Project provides several plugin files. You can see the source
  267. plugin files that ship with the Yocto Project
  268. :yocto_git:`here </poky/tree/scripts/lib/wic/plugins/source>`.
  269. Each of these plugin files contains source plugins that are designed to
  270. populate a specific Wic image partition.
  271. Source plugins are subclasses of the ``SourcePlugin`` class, which is
  272. defined in the ``poky/scripts/lib/wic/pluginbase.py`` file. For example,
  273. the ``BootimgEFIPlugin`` source plugin found in the ``bootimg-efi.py``
  274. file is a subclass of the ``SourcePlugin`` class, which is found in the
  275. ``pluginbase.py`` file.
  276. You can also implement source plugins in a layer outside of the Source
  277. Repositories (external layer). To do so, be sure that your plugin files
  278. are located in a directory whose path is
  279. ``scripts/lib/wic/plugins/source/`` within your external layer. When the
  280. plugin files are located there, the source plugins they contain are made
  281. available to Wic.
  282. When the Wic implementation needs to invoke a partition-specific
  283. implementation, it looks for the plugin with the same name as the
  284. ``--source`` parameter used in the kickstart file given to that
  285. partition. For example, if the partition is set up using the following
  286. command in a kickstart file::
  287. part /boot --source bootimg-pcbios --ondisk sda --label boot --active --align 1024
  288. The methods defined as class
  289. members of the matching source plugin (i.e. ``bootimg-pcbios``) in the
  290. ``bootimg-pcbios.py`` plugin file are used.
  291. To be more concrete, here is the corresponding plugin definition from
  292. the ``bootimg-pcbios.py`` file for the previous command along with an
  293. example method called by the Wic implementation when it needs to prepare
  294. a partition using an implementation-specific function::
  295. .
  296. .
  297. .
  298. class BootimgPcbiosPlugin(SourcePlugin):
  299. """
  300. Create MBR boot partition and install syslinux on it.
  301. """
  302. name = 'bootimg-pcbios'
  303. .
  304. .
  305. .
  306. @classmethod
  307. def do_prepare_partition(cls, part, source_params, creator, cr_workdir,
  308. oe_builddir, bootimg_dir, kernel_dir,
  309. rootfs_dir, native_sysroot):
  310. """
  311. Called to do the actual content population for a partition i.e. it
  312. 'prepares' the partition to be incorporated into the image.
  313. In this case, prepare content for legacy bios boot partition.
  314. """
  315. .
  316. .
  317. .
  318. If a
  319. subclass (plugin) itself does not implement a particular function, Wic
  320. locates and uses the default version in the superclass. It is for this
  321. reason that all source plugins are derived from the ``SourcePlugin``
  322. class.
  323. The ``SourcePlugin`` class defined in the ``pluginbase.py`` file defines
  324. a set of methods that source plugins can implement or override. Any
  325. plugins (subclass of ``SourcePlugin``) that do not implement a
  326. particular method inherit the implementation of the method from the
  327. ``SourcePlugin`` class. For more information, see the ``SourcePlugin``
  328. class in the ``pluginbase.py`` file for details:
  329. The following list describes the methods implemented in the
  330. ``SourcePlugin`` class:
  331. - ``do_prepare_partition()``: Called to populate a partition with
  332. actual content. In other words, the method prepares the final
  333. partition image that is incorporated into the disk image.
  334. - ``do_configure_partition()``: Called before
  335. ``do_prepare_partition()`` to create custom configuration files for a
  336. partition (e.g. syslinux or grub configuration files).
  337. - ``do_install_disk()``: Called after all partitions have been
  338. prepared and assembled into a disk image. This method provides a hook
  339. to allow finalization of a disk image (e.g. writing an MBR).
  340. - ``do_stage_partition()``: Special content-staging hook called
  341. before ``do_prepare_partition()``. This method is normally empty.
  342. Typically, a partition just uses the passed-in parameters (e.g. the
  343. unmodified value of ``bootimg_dir``). However, in some cases, things
  344. might need to be more tailored. As an example, certain files might
  345. additionally need to be taken from ``bootimg_dir + /boot``. This hook
  346. allows those files to be staged in a customized fashion.
  347. .. note::
  348. ``get_bitbake_var()`` allows you to access non-standard variables that
  349. you might want to use for this behavior.
  350. You can extend the source plugin mechanism. To add more hooks, create
  351. more source plugin methods within ``SourcePlugin`` and the corresponding
  352. derived subclasses. The code that calls the plugin methods uses the
  353. ``plugin.get_source_plugin_methods()`` function to find the method or
  354. methods needed by the call. Retrieval of those methods is accomplished
  355. by filling up a dict with keys that contain the method names of
  356. interest. On success, these will be filled in with the actual methods.
  357. See the Wic implementation for examples and details.
  358. Wic Examples
  359. ============
  360. This section provides several examples that show how to use the Wic
  361. utility. All the examples assume the list of requirements in the
  362. ":ref:`dev-manual/wic:requirements`" section have been met. The
  363. examples assume the previously generated image is
  364. ``core-image-minimal``.
  365. Generate an Image using an Existing Kickstart File
  366. --------------------------------------------------
  367. This example runs in Cooked Mode and uses the ``mkefidisk`` kickstart
  368. file::
  369. $ wic create mkefidisk -e core-image-minimal
  370. INFO: Building wic-tools...
  371. .
  372. .
  373. .
  374. INFO: The new image(s) can be found here:
  375. ./mkefidisk-201804191017-sda.direct
  376. The following build artifacts were used to create the image(s):
  377. ROOTFS_DIR: /home/stephano/yocto/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/rootfs
  378. BOOTIMG_DIR: /home/stephano/yocto/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share
  379. KERNEL_DIR: /home/stephano/yocto/build/tmp-glibc/deploy/images/qemux86
  380. NATIVE_SYSROOT: /home/stephano/yocto/build/tmp-glibc/work/i586-oe-linux/wic-tools/1.0-r0/recipe-sysroot-native
  381. INFO: The image(s) were created using OE kickstart file:
  382. /home/stephano/yocto/openembedded-core/scripts/lib/wic/canned-wks/mkefidisk.wks
  383. The previous example shows the easiest way to create an image by running
  384. in cooked mode and supplying a kickstart file and the "-e" option to
  385. point to the existing build artifacts. Your ``local.conf`` file needs to
  386. have the :term:`MACHINE` variable set
  387. to the machine you are using, which is "qemux86" in this example.
  388. Once the image builds, the output provides image location, artifact use,
  389. and kickstart file information.
  390. .. note::
  391. You should always verify the details provided in the output to make
  392. sure that the image was indeed created exactly as expected.
  393. Continuing with the example, you can now write the image from the
  394. :term:`Build Directory` onto a USB stick, or whatever media for which you
  395. built your image, and boot from the media. You can write the image by using
  396. ``bmaptool`` or ``dd``::
  397. $ oe-run-native bmaptool-native bmaptool copy mkefidisk-201804191017-sda.direct /dev/sdX
  398. or ::
  399. $ sudo dd if=mkefidisk-201804191017-sda.direct of=/dev/sdX
  400. .. note::
  401. For more information on how to use the ``bmaptool``
  402. to flash a device with an image, see the
  403. ":ref:`dev-manual/bmaptool:flashing images using \`bmaptool\``"
  404. section.
  405. Using a Modified Kickstart File
  406. -------------------------------
  407. Because partitioned image creation is driven by the kickstart file, it
  408. is easy to affect image creation by changing the parameters in the file.
  409. This next example demonstrates that through modification of the
  410. ``directdisk-gpt`` kickstart file.
  411. As mentioned earlier, you can use the command ``wic list images`` to
  412. show the list of existing kickstart files. The directory in which the
  413. ``directdisk-gpt.wks`` file resides is
  414. ``scripts/lib/image/canned-wks/``, which is located in the
  415. :term:`Source Directory` (e.g. ``poky``).
  416. Because available files reside in this directory, you can create and add
  417. your own custom files to the directory. Subsequent use of the
  418. ``wic list images`` command would then include your kickstart files.
  419. In this example, the existing ``directdisk-gpt`` file already does most
  420. of what is needed. However, for the hardware in this example, the image
  421. will need to boot from ``sdb`` instead of ``sda``, which is what the
  422. ``directdisk-gpt`` kickstart file uses.
  423. The example begins by making a copy of the ``directdisk-gpt.wks`` file
  424. in the ``scripts/lib/image/canned-wks`` directory and then by changing
  425. the lines that specify the target disk from which to boot::
  426. $ cp /home/stephano/yocto/poky/scripts/lib/wic/canned-wks/directdisk-gpt.wks \
  427. /home/stephano/yocto/poky/scripts/lib/wic/canned-wks/directdisksdb-gpt.wks
  428. Next, the example modifies the ``directdisksdb-gpt.wks`` file and
  429. changes all instances of "``--ondisk sda``" to "``--ondisk sdb``". The
  430. example changes the following two lines and leaves the remaining lines
  431. untouched::
  432. part /boot --source bootimg-pcbios --ondisk sdb --label boot --active --align 1024
  433. part / --source rootfs --ondisk sdb --fstype=ext4 --label platform --align 1024 --use-uuid
  434. Once the lines are changed, the
  435. example generates the ``directdisksdb-gpt`` image. The command points
  436. the process at the ``core-image-minimal`` artifacts for the Next Unit of
  437. Computing (nuc) :term:`MACHINE` the
  438. ``local.conf``::
  439. $ wic create directdisksdb-gpt -e core-image-minimal
  440. INFO: Building wic-tools...
  441. .
  442. .
  443. .
  444. Initialising tasks: 100% |#######################################| Time: 0:00:01
  445. NOTE: Executing SetScene Tasks
  446. NOTE: Executing RunQueue Tasks
  447. NOTE: Tasks Summary: Attempted 1161 tasks of which 1157 didn't need to be rerun and all succeeded.
  448. INFO: Creating image(s)...
  449. INFO: The new image(s) can be found here:
  450. ./directdisksdb-gpt-201710090938-sdb.direct
  451. The following build artifacts were used to create the image(s):
  452. ROOTFS_DIR: /home/stephano/yocto/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/rootfs
  453. BOOTIMG_DIR: /home/stephano/yocto/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share
  454. KERNEL_DIR: /home/stephano/yocto/build/tmp-glibc/deploy/images/qemux86
  455. NATIVE_SYSROOT: /home/stephano/yocto/build/tmp-glibc/work/i586-oe-linux/wic-tools/1.0-r0/recipe-sysroot-native
  456. INFO: The image(s) were created using OE kickstart file:
  457. /home/stephano/yocto/poky/scripts/lib/wic/canned-wks/directdisksdb-gpt.wks
  458. Continuing with the example, you can now directly ``dd`` the image to a
  459. USB stick, or whatever media for which you built your image, and boot
  460. the resulting media::
  461. $ sudo dd if=directdisksdb-gpt-201710090938-sdb.direct of=/dev/sdb
  462. 140966+0 records in
  463. 140966+0 records out
  464. 72174592 bytes (72 MB, 69 MiB) copied, 78.0282 s, 925 kB/s
  465. $ sudo eject /dev/sdb
  466. Using a Modified Kickstart File and Running in Raw Mode
  467. -------------------------------------------------------
  468. This next example manually specifies each build artifact (runs in Raw
  469. Mode) and uses a modified kickstart file. The example also uses the
  470. ``-o`` option to cause Wic to create the output somewhere other than the
  471. default output directory, which is the current directory::
  472. $ wic create test.wks -o /home/stephano/testwic \
  473. --rootfs-dir /home/stephano/yocto/build/tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/rootfs \
  474. --bootimg-dir /home/stephano/yocto/build/tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share \
  475. --kernel-dir /home/stephano/yocto/build/tmp/deploy/images/qemux86 \
  476. --native-sysroot /home/stephano/yocto/build/tmp/work/i586-poky-linux/wic-tools/1.0-r0/recipe-sysroot-native
  477. INFO: Creating image(s)...
  478. INFO: The new image(s) can be found here:
  479. /home/stephano/testwic/test-201710091445-sdb.direct
  480. The following build artifacts were used to create the image(s):
  481. ROOTFS_DIR: /home/stephano/yocto/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/rootfs
  482. BOOTIMG_DIR: /home/stephano/yocto/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share
  483. KERNEL_DIR: /home/stephano/yocto/build/tmp-glibc/deploy/images/qemux86
  484. NATIVE_SYSROOT: /home/stephano/yocto/build/tmp-glibc/work/i586-oe-linux/wic-tools/1.0-r0/recipe-sysroot-native
  485. INFO: The image(s) were created using OE kickstart file:
  486. test.wks
  487. For this example,
  488. :term:`MACHINE` did not have to be
  489. specified in the ``local.conf`` file since the artifact is manually
  490. specified.
  491. Using Wic to Manipulate an Image
  492. --------------------------------
  493. Wic image manipulation allows you to shorten turnaround time during
  494. image development. For example, you can use Wic to delete the kernel
  495. partition of a Wic image and then insert a newly built kernel. This
  496. saves you time from having to rebuild the entire image each time you
  497. modify the kernel.
  498. .. note::
  499. In order to use Wic to manipulate a Wic image as in this example,
  500. your development machine must have the ``mtools`` package installed.
  501. The following example examines the contents of the Wic image, deletes
  502. the existing kernel, and then inserts a new kernel:
  503. #. *List the Partitions:* Use the ``wic ls`` command to list all the
  504. partitions in the Wic image::
  505. $ wic ls tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic
  506. Num Start End Size Fstype
  507. 1 1048576 25041919 23993344 fat16
  508. 2 25165824 72157183 46991360 ext4
  509. The previous output shows two partitions in the
  510. ``core-image-minimal-qemux86.wic`` image.
  511. #. *Examine a Particular Partition:* Use the ``wic ls`` command again
  512. but in a different form to examine a particular partition.
  513. .. note::
  514. You can get command usage on any Wic command using the following
  515. form::
  516. $ wic help command
  517. For example, the following command shows you the various ways to
  518. use the
  519. wic ls
  520. command::
  521. $ wic help ls
  522. The following command shows what is in partition one::
  523. $ wic ls tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic:1
  524. Volume in drive : is boot
  525. Volume Serial Number is E894-1809
  526. Directory for ::/
  527. libcom32 c32 186500 2017-10-09 16:06
  528. libutil c32 24148 2017-10-09 16:06
  529. syslinux cfg 220 2017-10-09 16:06
  530. vesamenu c32 27104 2017-10-09 16:06
  531. vmlinuz 6904608 2017-10-09 16:06
  532. 5 files 7 142 580 bytes
  533. 16 582 656 bytes free
  534. The previous output shows five files, with the
  535. ``vmlinuz`` being the kernel.
  536. .. note::
  537. If you see the following error, you need to update or create a
  538. ``~/.mtoolsrc`` file and be sure to have the line "mtools_skip_check=1"
  539. in the file. Then, run the Wic command again::
  540. ERROR: _exec_cmd: /usr/bin/mdir -i /tmp/wic-parttfokuwra ::/ returned '1' instead of 0
  541. output: Total number of sectors (47824) not a multiple of sectors per track (32)!
  542. Add mtools_skip_check=1 to your .mtoolsrc file to skip this test
  543. #. *Remove the Old Kernel:* Use the ``wic rm`` command to remove the
  544. ``vmlinuz`` file (kernel)::
  545. $ wic rm tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic:1/vmlinuz
  546. #. *Add In the New Kernel:* Use the ``wic cp`` command to add the
  547. updated kernel to the Wic image. Depending on how you built your
  548. kernel, it could be in different places. If you used ``devtool`` and
  549. an SDK to build your kernel, it resides in the ``tmp/work`` directory
  550. of the extensible SDK. If you used ``make`` to build the kernel, the
  551. kernel will be in the ``workspace/sources`` area.
  552. The following example assumes ``devtool`` was used to build the
  553. kernel::
  554. $ wic cp poky_sdk/tmp/work/qemux86-poky-linux/linux-yocto/4.12.12+git999-r0/linux-yocto-4.12.12+git999/arch/x86/boot/bzImage \
  555. poky/build/tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic:1/vmlinuz
  556. Once the new kernel is added back into the image, you can use the
  557. ``dd`` command or :ref:`bmaptool
  558. <dev-manual/bmaptool:flashing images using \`bmaptool\`>` commands
  559. to flash your wic image onto an SD card or USB stick and test your
  560. target.
  561. .. note::
  562. Using ``bmaptool`` is generally 10 to 20 times faster than using ``dd``.