diff options
author | Matthias Hentges <oe@hentges.net> | 2006-01-24 11:37:57 +0000 |
---|---|---|
committer | OpenEmbedded Project <openembedded-devel@lists.openembedded.org> | 2006-01-24 11:37:57 +0000 |
commit | 378aacc1ff39a0fc6010bfe06b126108ec904283 (patch) | |
tree | aee20523b2d3a4ac7a1fcf57ed5fbafd9b648007 /packages/altboot/files/altboot.func | |
parent | fc1aee6b0d22286c48bb025c8d47faa8b93d96c6 (diff) |
altboot:
- Reworked moving old mountpoints into the new rootfs
- Optimized pivot_root'ing
Diffstat (limited to 'packages/altboot/files/altboot.func')
-rw-r--r-- | packages/altboot/files/altboot.func | 58 |
1 files changed, 24 insertions, 34 deletions
diff --git a/packages/altboot/files/altboot.func b/packages/altboot/files/altboot.func index 1c21a5f2f8..e1196ecc7f 100644 --- a/packages/altboot/files/altboot.func +++ b/packages/altboot/files/altboot.func @@ -67,30 +67,7 @@ pivot_realfs() { mount -o remount,ro / - echo -n "Pivoting root..." - if (/sbin/pivot_root $1 $1/media/ROM) - then - echo "Success" - - # Interestingly, this doesn't work with the "real" mount - # Without this command, /dev would be mounted under /media/ROM/dev after pivoting root - /bin/busybox mount -o move /media/ROM/dev /dev - - cd / - - # Boot /sbin/init if it is available or use /sbin/init.sysvinit instead - if test -x $/sbin/init - then - echo "Calling INIT [/sbin/init $RL]" - exec /usr/sbin/chroot . /sbin/init $RL >/dev/tty0 2>&1 - else - echo "Calling INIT [$REAL_INIT $RL]" - exec /usr/sbin/chroot . $REAL_INIT $RL >/dev/tty0 2>&1 - fi - else - echo "FAILED" - die "* * * pivot_root failed! * * *" - fi + do_pivot "$1" "$RL" } # This function loop-mounts an image-file and pivot_root's into it @@ -153,12 +130,17 @@ pivot_image() { fi # If mount fails it has the tendency to spew out a _lot_ of error messages. # We direct the output to /dev/null so the user can see which step actually failed. - mount -t $IMAGE_TYPE /dev/loop0 /media/image >/dev/null 2>&1 || die "mount -t $IMAGE_TYPE /dev/loop0 /media/image failed!" + mount -t $IMAGE_TYPE /dev/loop0 /media/image >/dev/null 2>&1 || die "mount -t $IMAGE_TYPE /dev/loop0 /media/image failed!" mkdir -p /media/image/media/ROM || die "mkdir -p /media/image/media/ROM failed" + do_pivot /media/image "$RL" +} + +#$1=mountpoint of the soon-to-be rootfs, $2=Runlevel +do_pivot(){ echo -n "Pivoting root..." - if (/sbin/pivot_root /media/image /media/image/media/ROM) + if (/sbin/pivot_root "$1" "$1/media/ROM") then echo "Success" @@ -169,18 +151,28 @@ pivot_image() { # Move mountpoints from the old rootfs into the new one. # The *real* mount is kinda touchy feely about that - /bin/busybox mount -o move /media/ROM$1 $1 - /bin/busybox mount -o move /media/ROM/dev /dev - /bin/busybox mount -o move /media/ROM/proc /proc >/dev/null 2>&1 + /bin/busybox mount -o move /media/ROM/proc /proc >/dev/null 2>&1 + for mpt in ` mount | grep "/media/ROM/" | awk '{print $3}'` + do + new_mpt="`echo "$mpt" | sed -n "s/\/media\/ROM//p"`" + + echo "Moving mountpoint [$mpt] -> [$new_mpt]" >/dev/tty0 2>&1 + + ! test -d "$new_mpt" && mkdir -p "$new_mpt" + /bin/busybox mount -o move "$mpt" "$new_mpt" + done + echo "Calling INIT" - exec /usr/sbin/chroot . /sbin/init $RL >/dev/tty0 2>&1 + + #read junk + + exec /usr/sbin/chroot . /sbin/init $2 >/dev/tty0 2>&1 else echo "FAILED" die "* * * pivot_root failed! * * *" fi - } # This functions configures the master password for altboot if none is set @@ -188,11 +180,9 @@ set_password() { mount -o remount,rw / if test -z "$MASTER_PASSWORD" then - echo -e "\nAltboot is a boot-manager which allows to boot from SD,\nCF and NFS" + echo -e "\nAltboot is a boot-manager which allows to boot from SD,\nCF, USB-Storage and NFS" echo -e "\nFor security reasons altboot requires a password\nto boot into init=/bin/sh." echo -e "${C_RED}This is *not* your root password!\nIt is used by altboot alone!${C_RESET}\n" - #echo -e "${C_BLUE}\nNote:\tThe password will be echoed to the screen\n\tand it will be asked twice for confirmation.${C_RESET}" - #echo -e "\nPlease enter a new master password:\n" while true do |