Gentoo Archives: gentoo-dev

From: Rich Freeman <rich0@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] Re: udev <-> mdev
Date: Sun, 15 Jul 2012 18:50:39
Message-Id: CAGfcS_knPjWSCydZZZ_-SVRxaj2Yt_D+gQ_WFDfn=bsDDdK6Pw@mail.gmail.com
In Reply to: [gentoo-dev] Re: udev <-> mdev by Duncan <1i5t5.duncan@cox.net>
1 On Sun, Jul 15, 2012 at 2:25 PM, Duncan <1i5t5.duncan@×××.net> wrote:
2 > So I have the general idea,
3 > but doing it from an initr* with limited tools available will be
4 > interesting.
5 >
6
7 Dracut modules can specify any tools they need, and they will be
8 loaded into the initramfs. Obviously you'll want to use some
9 discretion here.
10
11 > As for the tmpfs rootfs itself, I have the vague idea that I'd
12 > "simply" (note the scare-quotes) use what's normally the initial root
13 > that's essentially thrown away, only I'd not throw it away, I'd just
14 > mount everything on top, keep using it, and /somehow/ ensure that
15 > anything running from it directly terminates one way or another, so that
16 > I don't have old processes stuck around using the mounted-over points.
17
18 I suspect you could do that, but you'd probably have to change the
19 cleanup code, and you need to keep in mind that the initramfs runs on
20 ramfs and not tmpfs. While similar there are a few important
21 differences. Ramfs does not support size limits, so you can
22 extinguish all of your ram easily enough. Ramfs also does not swap,
23 which means that any actual content in that filesystem will waste ram,
24 whether it is used or not. Anything that writes to it could wipe out
25 all your memory even if you have swap available. The design of ramfs
26 is designed for simplicity rather than robustness (you can support an
27 initramfs on a system that otherwise lacks the drivers for tmpfs.
28
29 > Which is why I keep /usr (and /lib64 and /usr/lib64) on rootfs currently,
30 > tho the traditional /usr/src/, /usr/local, and /usr/portage are either
31 > pointed elsewhere with the appropriate vars or mountpoints/symlinks to
32 > elsewhere. Of course that'd have to change a bit for a tmpfs rootfs,
33 > since /lib64, /usr and /etc would obviously be mounted from elsewhere,
34 > but they could still be either symlinked or bind-mounted to the
35 > appropriate location on the single (read-only) system-filesystem.
36
37 Giving it a little thought, the simplest tmpfs-based root would be one
38 that defines a tarball as a the root. The system would create a
39 tmpfs, extract the tarball to it, and then use the existing fstab-sys
40 module to mount stuff on top of that. This gives you the option of
41 actually putting some content in the tarball, or just storing an empty
42 directory structure in it. A tarball would let you set
43 permissions/etc and be a bit more generic than writing a custom
44 script. If you wrote a module to do this I wouldn't be suprised if
45 upstream let you merge it. You'd just need to define some kind of
46 sane syntax for it (root=TAR=path...to...tarball - though how a path
47 works with nothing mounted you'd have to define). Maybe you define
48 the tarball at initramfs creation (as is done with fstab.sys and
49 mdadm.conf).
50
51 >
52 > FWIW I remember being truly fascinated with the power of symlinks when I
53 > first switched from MS. Now I consider them normal, but the power and
54 > flexibility of bind-mounts still amazes me, especially since, as with
55 > symlinks, it's possible to bind-mount individual files, but unlike
56 > symlinks (more like hard-links but cross-filesystem), it's possible to
57 > have some of the bind-mounts read-write (or dev, exec, etc) while others
58 > are read-only (or nodev, noexec...).
59
60 Yup, my /usr and /var are bind-mounts - I was following the
61 pre-initramfs raid guide and had my root on a raid1, and wanted to
62 keep it minimal. However, rather than having 47 individual
63 filesystems in lvm I only defined a few and bind-mounted half the tree
64 off of one of them. Fstab.sys seems to handle that just fine
65 (mounting the main mountpoint first, and the bind mounts afterwards).
66
67 Rich

Replies

Subject Author
[gentoo-dev] Re: udev <-> mdev Duncan <1i5t5.duncan@×××.net>