Early boot: Difference between revisions

From OLPC
Jump to navigation Jump to search
m (Expand abbreviation.)
(Update early boot with new /pristine layout.)
Line 24: Line 24:
vserver (protect PID 1, RTC <- vserver delta time)
vserver (protect PID 1, RTC <- vserver delta time)
v
v
--------------------> (post-FRS) debian w/ developer key:
with open('/sbin/olpc-init.py') as f:
str = f.read()
eval(str)
--------------------> debian w/ developer key:
| def run():
| def run():
| os.exec('/sbin/init')
| os.exec('/sbin/init')
if booting from a backup:
1. make new config w/ swapped current and alt
(ie. create a /pristine/configs/XXX w/ new current, alt)
2. then swing /pristine/boot symlink
create /pristine/running
xo boot:
xo boot:
$current = last part of /pristine/current symlink
$current = basename of realpath of /pristine/boot/current (a hash)
mnt /home /run/$current/home
mnt /home /run/$current/home
mnt /security /run/$current/security
mnt /security /run/$current/security
mnt /pristine /run/$current/pristine
mnt /pristine /run/$current/pristine
chroot /run/$current (mount --move ?)
chroot /run/$current (mount --move ?) [ actually vserver container here ]
v
v
with open('/sbin/olpc-init.py') as f:
if exists '/sbin/olpc_init.py':
sys.path = ['/sbin'] + sys.path
str = f.read()
from olpc_init import run
eval(str)
run(<parameters?>)
else:
exec '/sbin/init --init'
---------------------> debian w/o developer key (in run)
---------------------> debian w/o developer key (in run)
|
|
Line 57: Line 62:
== List of directories in root ==
== List of directories in root ==
/sys, /proc, /ofw vfs
/sys, /proc, /ofw vfs
/pristine/a
/pristine/trees/{hashes}
/pristine/b
/pristine/configs/`mkdtemp`/current
/pristine/current -> /pristine/a (say)
/pristine/configs/`mkdtemp`/alt
/pristine/boot -> configs/<something>
/run/a
/pristine/running -> /pristine/tree/<hash> (version we booted from)
/run/b
/pristine/updates/<hash> (temporary space for updates, preserved in case update
net connection drops & updater is restarted)
/run/{hashes}
/security
/security
/home
/home
/boot -> /pristine/boot/current
/sbin/olpc-init.py
/boot -> /pristine/current/boot
/boot-alt -> /pristine/boot/alt
/boot-alt -> /pristine/alt/boot


== Upgrade procedure ==
== Upgrade procedure ==
Upgrade procedure, creating new b from a (w.l.o.g)
Upgrade procedure, creating new b from a (w.l.o.g)
Rainbow: (ATC gives <version> <hash> <priority>)
Rainbow: (ATC gives <version> <hash> <priority>)
0. swing /pristine/alt to /pristine/a
0. delete /pristine/current/alt
1. delete /pristine/b
1. delete the tree it pointed to
2. Invoke 'olpc-updater <version>'
2. Invoke 'olpc-updater <version>'
in new container:
in new container:
[MICHAEL WILL REWRITE STARTING FROM HERE]
/current (ro-bind mount from /pristine/a)
/current (ro-bind mount from /pristine/a)
/upgrade (initially empty)
/upgrade (initially empty)
Line 80: Line 88:
3. clone /current to /upgrade
3. clone /current to /upgrade
4. upgrade /upgrade by hook or crook
4. upgrade /upgrade by hook or crook
[END MICHAEL REWRITES]
5. exit
5. exit
Rainbow:
Rainbow:
6. Verify $container/upgrade matches <hash>
6. Verify /pristine/updates/<hash> matches <hash>
7. Move $container/upgrade to /pristine/b (atomic!)
7. Move /pristine/updates/<hash> to /pristine/trees/<hash>
8. Swing /pristine/current to /pristine/b (atomic!)
8. Make a new config /pristine/configs/`mkdtemp`
9. Create 'current' symlink to /pristine/trees/<hash>
9. If <priority> reboot.
10. Create 'alt' symlink to *realpath of* /pristine/running
11. Swing /pristine/boot to /pristine/configs/<foo>, recording prev contents as $old
(atomic! iff we do file move of new symlink)
12. Delete /pristine/configs/$old
13. If <priority> reboot. (Ask Eben & sugar folks)


[[Category:software]]
[[Category:software]]

Revision as of 18:08, 24 August 2007

  This page is monitored by the OLPC team.


Pencil.png NOTE: The contents of this page are not set in stone, and are subject to change!

This page is a draft in active flux ...
Please leave suggestions on the talk page.

Pencil.png

Draft of early boot upgrade/init procedures designed by Michael Stone and C. Scott Ananian.

Early userland startup steps

[initrd]
v
python2.5 (pid 1)
v
network_setup(), mount usb/sd, etc
v
antitheft client (ATC)
 olpc.atc.run(fqdn of schoolserver, callback)

(sometime later, or immediately if already activated)
v
callback (as pid 2)
v
mount /sysroot, unmount usb/sd
copy /security/lease to /sysroot/security/lease if first boot
parse chosen/bootpath, swing /pristine/current
v
make minimal userland context (mount --move /sysroot /)
 vserver (protect PID 1, RTC <- vserver delta time)
v
--------------------> (post-FRS) debian w/ developer key:
|                      def run():
|                        os.exec('/sbin/init')
if booting from a backup:
 1. make new config w/ swapped current and alt
    (ie. create a /pristine/configs/XXX w/ new current, alt)
 2. then swing /pristine/boot symlink
create /pristine/running
xo boot:
$current = basename of realpath of /pristine/boot/current (a hash)
mnt /home /run/$current/home
mnt /security /run/$current/security
mnt /pristine /run/$current/pristine
chroot /run/$current (mount --move ?) [ actually vserver container here ]
v
if exists '/sbin/olpc_init.py':
  sys.path = ['/sbin'] + sys.path
  from olpc_init import run
  run(<parameters?>)
else:
  exec '/sbin/init --init'
---------------------> debian w/o developer key (in run)
|
pyinit + rainbow stuff (take over legacy init's job)
 fork run-parts (/etc/inittab stuff)
 listen for shutdown, etc.
 vserver (- CONTEXT)

Notes on P_SF_RUN

P_SF_RUN:
 off = allow mod = run from /run/X
 on  = pristine  = run from /run/X

switch on->off: set the unlink flags on /run
      off->on:  create immutably-tagged /run/a,b from /pristine/a,b

List of directories in root

 /sys, /proc, /ofw   vfs
 /pristine/trees/{hashes}
 /pristine/configs/`mkdtemp`/current
 /pristine/configs/`mkdtemp`/alt
 /pristine/boot -> configs/<something>
 /pristine/running -> /pristine/tree/<hash>  (version we booted from)
 /pristine/updates/<hash>   (temporary space for updates, preserved in case update
                             net connection drops & updater is restarted)
 /run/{hashes}
 /security
 /home
 /boot -> /pristine/boot/current
 /boot-alt -> /pristine/boot/alt

Upgrade procedure

Upgrade procedure, creating new b from a (w.l.o.g)
 Rainbow: (ATC gives <version> <hash> <priority>)
  0. delete /pristine/current/alt
  1. delete the tree it pointed to
  2. Invoke 'olpc-updater <version>'
     in new container:
[MICHAEL WILL REWRITE STARTING FROM HERE]
           /current (ro-bind mount from /pristine/a)
           /upgrade (initially empty)
 OLPC updater:
  3. clone /current to /upgrade
  4. upgrade /upgrade by hook or crook
[END MICHAEL REWRITES]
  5. exit
 Rainbow:
  6. Verify /pristine/updates/<hash> matches <hash>
  7. Move /pristine/updates/<hash> to /pristine/trees/<hash>
  8. Make a new config /pristine/configs/`mkdtemp`
  9. Create 'current' symlink to /pristine/trees/<hash>
 10. Create 'alt' symlink to *realpath of* /pristine/running
 11. Swing /pristine/boot to /pristine/configs/<foo>, recording prev contents as $old
      (atomic!  iff we do file move of new symlink)
 12. Delete /pristine/configs/$old
 13. If <priority> reboot. (Ask Eben & sugar folks)