Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Kernel & Hardware
  • Search

initrd vs initramfs

Kernel not recognizing your hardware? Problems with power management or PCMCIA? What hardware is compatible with Gentoo? See here. (Only for kernels supported by Gentoo.)
Post Reply
Advanced search
11 posts • Page 1 of 1
Author
Message
lenos
n00b
n00b
Posts: 13
Joined: Wed Mar 09, 2005 1:58 pm

initrd vs initramfs

  • Quote

Post by lenos » Sun Dec 04, 2005 9:52 pm

Hi!

I play around with a liveCD based on gentoo. I upgraded from gentoo-2004.x -> gentoo-2005.1-r1 and suddenly my liveCD doesn't boot anymore. I build the kernel using genkernel.

The kernel message I get is:

"Could not find ramdisk image: initramfs"

I use isolinux as CD boot loader and the entry in isolinux.cfg looks like this:

label qnds
kernel vmlinuz
append initrd=initramfs ramdisk_size=65535 prompt_ramdisk=0 rw root=/dev/ram0 vga=normal

The initramfs file is placed in the same location where I placed the initrd file earlier when it all worked.

I figured out it has to do with initramfs being used in the newer gentoo release but I can't find any descent docs on how to use initramfs (really, I tried googling...) I found a post in this forum on how to build the initramfs image but it seems some vital information is still missing since the kernel can't find the image, or perhaps finds it and discards it for some reason.

I also found the kernel option INITRAMFS_SOURCE but I don't want to have to rebuild the kernel every time I change something in the initramfs image.

Any help appreciated, I'm stuck...
Top
fuzzythebear
Guru
Guru
User avatar
Posts: 317
Joined: Sun Nov 28, 2004 12:57 pm

try something like this :

  • Quote

Post by fuzzythebear » Sun Dec 04, 2005 10:43 pm

Of course you will need to tweak .. but this is how i got it working

title Gentoo Linux 2.6.14-r3 AUTO
root (hd0,1)
kernel /kernel-genkernel-x86-2.6.14-gentoo-r3 root=/dev/ram0 /linuxrcamdisk=8192 real_root=/dev/hda3 vga=791 splash=silent
initrd /initramfs-genkernel-x86-2.6.14-gentoo-r3

excuse the formatting .. but the kernel line is one line till splash=silent
which was a personal choice.

hope that helps / works for you.

Fuzzy
Top
fuzzythebear
Guru
Guru
User avatar
Posts: 317
Joined: Sun Nov 28, 2004 12:57 pm

  • Quote

Post by fuzzythebear » Sun Dec 04, 2005 10:46 pm

bad formatting and then some ..

i just saw .. didnt notice it while previewing sorry ..


title Gentoo Linux 2.6.14-r3 AUTO
root (hd0,1)
kernel /kernel-genkernel-x86-2.6.14-gentoo-r3 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=/dev/hda3 vga=791 splash=silent
initrd /initramfs-genkernel-x86-2.6.14-gentoo-r3

Fuzz
Top
lenos
n00b
n00b
Posts: 13
Joined: Wed Mar 09, 2005 1:58 pm

  • Quote

Post by lenos » Mon Dec 05, 2005 7:08 am

Thanks, but it didn't solve my problem.

The grub config file will not work for me since I use isolinux
I build my own initramfs (named initramfs, with proprietary init, startup scripts, ...) image so I can't use the gentoo prebuilt one
I tried changing my isolinux.cfg file to

Code: Select all

default qnds
prompt 0
display message.txt
label qnds
  kernel vmlinuz
  append initrd=/initramfs ramdisk=8192 root=/dev/ram0 vga=791 splash=silent devfs=nomount 
kernel still complains about "Could not find ramdisk image: /initramfs" (this time with the leading slash ahead).

I can't use the real_root kernel option since I don't know from which device the image is booted (it's a CDROM, could be located anywhere). The init code in the initramfs image determines the boot device instead and the initramfs never returns control to the kernel so as I see it there's no need for the real_root option. I just need the kernel to unpack and start the initramfs image and I'm good to go...
Top
sundialsvc4
Guru
Guru
Posts: 436
Joined: Thu Nov 10, 2005 12:50 am

  • Quote

Post by sundialsvc4 » Mon Dec 05, 2005 6:35 pm

On your /boot directory, you must not only have the kernel-image but also the initramfs image. It sounds like this second file does not exist, or is improperly named. The file-name must be exactly correct, with particular attention paid to the placement of slashes... reflecting the root-directory structure as seen by the boot loader and by the kernel during this phase of the boot.

There are therefore four things to check:
  1. That the contents of the file are correct.
  2. That the file is actually there.
  3. That the boot loader can see it.
  4. That the kernel has been correctly told to reference it.
Top
lenos
n00b
n00b
Posts: 13
Joined: Wed Mar 09, 2005 1:58 pm

  • Quote

Post by lenos » Mon Dec 05, 2005 11:46 pm

First of all, your post made me realize it's not the kernel but the boot loader who is complaining about not finding initramfs, thanks. I then renamed initramfs to initrd and then the boot loader (isolinux) finds it and loads it. The kernel starts executing and later complains about:

"Failed to execute /init"
"Kernel panic - not syncing: No init found. Try passing init= option to kernel."

1. The contents of the file I don't know how to check really. I built it using info from another post on this forum. Let's assume I put the contents at /tmp/contents then I use the following lines to build the image (I removed all error handling for clarity and use hardcoded path names instead of the symbolic ones I use in the script):

Code: Select all

( cd /tmp/contents
   find . -print | cpio --quiet -o -H newc > /tmp/initramfs
   gzip -9 -c /tmp/initramfs > "isolinux directory"/initramfs
)
In /tmp/contents I've put

Code: Select all

sbin/
  init        -- my init executable
init          -- symlinked to /sbin/init
linuxrc     -- symlinked to /sbin/init
initramfs  -- symlinked to /sbin/init
... a lot of other stuff of course like required libs and so on...
Some of the symlinks should satisfy the kernel... I also tried replacing the symlinks with actual copies of the /sbin/init file, same result.

2. When I step into the "isolinux directory" the initramfs file is there, together with the kernel image and isolinux.cfg. Don't know how to further check it out.

3. This one is sorted out now.

4. And how do I do that? There's the init= option and the root= option. No matter what I set init= to, I get the same error message. root= should be /dev/ram0 I guess?

Is there really no initramfs howto available?

I also saw something about mkinitramfs but can't emerge it? Is this distro dependent?
Top
lenos
n00b
n00b
Posts: 13
Joined: Wed Mar 09, 2005 1:58 pm

[SOLVED] initrd vs initramfs

  • Quote

Post by lenos » Sat Dec 10, 2005 9:51 pm

I skipped initramfs, reverted to old initrd again. Still didn't work. Got an "No init found" error message. The problem was that I missed a library needed by my proprietary init. So the init binary (/sbin/init) was there but not the required lib. Not the best of error messages from the kernel, but why should things be easy...
Top
Apropos
n00b
n00b
Posts: 29
Joined: Tue Jan 06, 2004 6:15 am

  • Quote

Post by Apropos » Wed Dec 14, 2005 5:16 am

Read /usr/src/linux/Documentation/early-userspace/README. I have one in the latest linux-2.6.14-hardened-r1 source. At the bottom it sort of explains the difference between an initrd and an initramfs. I'm still trying to figure it out myself. Hope it helps.
Top
lenos
n00b
n00b
Posts: 13
Joined: Wed Mar 09, 2005 1:58 pm

  • Quote

Post by lenos » Wed Dec 14, 2005 10:57 am

Thanks, I'll check it out. From what I've seen else where in forums "early userspace" seems to be a good idea but its benefits doesn't justify the hazzle of getting it to work. At least I fail to see what I personally gain from it, apart from some saved RAM perhaps. The liveCD I'm playing around with is targeted for older PC's which typically have 64MB+ RAM so a little wasted RAM is no big deal.
I understand the kernel developer perspective though, where they want to "purify" the kernel and move stuff out to user space.
Top
Apropos
n00b
n00b
Posts: 29
Joined: Tue Jan 06, 2004 6:15 am

  • Quote

Post by Apropos » Thu Dec 15, 2005 10:09 am

Okay after actually reading your post thoroughly I think I see what may help.

I use both an initramfs cpio file built into the kernel and an initrd file in /boot. The builtin initramfs is a cpio file with directories and whatnot for the splash screen. It is compiled into the kernel.

I also use an initrd file stored in my /boot directory along with my kernel. This is a filesystem (ext2) with evms_activate so I can see my root partition. I notice above that you used cpio for what I think is an initrd file.

The kernel can read and use both at bootup.

So try this because this is what I do to modifiy my initrd in /boot.

First get the size of your directory tree:

Code: Select all

du -s /tmp/contents
I assume from "ramdisk_size=65535" it is about 64k but I'll leave it up to you. Since you never return control back to the kernel you are probably setting it to the size of all your ram but I don't know what else is using memory.

Add about 10% (ext2 overhead) to what you actually need (but not more than the space you have in ram) and create a file for your ext2 filesystem:

Code: Select all

dd if=/dev/zero of=/tmp/initrd bs=1k count=64
Make an ext2 filesystem on that file:

Code: Select all

mkfs.ext2 -b 1024 -F -v /tmp/initrd
If necessary load the loop module into the kernel:

Code: Select all

modprobe loop
Mount the loop device at say /mnt/initrd using the new file /tmp/initrd:

Code: Select all

mount /tmp/initrd /mnt/initrd -t ext2 -o loop
Double check your filesystem size to see if you have enough room for all your files (ext2 takes up some space):

Code: Select all

df /dev/loop0
Copy your disk tree over to the newly mounted loop device:

Code: Select all

cp -Rp /tmp/contents/* /mnt/initrd/
Unmount the loop device, gzip it and move it to /boot or wherever you kernel is:

Code: Select all

umount /mnt/initrd
gzip /tmp/initrd
mv /tmp/initrd.gz /boot
I think that is it. Good luck.

Edit: I think the 64k might be 64M and that would change the dd command above to count=64000.
Top
lenos
n00b
n00b
Posts: 13
Joined: Wed Mar 09, 2005 1:58 pm

initrd vs initramfs [SOLVED]

  • Quote

Post by lenos » Thu Dec 15, 2005 9:41 pm

From my earlier post:
The problem was that I missed a library needed by my proprietary init. So the init binary (/sbin/init) was there but not the required lib.
That is, I didn't include a library which was required by the init code, hence the kernel couldn't find an init (or rather execute it). After putting the library file in the initrd image it all worked and I was happy with that. But after reading your last post it struck me, why not try the initramfs approach again, now that the required library is in place. So I cpio:ed the same files (and added a symlink from /init -> /sbin/init since this is required in an initramfs image) and now the initramfs image works as well.

So everything was just a silly mistake :oops: of forgetting a required library in the first place. But, as so often, you learn from your mistakes (silly or not) and now I know a lot more about "early userspace" than before :)

Thanks for your help!
Top
Post Reply

11 posts • Page 1 of 1

Return to “Kernel & Hardware”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic