Yocto est
une usine à g un suite d'outil basée entre autre sur
OpenEmbedded pour construire sa propre distribution Linux.
Sur ma machine, qui héberge de base un
FreeBSD 11-Stable, Je fait tourner
Yocto sous une
Debian à l'aide de
bHyve.
Par exemple, après avoir ciblé ma
session Yocto sur l'architecture de ma machine hôte:
Code:david@yocto:~/poky/build$ grep "MACHINE" conf/local.conf | tail -1
MACHINE = "intel-corei7-64"
je concocte une distribution; ici, celle fournit par Yocto de base:
Code:david@yocto:~/poky/build$ bitbake core-image-full-cmdline
Loading cache: 100% |############################################| Time: 0:00:01
Loaded 1308 entries from dependency cache.
NOTE: Resolving any missing task queue dependencies
Build Configuration:
BB_VERSION = "1.36.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "universal"
TARGET_SYS = "x86_64-poky-linux"
MACHINE = "intel-corei7-64"
DISTRO = "poky"
DISTRO_VERSION = "2.4.2"
TUNE_FEATURES = "m64 corei7"
TARGET_FPU = ""
meta
meta-poky
meta-yocto-bsp = "rocko:50189fdf620bc9ca42065998ce8c5a796ad8c331"
meta-intel = "master:a17f3f4e9c61a9317a013b11ee36686d3a62c98f"
Initialising tasks: 100% |#######################################| Time: 0:00:08
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
NOTE: Tasks Summary: Attempted 3716 tasks of which 3716 didn't need to be rerun and all succeeded.
À partir de laquelle je créé une image pour
Bios Legacy:
Code:david@yocto:~/poky/build$ wic create directdisk -e core-image-full-cmdline
INFO: Building wic-tools...
Loading cache: 100% |############################################| Time: 0:00:01
Loaded 1308 entries from dependency cache.
NOTE: Resolving any missing task queue dependencies
Build Configuration:
BB_VERSION = "1.36.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "universal"
TARGET_SYS = "x86_64-poky-linux"
MACHINE = "intel-corei7-64"
DISTRO = "poky"
DISTRO_VERSION = "2.4.2"
TUNE_FEATURES = "m64 corei7"
TARGET_FPU = ""
meta
meta-poky
meta-yocto-bsp = "rocko:50189fdf620bc9ca42065998ce8c5a796ad8c331"
meta-intel = "master:a17f3f4e9c61a9317a013b11ee36686d3a62c98f"
Initialising tasks: 100% |#######################################| Time: 0:00:04
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
NOTE: Tasks Summary: Attempted 1785 tasks of which 1785 didn't need to be rerun and all succeeded.
INFO: Creating image(s)...
INFO: The new image(s) can be found here:
./directdisk-201802181651-sda.direct
The following build artifacts were used to create the image(s):
ROOTFS_DIR: /home/david/poky/build/tmp.wic.0zmxdbkl/rootfs_copy
BOOTIMG_DIR: /home/david/poky/build/tmp/work/intel_corei7_64-poky-linux/core-image-full-cmdline/1.0-r0/recipe-sysroot/usr/share
KERNEL_DIR: /home/david/poky/build/tmp/deploy/images/intel-corei7-64
NATIVE_SYSROOT: /home/david/poky/build/tmp/work/corei7-64-poky-linux/wic-tools/1.0-r0/recipe-sysroot-native
INFO: The image(s) were created using OE kickstart file:
/home/david/poky/scripts/lib/wic/canned-wks/directdisk.wks
que je récupère par
scp.
Ensuite, depuis l'hôte FreeBSD je lance un script
de ce genre là::
Code:#!/bin/sh
vmname=test
memorystamp=1024M
# create a tap interface
# ifconfig tap1 create
# add to bridge
# ifconfig bridge0 addm tap1
# kill (if any)
bhyvectl --vm=${vmname} --destroy
list_sda () {
hddisk="./"`ls -1 -t direct*.sda | head -1`
}
hddisk=${1}
[ -z ${hddisk} ] && list_sda
echo "building map file for grub"
echo "(hd0) "${hddisk} > direct.map
grub-bhyve -m direct.map -r hd0,msdos1 -M ${memorystamp} ${vmname}
echo "starting linux on root=" ${hddisk}
bhyve -A -H -P -s 0:0,hostbridge \
-s 1:0,lpc \
-s 2:0,virtio-net,tap1 \
-s 3:0,virtio-blk,${hddisk} \
-l com1,stdio \
-c 1 -m ${memorystamp} ${vmname}
bhyvectl --vm=${vmname} --destroy
L'image est renommée «direct.sda» et le script créé automatiquement un fichier map pour
Grub.
Une fois
grub lancé avec
bhyve-grub, il faut amorcer son linux:
Code:linux (hd0,msdos1)/vmlinuz root=/dev/vda2
boot
et
bhyve fait le reste.
Pensez à créer et ajuster une carte réseau virtuelle de type
tap.
Code:ifconfig tap1 create
et de l'associer à une interface bridge au besoin:
Code:ifconfig bridge0 addm tap1
Et ça roule.