Gentoo Archives: gentoo-user

From: Hans-Werner Hilse <hilse@×××.de>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Looking for best tutorial on creating initramfs
Date: Thu, 20 Apr 2006 14:52:51
Message-Id: 20060420164416.947a31ac.hilse@web.de
In Reply to: [gentoo-user] Looking for best tutorial on creating initramfs by "Johnson
1 Hi,
2
3 On Thu, 20 Apr 2006 08:05:50 -0500 "Johnson, Maurice E CTR NSWCDL-K74"
4 <maurice.e.johnson1.ctr@××××.mil> wrote:
5
6 > Need to find a better tutorial on initramfs. One that doesn't rely on
7 > tools that automate the process.
8
9 In fact, an initramfs doesn't differ much from other root fs'es.
10 Physically, it is a gzipped cpio archive. The kernel will compile it
11 into the kernel itself if you tell it so (kernel configuration:
12 configure a patch for initramfs data). If you want to create it
13 manually and load it like a ram disk (i.e. use the boot loader to pass
14 the initramfs to the kernel) you can rely on a script that is in
15 your kernels ./scripts/ directory and an executable that gets compiled
16 in ./usr/ like this:
17
18 gen_initramfs_list.sh /path/to/initramfs/data | gen_init_cpio /dev/stdin | gzip -9 > initramfs.gz
19
20 Inside the initramfs you can create a userland. Kernel's entry point
21 will be /init, which is supposed to be executable.
22
23 You'll want to read
24
25 /usr/src/linux/Documentation/early-userspace/README
26
27 for the basics and then read
28
29 /usr/src/linux/Documentation/initrd.txt
30 (be careful to ignore the first part which is only initrd specific).
31
32 You can put anything you want into your initramfs. If it's just some
33 simple script that should be run, you're probably done with a
34 statically compiled "busybox" executable and /init being a shell
35 script. At the end of the script, you'll want to pivot_root into the
36 real root filesystem and maybe delete initramfs data afterwards.
37
38 I've never found really good documentation, but everything just works
39 as expected. There's really nothing special with initramfs.
40
41 Feel free to ask more questions here.
42
43 -hwh
44 --
45 gentoo-user@g.o mailing list