はじめに
Intel 64ビットプロセッサー(x64)向けLinuxをYoctoでビルドする方法です。
meta-intel を使います。
環境構築
$ mkdir path/to/prj
$ mkdir sources
$ cd sources
$ git clone git://git.yoctoproject.org/poky -b kirkstone
$ git clone git://git.openembedded.org/meta-openembedded -b kirkstone
$ git clone git://git.yoctoproject.org/meta-intel -b kirkstone
$ cd ..
$ . ./sources/poky/oe-init-build-env build
設定
build/conf/local.conf
MACHINE = "intel-corei7-64"
- インストーラーイメージの設定(
sources/meta-intel/README
参考)
WKS_FILE = "image-installer.wks.in"
IMAGE_FSTYPES:append = " ext4"
IMAGE_TYPEDEP_wic = "ext4"
INITRD_IMAGE_LIVE = "core-image-minimal-initramfs"
do_image_wic[depends] += "${INITRD_IMAGE_LIVE}:do_image_complete"
do_image_wic[recrdeptask] += "do_image_ext4"
do_rootfs[depends] += "virtual/kernel:do_deploy"
IMAGE_BOOT_FILES:append = " \
${KERNEL_IMAGETYPE} \
microcode.cpio \
${IMGDEPLOYDIR}/${IMAGE_BASENAME}-${MACHINE}.ext4;rootfs.img \
${@bb.utils.contains('EFI_PROVIDER', 'grub-efi', 'grub-efi-bootx64.efi;EFI/BOOT/bootx64.efi', '', d)} \
${@bb.utils.contains('EFI_PROVIDER', 'grub-efi', '${IMAGE_ROOTFS}/boot/EFI/BOOT/grub.cfg;EFI/BOOT/grub.cfg', '', d)} \
${@bb.utils.contains('EFI_PROVIDER', 'systemd-boot', 'systemd-bootx64.efi;EFI/BOOT/bootx64.efi', '', d)} \
${@bb.utils.contains('EFI_PROVIDER', 'systemd-boot', '${IMAGE_ROOTFS}/boot/loader/loader.conf;loader/loader.conf ', '', d)} \
${@bb.utils.contains('EFI_PROVIDER', 'systemd-boot', '${IMAGE_ROOTFS}/boot/loader/entries/boot.conf;loader/entries/boot.conf', '', d)} \
"
build/conf/bblayers.conf
BBLAYERS ?= " \
${TOPDIR}/../sources/poky/meta \
${TOPDIR}/../sources/poky/meta-poky \
${TOPDIR}/../sources/poky/meta-yocto-bsp \
${TOPDIR}/../sources/meta-openembedded/meta-oe \
${TOPDIR}/../sources/meta-openembedded/meta-networking \
${TOPDIR}/../sources/meta-openembedded/meta-python \
${TOPDIR}/../sources/meta-openembedded/meta-filesystems \
${TOPDIR}/../sources/meta-openembedded/meta-multimedia \
${TOPDIR}/../sources/meta-intel \
"
ビルド
$ bitbake core-image-x11
$ bitbake core-image-sato
$ sudo dd if=tmp/deploy/images/intel-corei7-64/core-image-x11-intel-corei7-64.wic of=/dev/sdx status=progress
$ sudo dd if=tmp/deploy/images/intel-corei7-64/core-image-sato-intel-corei7-64.wic of=/dev/sdx status=progress
sdx は環境に合わせて変更ください。
[例]sdc
Windows機ならrufusで作成できます。
rufus.ie
ターゲット機のBIOS(UEFI)でブートデバイス順序の第1をUSBにして、このUSBメモリーをターゲット機に挿して起動すればインストール開始します。
カスタマイズ
インストール開始までの待ち(タイムアウト)時間変更
デフォルトだと、インストール開始まで5秒待たされます。この待ち時間はsources/meta-intel/wic/image-installer.wks.in
で変更できます。
[例]1秒
bootloader --ptable gpt --timeout=1 --append=" rootwait "
インストール処理の変更
インストール処理はsources/poky/meta/recipes-core/initrdscripts/files/init-install-efi.sh
に記述されています。
インストール処理を変更したい場合はこのファイルを編集ください。
--- sources/poky/meta/recipes-core/initrdscripts/files/init-install-efi.sh.orig 2023-12-26 13:21:42.493604948 +0900
+++ sources/poky/meta/recipes-core/initrdscripts/files/init-install-efi.sh 2023-12-07 09:14:09.962019853 +0900
@@ -101,12 +101,16 @@
# Get user choice
while true; do
- echo "Please select an install target or press n to exit ($hdnamelist ): "
- read answer
+ echo "Please select an install target or press n to exit ($hdnamelist ), waiting for 5 secs ...: "
+ read -t 5 answer || true
if [ "$answer" = "n" ]; then
echo "Installation manually aborted."
exit 1
fi
+ if [ -z "$answer" ]; then
+ echo "Default target (sda) selected."
+ answer=sda
+ fi
for hdname in $hdnamelist; do
if [ "$answer" = "$hdname" ]; then
TARGET_DEVICE_NAME=$answer
@@ -208,7 +212,7 @@
mkfs.vfat $bootfs
echo "Formatting $rootfs to ext4..."
-mkfs.ext4 $rootfs
+mkfs.ext4 -F $rootfs
echo "Formatting swap partition...($swap)"
mkswap $swap
@@ -274,7 +278,7 @@
# delete any root= strings
sed -i "s/ root=[^ ]*/ /" $SYSTEMDBOOT_CFGS
# add the root= and other standard boot options
- sed -i "s@options *@options root=PARTUUID=$rootuuid rw $rootwait quiet @" $SYSTEMDBOOT_CFGS
+ sed -i "s@options *@options root=PARTUUID=$rootuuid rw $rootwait @" $SYSTEMDBOOT_CFGS
fi
umount /tgt_root
デフォルトだと、Linuxブートまで10秒待たされます。この待ち時間はbuild/conf/local.conf
に下記追加で変更できます。
[例]1秒
SYSTEMD_BOOT_TIMEOUT = "1"