Gentoo Archives: gentoo-catalyst

From: Paul Smith <psmith@××××××.com>
To: gentoo-catalyst@l.g.o
Subject: Re: [gentoo-catalyst] How is initrd built?
Date: Thu, 07 Jul 2005 20:02:12
Message-Id: vpdr3bqqz8q5.fsf@lemming.engeast.baynetworks.com
In Reply to: Re: [gentoo-catalyst] How is initrd built? by Chris Gianelloni
1 %% Chris Gianelloni <wolf31o2@g.o> writes:
2
3 cg> Actually, what rocket means in that catalyst has no built-in
4 cg> support for unionfs. To get unionfs, you need to use gk_mainargs
5 cg> (or gk_kernargs) --unionfs.
6
7 Oh, OK. Yeah, I already found this in the new genkernel, and did do it
8 in livecd.conf (I thought I mentioned that in one of my mails).
9
10 cg> You will also probably want livecd/bootargs: unionfs... unless
11 cg> you know the device you want, in which case you can do
12 cg> livecd/bootargs: unionfs=/dev/sda1 (or whatever).
13
14 I'm actually using GNAP to create the ISO, so I override the kernel boot
15 params there and don't need this.
16
17 cg> Yeah, livecd/bootargs is new in the _pre series. I even documented it
18 cg> in the template spec files... ;]
19
20 That's a good enhancement though! :-).
21
22 >> 0) mkdir -p /newroot
23 >>
24 >> 1) Create a tmpfs at /memory
25 >>
26 >> 2) Create a unionfs at /union, where the only item in the union is
27 >> /memory (mounted RW)
28 >>
29 >> 3) Init /newroot (make directories, copy over /dev/null and /dev/console)
30 >>
31 >> 4) Find the cdrom and mount it as /newroot/mnt/cdrom
32 >>
33 >> 5) Mount the squashfs as /newroot/mnt/livecd (read-only)
34 >>
35 >> 6) Add /newroot/mnt/livecd to the unionfs after the tmpfs (/memory)
36 >>
37 >> 7) Create /union/proc and /union/sys
38 >>
39 >> 8) Pivot_root to make /union the new /.
40 >>
41 >> 9) Clean up the old root (in /tmp/.initrd)
42 >>
43 >> 10) chroot . 'exec /sbin/init' (basically).
44
45 Hold on a second... I just discovered something that I don't understand
46 at all. The behavior above, in particular steps #8 & 9, is not actually
47 what happens.
48
49 If you look in the linuxrc you'll see it has an option to be invoked one
50 of two ways: where $0 is "/init", and where $0 is "/linuxrc". Depending
51 on which one is used the script exhibits different behavior... very
52 different, in some cases. Like, the "/init" branch doesn't use
53 pivot_root at all; it just does a chroot. The whole end cleanup is very
54 different.
55
56 I've been thinking that the livecd is booting with $0 == "/linuxrc", but
57 in fact it's not: $0 == "/init".
58
59 Can someone give me an idea of where this ($0) is set up (it's not init=
60 on the boot line because my boot line says init=/linuxrc--but it must be
61 the kernel somehow because it execs the shell so it would set argv[0]),
62 and what the purpose is between the different behaviors, and why you'd
63 choose one over the other?
64
65 cg> AFIAK, /mnt/cdrom would need to be done before the pivot_root,
66 cg> too. So you can't move that to later.
67
68 True, but you could do one of two things:
69
70 a) Mount it in /unionfs/mnt/cdrom in the first place, not in
71 /newroot/mnt/cdrom. By the time we mount the cdrom we already have
72 a /union filesystem created and working.
73
74 OR
75
76 b) Try to "mount --move" it from /newroot to /union once the unionfs is
77 set up.
78
79
80 I looked at (a) and while I think it would work, it would involve a lot
81 of changes. Although the value of CHROOT is set to $NEW_ROOT (or $UNION,
82 if we're using unionfs) early in the script, almost all the commands
83 after that continue to use $NEW_ROOT explicitly rather than $CHROOT.
84 Sometimes this probably makes sense (such as mounting livecd) but in
85 other cases it doesn't, so much (such as in mounting cdrom). I think
86 these variables need to be rationalized somewhat, so $CHROOT is used
87 instead of $NEW_ROOT where appropriate.
88
89 There are other things that probably don't hurt, but aren't required
90 either. For example, even in the unionfs case the code still
91 initializes $NEW_ROOT with a bunch of stuff that is never needed, and
92 then is just cleaned up again afterwards.
93
94 --
95 -------------------------------------------------------------------------------
96 Paul D. Smith <psmith@××××××.com> HASMAT--HA Software Mthds & Tools
97 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist
98 -------------------------------------------------------------------------------
99 These are my opinions---Nortel Networks takes no responsibility for them.
100 --
101 gentoo-catalyst@g.o mailing list

Replies

Subject Author
Re: [gentoo-catalyst] How is initrd built? Eric Edgar <rocket@g.o>