Gentoo Archives: gentoo-user

From: Mark Knecht <markknecht@×××××.com>
To: Gentoo User <gentoo-user@l.g.o>
Subject: [gentoo-user] Building an initramfs into the kernel
Date: Wed, 26 Dec 2012 16:00:20
Message-Id: CAK2H+ee+R9EgWBkbiv7c+uAtuc+XRkPgh7XQ+feLb08+2YmM+A@mail.gmail.com
1 Hi,
2 OK, it's the day after Christmas and this little kid wants to play
3 with the new toys Uncle Neil gave us yesterday - a copy of his well
4 worn setup file for building an initramfs into the kernel - a copy of
5 which I place here:
6
7 [QUOTE]
8
9 This is the file I use on a system that has / on a LUKS filesystem on top
10 of LVM. The format is documented in the kernel docs at
11 Documentation/filesystems/ramfs-rootfs-initramfs.txt
12
13
14 dir /bin 755 0 0
15 file /bin/busybox /bin/busybox 755 0 0
16 slink /bin/sh busybox 777 0 0
17
18 dir /realroot 755 0 0
19 dir /etc 755 0 0
20 dir /proc 755 0 0
21 dir /sys 755 0 0
22
23 dir /sbin 755 0 0
24 file /sbin/lvm.static /sbin/lvm.static 755 0 0
25 #file /sbin/mdadm /sbin/mdadm 755 0 0
26 file /sbin/cryptsetup /sbin/cryptsetup 755 0 0
27
28 file /sbin/e2fsck /sbin/e2fsck 755 0 0
29 dir /lib 755 0 0
30 file /lib/libext2fs.so /usr/lib64/libext2fs.so 755 0 0
31
32 dir /dev 755 0 0
33 nod /dev/console 600 0 0 c 5 1
34 nod /dev/null 666 0 0 c 1 3
35 nod /dev/tty 666 0 0 c 5 0
36 nod /dev/urandom 666 0 0 c 1 9
37
38 file /init /usr/src/init.sh 755 0 0
39
40 [/QUOTE]
41
42
43 OK, so reading through this it seems moderately straight forward. My reading:
44
45 a) Create some directories
46 b) Populate them with some executables
47 c) Make some nodes
48 d) Execute a script
49
50
51 I do have a few questions:
52
53 1) dir /realroot 755 0 0
54
55 Is this something required to make the machine boot? Or is it possibly
56 a mount point in case of problems and just used inside the initramfs
57 if trouble arises? Something else? Google didn't point me toward
58 anything meaningful.
59
60 2) Contained executables, as I understand them, either need to be
61 built with the static flag or you have to include all the libraries.
62 Static seems simpler so (in my case) should I rebuild mdadm &
63 e2fsprogs with +static? (I don't currently use lvm or any crypt stuff)
64 I assume from the line
65
66 file /lib/libext2fs.so /usr/lib64/libext2fs.so 755 0 0
67
68 that running ldd on the new mdadm is still going to require this one
69 library be in the initramfs?
70
71 3) My system uses RAID today. Is there any significant risk in
72 rebuilding mdadm with static support, rebooting the existing kernel
73 without an initramfs and then mdadm having trouble?
74
75 4) What's in /usr/src/init.sh ? From the Gentoo initramfs wiki I find
76 this as an example:
77
78 rescue_shell() {
79 echo "Something went wrong. Dropping you to a shell."
80 busybox --install -s
81 exec /bin/sh
82 }
83
84 I wonder what Uncle Neil uses? (Or anyone else...)
85
86 Yipee!!! Better than the Red Ryder BB gun complete with a compass
87 and a sundial I was hoping for! ;-)
88
89 (And if it's not clear, I'm hoping this thread might possibly help
90 others in the future move from one place about initramfs to another
91 place about initramfs. We'll see.)
92
93 Cheers,
94 Mark

Replies

Subject Author
Re: [gentoo-user] Building an initramfs into the kernel Neil Bothwick <neil@××××××××××.uk>