Muli Ben-Yehuda wrote:

On Thu, Aug 05, 2004 at 06:31:59PM +0300, Shachar Shemesh wrote:



I'm trying to create my own initrd for specific custom circumstances. As a part of these special circumstances, I wish the "linuxrc" script to perform the actual mounting of the new root filesystem.


That's what linuxrc usually does...




If I specify that "root=/dev/ram0", then linuxrc isn't run at all. If I say anything else, it is going to try and mount the new root system itself, and fail (as it is already mounted).


If it's already mounted, it's because the linuxrc has mounted
it... I've been over this code in the kernel a few times recently, and
if I recall correctly, if you have initrd support compiled in, the
kernel relies on the initrd (which means the linuxrc) for mounting the
root FS. Can you show your linuxrc as Oleg suggested?


Cheers, Muli


A watered down version of the linuxrc is merely something that does:
mount -nt ext3 /dev/hda1 /mnt
pivot_root /mnt initrd

This is a watered down version. The full version does things slightly more interestingly, which is the reason I have to have linuxrc mount root.

If this is run with "root=/dev/hda1" kernel parameter then I get a kernel panic after the script already runs. If I set "root=/dev/ram0" then linuxrc isn't sought after at all, and the usual "find me init" algorithm runs on the initrd mount, which fails at locating all the usual inits, and run /bin/sh (which is actually busybox, but never mind).

What I finally did to solve this problem was to pass to the kernel "root=/dev/hda1", and then write a linuxrc that does:
mount -nt proc proc /proc
mount -nt ext3 /dev/hda1
echo "0x100" > /proc/sys/kernel/real_root_dev
umount /proc
pivot_root /mnt initrd


The problem is that, while this sortof works, I have not seen it documented anywhere.

Explanation - 0x100 is /dev/ram0. In effect, I'm fooling the kernel into thinking it needs to mount a new kernel itself by telling it the root will be /dev/hda1, and then linuxrc tells it that it actually uses /dev/ram0 as the root. What I'm guessing is that once linuxrc finishes, it tries to pivot_root, sees that it already has the right partition mounted, and goes on with the init process as usual. Still, some confirmation that this will not break would be reassuring.

         Shachar
Reference:
initrd manual: http://www.netadmintools.com/html/initrd.man.html
In particular, the following quote:

4. If the indicated normal root file system is also the initial root file-system (e.g. */dev/ram0* ) then the kernel skips to the last step for the usual boot sequence.

I'll just mention that the 8 steps documented there fit 100% to my observed actual behavior, so Muli's explanation does not seem the right one.

            Shachar

--
Shachar Shemesh
Lingnu Open Source Consulting ltd.
http://www.lingnu.com/


================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]



Reply via email to