Yocto - failed to buid hddimg. Error: do_bootimg

Yocto - failed to buid hddimg. Error: do_bootimg

我正在研究 yocto,dunfell,正在尝试为 genericx86-64 机器构建 .hddimg 图像。我 inherit image-live,将 hhdimg 添加到 IMAGE_FSTYPES,使用 isowic 和...一切正常,但是当我添加 hddimg 时,我得到此错误:

ERROR: test-image-1.0-r0 do_bootimg: /path/build/tmp/work/genericx86_64-poky-linux/test-image/1.0-r0/test-image-1.0/hddimg/rootfs.img rootfs size is greather than or equal to 4GB,
ERROR: test-image-1.0-r0 do_bootimg: and this doesn't work on a FAT filesystem. You can either:
ERROR: test-image-1.0-r0 do_bootimg: 1) Reduce the size of rootfs.img, or,
ERROR: test-image-1.0-r0 do_bootimg: 2) Use wic, vmdk or vdi instead of hddimg

ERROR: test-image-1.0-r0 do_bootimg: Error executing a python function in exec_python_func() autogenerated:

The stack trace of python calls that resulted in this exception/failure was:
File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
     0001:
 *** 0002:do_bootimg(d)
     0003:
File: '/path/layers/poky/meta/classes/image-live.bbclass', lineno: 257, function: do_bootimg
     0253:    if d.getVar("PCBIOS") == "1":
     0254:        bb.build.exec_func('build_syslinux_cfg', d)
     0255:    if d.getVar("EFI") == "1":
     0256:        bb.build.exec_func('build_efi_cfg', d)
 *** 0257:    bb.build.exec_func('build_hddimg', d)
     0258:    bb.build.exec_func('build_iso', d)
     0259:    bb.build.exec_func('create_symlinks', d)
     0260:}
     0261:do_bootimg[subimages] = "hddimg iso"
File: '/path/layers/poky/bitbake/lib/bb/build.py', lineno: 251, function: exec_func
     0247:    with bb.utils.fileslocked(lockfiles):
     0248:        if ispython:
     0249:            exec_func_python(func, d, runfile, cwd=adir)
     0250:        else:
 *** 0251:            exec_func_shell(func, d, runfile, cwd=adir)
     0252:
     0253:    try:
     0254:        curcwd = os.getcwd()
     0255:    except:
File: '/path/layers/poky/bitbake/lib/bb/build.py', lineno: 452, function: exec_func_shell
     0448:    with open(fifopath, 'r+b', buffering=0) as fifo:
     0449:        try:
     0450:            bb.debug(2, "Executing shell function %s" % func)
     0451:            with open(os.devnull, 'r+') as stdin, logfile:
 *** 0452:                bb.process.run(cmd, shell=False, stdin=stdin, log=logfile, extrafiles=[(fifo,readfifo)])
     0453:        finally:
     0454:            os.unlink(fifopath)
     0455:
     0456:    bb.debug(2, "Shell function %s finished" % func)
File: '/path/layers/poky/bitbake/lib/bb/process.py', lineno: 182, function: run
     0178:        if not stderr is None:
     0179:            stderr = stderr.decode("utf-8")
     0180:
     0181:    if pipe.returncode != 0:
 *** 0182:        raise ExecutionError(cmd, pipe.returncode, stdout, stderr)
     0183:    return stdout, stderr
Exception: bb.process.ExecutionError: Execution of '/path/build/tmp/work/genericx86_64-poky-linux/test-image/1.0-r0/temp/run.build_hddimg.18514' failed with exit code 1:
WARNING: exit code 1 from a shell command.


ERROR: Logfile of failure stored in: /path/build/tmp/work/genericx86_64-poky-linux/test-image/1.0-r0/temp/log.do_bootimg.18514
ERROR: Task (/path/layers/meta-ammsc2/recipes-core/images/test-image.bb:do_bootimg) failed with exit code '1'``` 

test-image 的 rootfs 大于 4GB,这是 FAT 分区的最大文件系统大小(.hddimg 映像类型使用的默认值)。

错误已经包含两个解决方案:

  1. 通过删除包减小图像大小
  2. 使用 wic 格式(vmdkvdi 用于虚拟机引擎)

要使用 wic 格式,只需将 wic 添加到 IMAGE_FSTYPES,Yocto 将构建一个 .wic 图像并将其放置在 deploy/images 目录中.您可以使用 ddbmaptool 将其闪存到您的磁盘,然后启动它。

这些图像是根据 WKS_FILE 指定的模板构建的,genericx86-64 机器默认为 genericx86.wks.in。此默认模板创建分区 table 并安装 EFI 引导程序 (Grub)。

如果您想手动生成 wic 图像或修改模板,请查看 Creating Partitioned Images Using Wic 的文档。