Event-based initramfs
Initramfs is used for getting the root filesystem mounted and passing control the real init on the real root fs. Once the kernel boots, it passes control to the init in the initramfs. This init then runs scripts that are responsible for checking if the root device is configured properly and capable of mounting the root fs on it. In parallel, behind the scenes, udev runs and uses the help of blkid to run "admin" scripts like "mdadm", "lvm", "cryptsetup" to configure the root device. This is all event based, i.e the devices are configured as and when they become available. However the exception to this is configuring the LUKS devices, which are configured using cryptsetup. The script that runs cryptsetup, first checks up if the device which is to be configured as an encrypted device, is available. If not then it waits for some time and then it checks again if the device is available or not. If not then it will simply give up and get the user to a busybox prompt. If the device is available, then cryptsetup is called and the device is configured as a LUKS device. Once the device is available a udev event is generated and again, udev runs blkid and calls whatever admin script needs to be called if any other subsystem is stacked on top of this LUKS device. While all this is good, there are two observations to be made here:
a. The invocation of cryptsetup is procedural and not completely event based.
b. There is a repeatition of code for mounting, checking filesystems, crypt devices, LVM devices and so on - one code path is found in upstart jobs and the other in initramfs.
So one idea that lets you remove this duplication and at the same time enables the LUKS devices in an event based fashion, is to make the initramfs event based in the true sense, by bringing in upstart in initramfs. This means that we copy the jobs in /etc/init/ in initramfs and run them at boot time. This brings in the simplicity, elegance and robustness of upstart in initramfs and also gives you more flexibility to handle the events in a way that you want
Blueprint information
- Status:
- Not started
- Approver:
- Colin Watson
- Priority:
- Medium
- Drafter:
- Dimitri John Ledkov
- Direction:
- Approved
- Assignee:
- Dimitri John Ledkov
- Definition:
- Approved
- Series goal:
- Accepted for raring
- Implementation:
- Deferred
- Milestone target:
- None
- Started by
- Completed by
Related branches
Whiteboard
= References =
https:/
https:/
Recent thread on ubuntu-devel: http://
http://
= Redacted etherpad notes from UDS-Q =
Currently there are two implementations of raid/lvm/
* in the busybox boot-strap
* and in the fully booted system
The busybox version has arbitary timeouts, and prevents reliably
booting certain common types of system, e.g. RAID on USB disk, RAID on
crypt, etc. Resolving this, removing code-duplication and different
mounting behaviour pre-/post- boot are the core objectives.
If we have event-driven initramfs, we could unconditionally put KMS
drivers into initramfs and have udev load them so can start video load
earlier (to get early splash). For some users video load takes same
time.
Considering adding lvm/raid into initramfs by default (?!).
A hack was proposed to consider generating i18n bitmaps for all
supported languages as considerably smaller than shoe-horning pango
into the initramfs (chromium implements bitmpaps generation).
Putting more things into initramfs, will make it larger. The question
is, whether it will become too large (~3-4MB limit on ARM). The size
of initramfs also may affect the bootspeed. It needs benchmarking.
A question was raised about upstart re-exec and udevd. Do we kill
udevd in the initramfs and restart in the main system? or pause the
udev events, pivot, unpause and handle the events that occured when
paused?
Upstart would need to support stateful re-exec, pivot support, second
re-exec should define which events we need. initramfs upstart emit a
different event "initramfs" or "pre-startup", etc to avoid having the
2 instances of upstart emit the "startup" event.
= Outstanding notes =
* ensure design allows for non-initramfs systems.
* do we want to copy the upstart job logs from the initramfs into
the main system? probably not as can just use "break" to query
those files (in say /run/init/log/)
The team: xnox, adam, ogra, james.
Work Items
Work items:
[csurbhi] mountall - mounting rootfs readonly. Waiting for a rootdelay time for the device to be ready in case necessary. Emit an event based on which upstart saves state: DONE
[csurbhi] writing an upstart job for degraded array startup: DONE
taking care of casper - fs mounting: POSTPONED
taking care of network based and iscsi based mounts: POSTPONED
writing an upstart job for moving from the initramfs rootfs to real rootfs and re-exec the init in the new rootfs: POSTPONED
investigate generating a large and small initramfs with auto-fallback on failed boot: POSTPONED
establish if surbhi's branch cleans up the initramfs (is it just /run?): POSTPONED
ensure still possible to break into initramfs at various points / interactive boot.: POSTPONED
create a /etc/initramfs-
put proof-of-concept into archive which users can opt into (no pressing need to do this in quantal): POSTPONED
consult with RAOF/rancell about having wayland-
once mountall has mounted / and /usr in initramfs, mountall exits (this replaces wait-for-root.c currently in initramfs). Needs a new mountall (*not* mntctl) option. See previous work on the upstart job by csurbhi.: POSTPONED
mountall needs to recognise post-pivot that / and /usr may need to be fsck'ed.: POSTPONED
Implement UTAH automatic smoke testing of both initramfs types with various filesystems (LVM, crypto, Raid, etc): POSTPONED
need to ensure we move mountpoints (/proc, /sys, /dev/pts, /run) to the new root.: POSTPONED
ensure regen initramfs on upstart upgrade! :-) (triggers please!): POSTPONED
detect if NFS root and if so forcibly disable event-based initramfs (stretch goal): POSTPONED
update casper to use event-based initramfs for improved CD boot (stretch goal): POSTPONED
ensure we (somehow) continue to support the cmdline options specified in initramfs-tools(8). (smoser needs for example "root=..." for EC2, etc). Check with server team!!: POSTPONED
Dependency tree
* Blueprints in grey have been implemented.