]>
Commit | Line | Data |
---|---|---|
4efcd19a BZ |
1 | Dracut supports running against a sysroot directory that is different |
2 | from the actual root (/) directory of the running system. It is most | |
3 | useful for creating/bootstrapping a new system that may or may not be | |
4 | using the same CPU architecture as the host system, i.e. building a | |
5 | whole Linux system with a cross-compiler framework like Yocto. | |
6 | ||
7 | The user-visible frontend change is the introduction of a new option | |
8 | called "-r" or "--sysroot". It expects a directory that contains the | |
9 | complete Linux system that has all the files (kernel drivers, firmware, | |
10 | executables, libraries and others) necessary to construct the initramfs. | |
11 | ||
12 | E.g: dracut --sysroot /path/to/sysroot initramfs.img kernelversion | |
13 | ||
14 | To support this, a new global variable was introduced inside dracut. | |
15 | This variable is called "dracutsysrootdir" and all the files installed | |
16 | into the initramfs image is searched relative to the sysroot directory. | |
17 | This variable can also be set externally to dracut without using option | |
18 | -r/--sysroot. | |
19 | ||
20 | There are other details that are necessary to tweak to be able to | |
21 | run on cross-compiled (a.k.a. foreign) binaries. | |
22 | ||
23 | dracut uses these crucial utilities during its operation: | |
24 | ||
25 | ldd | |
26 | === | |
27 | It lists dynamic library dependencies for executables or libraries | |
28 | ||
29 | ldconfig | |
30 | ======== | |
31 | It creates /etc/ld.so.cache, i.e. the cached information about libraries | |
32 | known to the system. | |
33 | ||
34 | These utilities the way they exist on the host system only work on | |
35 | the host system. | |
36 | ||
37 | To support cross-compiled binaries, a different ldd variant is needed that | |
38 | works on those binaries. One such ldd script is found at | |
39 | https://gist.github.com/jerome-pouiller/c403786c1394f53f44a3b61214489e6f | |
40 | ||
41 | ldconfig in GLIBC as is does support a sysroot with its -r option. | |
42 | ||
43 | Extra environment variables needed to run dracut on the sysroot are | |
44 | documented in the dracut(8) man page. | |
45 | ||
46 | For the Plymouth boot splash to be added to the initramfs image, | |
47 | this gitlab PR is needed for Plymouth: | |
48 | https://gitlab.freedesktop.org/plymouth/plymouth/merge_requests/72 | |
49 | ||
50 | Extensions to be used with Yocto | |
51 | ================================ | |
52 | ||
53 | examples/yocto/classes/dracut.bbclass: | |
54 | Bitbake class for running dracut during the "do_rootfs" stage of | |
55 | creating a distribution image and from the postinstall script of | |
56 | a package. A kernel recipe needs this line to activate it: | |
57 | ||
58 | inherit dracut | |
59 | ||
60 | examples/yocto/postinst-intercepts/execute_dracut | |
61 | The "intercept" script used during "do_rootfs" mentioned above. | |
62 | ||
63 | examples/yocto/recipes/cross-compiler-ldd_git.bb | |
64 | Package recipe for the cross-compiler-ldd script from the above link. | |
65 | ||
66 | All the above three need to be added to a Yocto layer to their | |
67 | proper locations. | |
68 | ||
69 | They were tested on Yocto 2.7 with MACHINE="intel-core2-32" and | |
70 | MACHINE="genericx86-64". |