pivot_root -> switch_root

This commit is contained in:
Denis Knauf 2012-06-02 10:10:54 +02:00
parent 7d61a0acdf
commit 6ac1d4d5bb

37
isirc
View file

@ -1,12 +1,11 @@
#!/bin/sh #!/bin/sh
QUITE=false PATH=/bin
export PATH
QUITE=${QUITE:-false}
log() { log() {
if [ "X$QUITE" != "Xtrue" ] [ "X$QUITE" != "Xtrue" ] && echo "$*"
then
echo "$*"
fi
} }
err() { err() {
@ -17,7 +16,6 @@ if [ "x${1}x" != "x-rx" ]
then then
exec </dev/console >/dev/console 2>&1 exec </dev/console >/dev/console 2>&1
log "### ISIRD ###" log "### ISIRD ###"
PATH=/bin
cd / cd /
log " mount proc and sysfs and / as rw" log " mount proc and sysfs and / as rw"
@ -41,11 +39,8 @@ else
log " returned" log " returned"
fi fi
log " detect cmdline options..."
ROOT="$(cmdline -c root)" ROOT="$(cmdline -c root)"
log " root: #{ROOT}"
FLAGS="$(cmdline -c rootflags)" FLAGS="$(cmdline -c rootflags)"
log " flags: ${FLAGS}"
if cmdline -c ro if cmdline -c ro
then then
FLAGS="${FLAGS},ro" FLAGS="${FLAGS},ro"
@ -53,7 +48,6 @@ elif cmdline -c rw
then then
FLAGS="${FLAGS},rw" FLAGS="${FLAGS},rw"
fi fi
log " flags: ${FLAGS}"
FSTYPE="$(cmdline -c rootfstype)" FSTYPE="$(cmdline -c rootfstype)"
FSTYPE="${FSTYPE:-auto}" FSTYPE="${FSTYPE:-auto}"
log " umount sysfs" log " umount sysfs"
@ -66,25 +60,6 @@ then
exec sh exec sh
fi fi
if ! test -d /mnt/initrd || mkdir /mnt/initrd
then
err "/initrd doesn't exist on root!"
exec sh
fi
log " Change to new root"
cd /mnt cd /mnt
if ! pivot_root . initrd log " Change to new root"
then exec switch_root /mnt /bin/sh
err "Can't pivot root!"
cd /
exec sh
fi
log " OK :)"
export LD_LIBRARY_PATH="/initrd/lib"
LD_SO="${LD_LIBRARY_PATH}/ld-linux.so.2"
${LD_SO} /initrd/bin/ls /mnt/dev/*
echo 0x0100 > /initrd/proc/sys/kernel/real-root-dev
${LD_SO} /initrd/bin/umount -n /initrd/proc
exit 0