[lkml]   [2001]   [Oct]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [Q] pivot_root and initrd
>> Works great. I use it in my SuperRescue CD for example; you can
>> there check out a complete, working example.
>> -hpa


Thanks for the example. The documentation for pivot_root must be just
plain lousy-- I thought I'd go "by the book" with the following
admonitions from the manpage:

1) cd to new_root prior to calling pivot_root
2) call pivot_root with relative new_root (.) and put_old
3) call 'chroot' immediately after pivot and redirect stdin/out

You are simply doing the following, I assume with success:

[ ... ]
# Switch roots and run init
cd /ram
pivot_root /ram /ram/initrd
exec /sbin/init "$@"

whereas I am doing something like the following:

[ ... ]
mount -o ro $ROOTDEV $NEWROOT
pivot_root . $OLDROOT

# export for visibility to exec'ed shell
export INITARGS="$@"
export OLDROOT

exec chroot . sh -c 'umount $OLDROOT; exec -a /sbin/init
$INITARGS' <dev/console >dev/console 2>&1

I am mystified that the call to 'exec /sbin/init' works if you are using
the standard (you mention "based on RedHat7.1" util-linux") /sbin/init
proggie, and that a standard RH7.1 initscripts would not complain when
the root filesystem is already mounted r/w.

I would also guess that you are susceptible to the kernel's change_root
call if your /sbin/init terminates. I'll have to play with the disk a bit.


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:08    [W:0.062 / U:1.480 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site