Skip to contentSkip to conversation

Initrd Question

DISCUSSION [email protected] 3 participants 3 messages Feb 13, 2004 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

On Fri, 13 Feb 2004 15:20:13 +0100, you wrote in linux.kernel:

Quoted 5 lines
Quoted 2 lines
Quoted 1 line

echo 0x0100 > /proc/sys/kernel/real-root-dev

This makes no sense as you're using pivot_root.

this makes all sort of sense. Please check sources. It is required so that kernel will not attempt to mount root passed to it by loader. You are welcome to clean up the code :)

I'm not doing that and it works as expected. Note that the initrd code in question never exits. It execs init. So when would the kernel do this attempted mount of the root filesystem passed in by the bootloader? My understanding is that the old, non-pivot_root method works by exiting the initrd script - and *then* the kernel attempts to mount real-root-dev.

In any case, if that wasn't clear, I expect the bootloader to pass in root=/dev/ram0 anyway. ;)

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

mount -n -o ro /dev/sda2 /new_root

This doesn't even match with the 0x0100 above, now does it?

so what? kernel happily ignores real-root-dev, it is possible that some user-level tools may be confused but I have not seen any so far.

Now you're saying the kernel ignores real-root-dev, while a moment before you state that it is important to set real-root-dev because otherwise the kernel does something. Which is it?

Quoted 6 lines
Quoted 2 lines
Quoted 1 line

pivot_root /new_root /new_root/initrd

You should cd into /new_root before running pivot_root,

Huh? Why?

SYNOPSIS
pivot_root new_root put_old

And just a couple of lines further down:

Note that, depending on the implementation of pivot_root, root and cwd of the caller may or may not change. The following is a sequence for invoking pivot_root that works in either case, assuming that pivot_root and chroot are in the current PATH:

cd new_root
pivot_root . put_old
exec chroot . command

The pivot_root(2) manpage states the same, by the way.

Signature · 2 lines
Ciao,
Pascal
#2 lore raw

So is the /proc/real-root-dev seems to be a necessary file after all for the pivot_root to work, is that correct? If so the initrd.txt needs to be updated.

#3 lore raw
In reply to [email protected]
Followup to:  <E1ArfAQ-00007f-7Z@localhost>
By author:    [email protected]
In newsgroup: linux.dev.kernel
Quoted 5 lines

Now you're saying the kernel ignores real-root-dev, while a moment before you state that it is important to set real-root-dev because otherwise the kernel does something. Which is it?

You have to set root=/dev/ram0 in the boot loader, so that the kernel will spawn /sbin/init with pid 1. Otherwise it spawns /linuxrc with a non-1 pid, for dumb historical reasons.

Thus, setting it in the script is too late to do any good.

-hpa

Signature · 4 lines
PGP public key available - finger [email protected]
Key fingerprint: 2047/2A960705 BA 03 D3 2C 14 A8 A8 BD  1E DF FE 69 EE 35 BD 74
"The earth is but one country, and mankind its citizens."  --  Bahá'u'lláh
Just Say No to Morden * The Shadows were defeated -- Babylon 5 is renewed!!