Differences between 2.2.x and 2.4.x initrd
I've come across a difference in how initrd is handled in 2.2.x and 2.4.x. This related directly to TILO (sparc TFTP image with ramdisk).
Basically what we have is a kernel image with ramdisk and initrd enabled, and a root disk image slapped on the end that is loaded via initrd.
On 2.2.x, this works without problems; the ramdisk is loaded, and /sbin/init is executed. However, with 2.4.x, it's quite different.
It loads the initial ramdisk, mounts it fine, tries to execute /linuxrc (same as in 2.2.x, but it isn't there, so it continues), and then complains with this:
VFS: Mounted root (ext2 filesystem).
VFS: Cannot open root device "" or 02:00
For some reason it is trying to mount /dev/fd, and totally forgets about /dev/ram. If I pass root=/dev/ram to the command line, it works fine, but I don't want to have to do this :)
I can't seem to find the relevant place where this broke. Any ideas?
Signature · 4 lines
.----------=======-=-======-=========-----------=====------------=-=-----. / Ben Collins -- Debian GNU/Linux \ ` [email protected] -- [email protected] -- [email protected] ' `---=========------=======-------------=-=-----=-===-======-------=--=---'
Quoted 11 lines · Ben Collins
Basically what we have is a kernel image with ramdisk and initrd enabled, and a root disk image slapped on the end that is loaded via initrd.
On 2.2.x, this works without problems; the ramdisk is loaded, and
/sbin/initis executed. However, with 2.4.x, it's quite different.It loads the initial ramdisk, mounts it fine, tries to execute /linuxrc (same as in 2.2.x, but it isn't there, so it continues), and then complains with this:
Quoted 6 lines
VFS: Mounted root (ext2 filesystem).
VFS: Cannot open root device "" or 02:00For some reason it is trying to mount
/dev/fd, and totally forgets about/dev/ram. If I pass root=/dev/ram to the command line, it works fine, but I don't want to have to do this :)
hrm, if your root filesystem is indeed in RAM, then root=/dev/ram seems appropriate on both 2.2.x and 2.4.x. That's what 2.2.x and 2.4.x Documentation/initrd.txt seem to indicate to me, anyway.
Jeff
Signature · 3 lines
Jeff Garzik | Only so many songs can be sung Building 1024 | with two lips, two lungs, and one tongue. MandrakeSoft | - nomeansno
Quoted 15 lines · Jeff Garzik
Quoted 14 lines · Ben Collins
Basically what we have is a kernel image with ramdisk and initrd enabled, and a root disk image slapped on the end that is loaded via initrd.
On 2.2.x, this works without problems; the ramdisk is loaded, and
/sbin/initis executed. However, with 2.4.x, it's quite different.It loads the initial ramdisk, mounts it fine, tries to execute /linuxrc (same as in 2.2.x, but it isn't there, so it continues), and then complains with this:
VFS: Mounted root (ext2 filesystem).
VFS: Cannot open root device "" or 02:00
Quoted 7 lines
Quoted 3 lines
For some reason it is trying to mount
/dev/fd, and totally forgets about/dev/ram. If I pass root=/dev/ram to the command line, it works fine, but I don't want to have to do this :)hrm, if your root filesystem is indeed in RAM, then root=/dev/ram seems appropriate on both 2.2.x and 2.4.x. That's what 2.2.x and 2.4.x
Documentation/initrd.txtseem to indicate to me, anyway.
Well, the point being that 2.2.x worked implicitly, and 2.4.x doesn't. I don't want to have to tell people who have been using tilo forever and a day that they now have to add additional command line to get it to work with 2.4.x.
Signature · 4 lines
.----------=======-=-======-=========-----------=====------------=-=-----. / Ben Collins -- Debian GNU/Linux \ ` [email protected] -- [email protected] -- [email protected] ' `---=========------=======-------------=-=-----=-===-======-------=--=---'
Quoted 4 lines · Ben Collins
Well, the point being that 2.2.x worked implicitly, and 2.4.x doesn't. I don't want to have to tell people who have been using tilo forever and a day that they now have to add additional command line to get it to work with 2.4.x.
You don't have to. Just setup linuxrc to echo the right stuff into /proc/sys/kernel/real-root-dev
Signature · 4 lines
Debian GNU/Linux 2.2 is out! ( http://www.debian.org/ )
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtQuoted 9 lines · Herbert Xu
Quoted 4 lines · Ben Collins
Well, the point being that 2.2.x worked implicitly, and 2.4.x doesn't. I don't want to have to tell people who have been using tilo forever and a day that they now have to add additional command line to get it to work with 2.4.x.
You don't have to. Just setup linuxrc to echo the right stuff into
/proc/sys/kernel/real-root-dev
Yeah, which is listed under the "Obsolete" section in Documentation/initrd.txt. The assumption I'm making here is that if /linuxrc fails to execute, it falls back to /sbin/init on the currently mounted root filesystem. Assumptions are bad, but I don't see why it can't work like this. If there is a filesystem already mounted, it should be used.
Ben
Signature · 4 lines
.----------=======-=-======-=========-----------=====------------=-=-----. / Ben Collins -- Debian GNU/Linux \ ` [email protected] -- [email protected] -- [email protected] ' `---=========------=======-------------=-=-----=-===-======-------=--=---'
Quoted 12 lines · Ben Collins
Quoted 9 lines · Herbert Xu
Quoted 4 lines · Ben Collins
Well, the point being that 2.2.x worked implicitly, and 2.4.x doesn't. I don't want to have to tell people who have been using tilo forever and a day that they now have to add additional command line to get it to work with 2.4.x.
You don't have to. Just setup linuxrc to echo the right stuff into
/proc/sys/kernel/real-root-dev
Quoted 6 lines
Yeah, which is listed under the "Obsolete" section in
Documentation/initrd.txt. The assumption I'm making here is that if /linuxrc fails to execute, it falls back to/sbin/initon the currently mounted root filesystem. Assumptions are bad, but I don't see why it can't work like this. If there is a filesystem already mounted, it should be used.
Really? I always thought the standard behavior of initrd was "umount ramdisk unless" not "umount ramdisk if", implying you need to do something special (like root=/dev/ram) to keep the initrd around.
Signature · 3 lines
Jeff Garzik | Only so many songs can be sung Building 1024 | with two lips, two lungs, and one tongue. MandrakeSoft | - nomeansno
Quoted 20 lines · Jeff Garzik
Quoted 12 lines · Ben Collins
Quoted 9 lines · Herbert Xu
Quoted 4 lines · Ben Collins
Well, the point being that 2.2.x worked implicitly, and 2.4.x doesn't. I don't want to have to tell people who have been using tilo forever and a day that they now have to add additional command line to get it to work with 2.4.x.
You don't have to. Just setup linuxrc to echo the right stuff into
/proc/sys/kernel/real-root-devQuoted 6 lines
Yeah, which is listed under the "Obsolete" section in
Documentation/initrd.txt. The assumption I'm making here is that if /linuxrc fails to execute, it falls back to/sbin/initon the currently mounted root filesystem. Assumptions are bad, but I don't see why it can't work like this. If there is a filesystem already mounted, it should be used.
Quoted 3 lines
Really? I always thought the standard behavior of initrd was "umount ramdisk unless" not "umount ramdisk if", implying you need to do something special (like root=/dev/ram) to keep the initrd around.
That's if /linuxrc remains the initial process (which should in turn exec /sbin/init, atleast according to my reading of the same document):
When finished with its duties, linuxrc typically changes the root device and proceeds with starting the Linux system on the "real" root device.
After it changes root (pivot_root):
Now, the initrd can be unmounted and the memory allocated by the RAM disk can be freed:
# umount /initrd
# blockdev --flushbufs /dev/ram0 # /dev/rd/0 if using devfs
Then there's this note:
Note: if linuxrc or any program exec'ed from it terminates for some reason, the old change_root mechanism is invoked (see section "Obsolete root change mechanism").
The old mechanism is described as using /proc/sys/kernel/real-root-dev, rdev or root= mechanisms.
Now, on 2.2, if any of those were empty (which is the case), it just used the already mounted filesystem (the ramdisk). In 2.4 it assumes that if initrd is enabled, and the root device string is empty, then /dev/fd is the default device. Why this is done, I'm not sure.
Ben
Signature · 4 lines
.----------=======-=-======-=========-----------=====------------=-=-----. / Ben Collins -- Debian GNU/Linux \ ` [email protected] -- [email protected] -- [email protected] ' `---=========------=======-------------=-=-----=-===-======-------=--=---'
Silly TILO. Seems 2.4.x is correctly doing things. TILO was setting HdrS in the kernel to 0x0200 (floppy of course). So, 2.2.x was ignoring it (the wrong behavior), and 2.4.x respects it. I changed TILO to use 0x0100, and now it boots just fine.
Sorry for the hubub.
Signature · 4 lines
.----------=======-=-======-=========-----------=====------------=-=-----. / Ben Collins -- Debian GNU/Linux \ ` [email protected] -- [email protected] -- [email protected] ' `---=========------=======-------------=-=-----=-===-======-------=--=---'