Commit Graph

9 Commits (0b440844bdaa8ca85fc6bc2bc9aab38b0aa7ebe9)

Author SHA1 Message Date
Daniel Drake f47478b336 switch_root: add subroot support
The current switch_root can only switch to a new root that is the root
of a mount point.

This patch adds support for "subroots", where the new root is somewhere
below a mount point. It does this by adding in a few extra steps to
chroot into the subroot after the enclosing partition has been moved
and entered.

This will be used by OLPC, who sort-of have 2 copies of Fedora stored
on a single partition under different directory trees, where the
initramfs decides which one to boot into.
2009-07-14 13:53:44 +02:00
Harald Hoyer d49449cd4e updated switch_root.c
matches the version, which will go to util-linux-ng
2009-06-19 13:00:08 +02:00
Harald Hoyer afc3ed92cc setsid() and set controlling terminal for real /sbin/init
enables job control in the test images
2009-05-18 14:01:49 +02:00
Victor Lowther 05469ee13e Remove all files on the initramfs before switching root
The code from pjones's tree did not include the recursive remove code,
so I readded it from the nash source code.
2009-03-08 11:39:31 -05:00
Victor Lowther faf882394b Simplify switch_root.c a bit
Shift some required functionality from switch_root.c to init.

String manipulation and filtering, and testing for the existence of init
is easier in the init script than in C.
2009-03-06 22:32:37 -06:00
Harald Hoyer 2394813bf3 mount move instead of umount and fix the search for fallback inits
chdir to newroot, then mount move instead of umount /dev, /sys, etc.
search for fallback init bins in current dirs
2009-03-06 11:53:49 +01:00
Harald Hoyer 63efe29bb3 use switch_root code from http://pjones.fedorapeople.org/mkstart/usr/lib/mkstart/switchroot.c 2009-03-06 10:57:12 +01:00
Harald Hoyer aedead8068 add \n to switch_root 2009-03-04 17:49:19 +01:00
Harald Hoyer c4da240717 replace switch_root shell script with binary
The switch_root shell script did not work with bash-4.0-2, because
"exec" gets the real path of the executable which is then
"/sysroot/lib/ld-linux.so.2" instread of "./lib/ld-linux.so.2".

Also the required chroot binary might live in /usr/bin, which can
be mounted later.

Here is the switch_root code from nash, which can be stripped down
further, but which works.

>From f1b1e4f8694104f007e4483c36b0bf40a5760167 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Date: Wed, 4 Mar 2009 13:41:07 +0100
Subject: [PATCH] replace switch_root shell script with binary

The switch_root shell script did not work with bash-4.0-2, because
"exec" gets the real path of the executable which is then
"/sysroot/lib/ld-linux.so.2" instead of "./lib/ld-linux.so.2".
Also the required chroot binary might live in /usr/bin, which can
be mounted later.

Here is the switch_root code from nash, which can be stripped down
further, but which works.
2009-03-04 17:23:03 +01:00