LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   initrd how to make one? (https://www.linuxquestions.org/questions/linux-general-1/initrd-how-to-make-one-41048/)

watashiwaotaku7 01-10-2003 10:57 PM

initrd how to make one?
 
ive just compiled a kernel (2.4.20) and bleieve it is completely ready for use the only problem is i have no initrd.img and dont know what it is or where to get it...i still have one from 2.4.19-9mdk but im assuming this does me no good wiht the new kernel?...so how do i create an initrd.img?

-thanks

nxny 01-11-2003 12:16 AM

Initrd stands for INITial Ram Disk. This is a tiny root filesystem that's loaded into the memory for booting systems that need modules that cannot be accessed at boot time otherwise.

You probably wont need an initrd for the kernel if ext3 support is compiled in( as opposed to modules) Assuming you're not using raid/LVM for the root filesystem and if you are you have the necessary options compiled in. If this is the case you may safely boot the kernel without the initrd.

Mandrake is based on RedHat., I hear. See mkinitrd manpage.

If you are using raid for the root fs and dont have the mkinitrd script, you may create your own initrd. You may find some hints at
http://www.tldp.org/HOWTO/Root-RAID-HOWTO.html

watashiwaotaku7 01-11-2003 09:42 AM

then i most likely dont need one...but when i try to configure lilo it tells me that there is no initrd.img and that it cant continue without one should i just put the old image in to appease it?

nxny 01-11-2003 01:08 PM

Quote:

Originally posted by watashiwaotaku7
then i most likely dont need one...but when i try to configure lilo it tells me that there is no initrd.img and that it cant continue without one should i just put the old image in to appease it?
Edit lilo.conf and remove the initrd line from under your 'new' kernel image. Then rerun the map installer ( /sbin/lilo )

raid517 02-27-2004 02:11 PM

Yeah but how do you do it? I have a bunch of modules that weren't loaded in my Suse 9.0 kernel 2.6.2 install and I know for a fact that there were loaded when I did use an initrd.

I've been looking for days to try to find a way to make one - I have searched hundreds of Google pages - and its always the same anser. "You probably don't need one". Well I have no network, no sound and no 3D acceleration - which kind of makes me think that maybe I do need one.

If I could work out some other way to load the modules I need at boot time then I guess I would be good to go. But Suse doesn't seem to have a /etc/modules file like debian, nor does it have an ./etc/init.d/Kernel-version file like Gentoo.

I'm beginning to think that this is some kind of big Linux secret only known to true gurus. Lol. :)

Comeon guys, can you just explain this to me, please?

GJ

nxny 02-27-2004 02:45 PM

From your post, it sounds like you want to load a few modules( that do get loaded at boot-time when you boot using an initrd) automatically, even without an initrd.

Do you have an rc.local of some sort in SuSE? If yes, you can append
Code:

/sbin/modprobe module-a
/sbin/modprobe module-b

to the said file and that's all you have to do.

That is pretty much all what an initrd does, if you split one open and peek inside.

tincat2 02-27-2004 08:14 PM

do you have an /etc/rc.d//rc.modules-this script loads the modules for sound, network cards and agp support-xf86config plus your drivers should get your 3d going-if you're just plugging in a new kernel and have done 'make modules', what you need should be there.

jong357 02-27-2004 09:16 PM

Yea... An initrd.img is pointless.... I dont use one on Redaht or Suse even tho they start you out with one. I've got a custom compiled kernel specific to my machine and I have alot of stuff hard-wired in as well... Your either missing something in your kernel or your not deleting the initrd line from your bootloader config file. Trust me.... Ditch it.

raid517 02-28-2004 09:07 AM

Thanks guys, but SuSe doesn't seem to have an etc/rc.d//rc.modules or rc.local file. Does anybody know how I can get the modules I need to load automatically at boot time in Suse without an initrd? You guys seem to think an initrd is a bad idea so I am happy to try another method.

Any ideas? So far there is no /etc/modules, no /etc/init.d/kernel-version, no /etc/rc.local, no etc/rc.d//rc.modules and nothing else resembling that that I can see. I would be happy to live without an initrd entry - but I do need my drivers to be automatically loaded at boot time so I don't have to modprobe them by hand every time my PC starts.

GJ

jong357 02-28-2004 10:52 AM

Recompile your kernel. DO NOT use modules for a file system. Especially not your root file system. That is a really illogical thing to do. I never use modules for important KEY functions. All file systems and devices I hardwire into the kernel. The only thing I use modules for is ipv6 and various other "less important stuff". My kernel image still stays under 1.5mb. If all that is built in, and your kernel config is just the way you want it, do a

make bzImage modules modules_install

move your new System.map and bzImage to your boot folder and readjust your grub or lilo config file. Ditch the initrd line as well... Boot up. (I also move the vmlinux to /boot as well just to keep that stuff together.)

Your kernel will know what modules to load by looking at config files in /lib/modules/uname -r

/bin/bash 02-28-2004 11:24 AM

The answer to the question is:
mkinitrd /boot/initrd-x.y.z x.y.z
Where x.y.z is the kernel version.

Having an initrd is perfectly acceptible. If you choose to build a modular kernel then go ahead, and don't let anyone tell you it is wrong to do. I have a reiserfs filesystem and always build reiserfs as a module with no problems. And yes there are some things that CAN NOT be built into the kernel and therefore require an initrd. The one thing I know of is the pictures for bootsplash require an initrd to pass them to the kernel. The one filesystem you have to build into the kernel is ext2 because the initrd image is made using ext2 filesystem.

raid517 02-28-2004 01:38 PM

Thanks man, I was begining to wonder if making an initrd was some kind of Linux secret - and yes I do want to use bootsplash. The only problem is I did exactly what you said. I opened a command window on the desktop and typed:

Code:

mkinitrd /boot/initrd-2.63
where the only thing I changed was the number to represent my initrd and kernel version.

But when I did this and hit enter I got:

Code:

/boot/linux-2.6.3/var/tmp is not a directory
What does this mean and how do I fix it?

GJ

dford 02-28-2004 02:32 PM

mkinitrd is just a shell script, perhaps you might look through it to see where the problem is occurring. Offhand in my version, I don't see where that message would come from, but I'm using RedHat. One thing to be aware of is that it does a loopback mount of the initrd-2.6.3 file and creates a directory structure under it. It is possible that is what it is referring to.

/bin/bash 02-28-2004 05:36 PM

To make initrd for 2.6.3 kernel do exactly this. <edit> Of course you must be root to do this.

mkinitrd /boot/initrd.2.6.3.img 2.6.3

NOTE: The initrd.2.6.3.img is just a filename and you can name it anything you want but the rest is necessary. Make sure the entry in /etc/lilo.conf matches, for example:

Code:

image=/boot/vmlinuz-2.6.3
        label="Linux"
        root=/dev/hda7
        initrd=/boot/initrd-2.6.3.img
        append="devfs=mount reboot=w panic=10 splash=silent"
        vga=788
        read-only

BTW if you didn't apply the bootsplash patch to the 2.6.3 kernel sources then you won't have bootsplash. The patch is at www.bootsplash.org but it's for 2.6.0-test9. It works for most 2.6.X kernels except you get some errors patching and have to do some of the work by hand. I havent got it to work for 2.6.3 yet.

raid517 02-28-2004 06:31 PM

Thanks man. But I'm still getting that crazy error message about var/tmp not being a directory. What is it going on about?

GJ

michael@actrix 02-29-2004 01:59 AM

Quote:

Originally posted by raid517
Code:

mkinitrd /boot/initrd-2.63

Where as, /bin/bash said:
Quote:

Originally posted by raid517
Code:

mkinitrd /boot/initrd.2.6.3.img 2.6.3

Which has one extra parameter - the kernel version, and some extra punctuation. /bin/bash's version is definitely what I would expect to do.

Because I haven't ever used SUSE, the following is speculation based on experience with Redhat. If SUSE has a /bin/installkernel or /sbin/installkernel, and you've done all the other steps in the kernel install process (make bzImage, make modules, make modules_install), then I think doing a "make install" in the kernel directory might do all the right things - such as making an initrd, and installing the kernel. But for all I know this might be a really bad thing to do on SUSE.

jong357 02-29-2004 02:43 AM

good point /bin/bash..... I tend to think rather linear when it comes to giving advice. I.E - I have no need for it so why should you? But honestly, what other practical use is there to using an initrd image besides having a "pretty" background to your bootloader? If that was a concern for me, I suppose I would be booting into a runlevel 5 with flowers and cute pictures of teddy bears as well insted of init3.... There are a few other uses for initrd that are on the tip of my mind, but again, are they really necessary? It just seems really silly to rely upon external modules when the middleman can be kicked to the curb completely.... Your just increasing the complexity of your boot process and increasing the risk of your system not booting.... I'm all for simplicity I guess.... I also like it when I can consistently boot into any new kernel that I compile without a hitch.... :) Well, good post. I might have to expierment with using initrd just to learn some new stuff.....

/bin/bash 02-29-2004 10:13 AM

As was posted earlier mkinitrd is a script. And Suse may have their own version of that script. If you just type mkinitrd without parameters it should spit out some usage help, if you could do that and post it here. It looks to me like it is thinking /boot/initrd.2.6.3.img is the path to a /var/tmp directory instead of the name of the initrd file. Maybe Suse has the parameters in a different order. With Mandrake it is:
mkinitrd [options] <initrd.img> <kernel ver>


Quote:

Posted by jong357
But honestly, what other practical use is there to using an initrd image besides having a "pretty" background to your bootloader?
I'm sure there are hundreds or thousands of uses for initrd of which I'm not aware, I just said that bootsplash was one instance where an initrd image was required and not an option.
Since you asked...
  1. Suppose you have a system with minimal ram and harddrive space. You can't even keep kernal sources on it so you build your kernel on another system and download it to this system. You build a modular kernel because of memory restraints and use initrd to pass modules needed for booting to the kernel. Then you can remove the modules when not needed and free up memory.
  2. You are a wannabe kernel hacker designing a new foobar adapter module. You don't want to build a new kernel every time you modify the module but the module is required to boot. So you put it in initrd and when you modify it you just make a new module and a new initrd and you don't need to make a new kernel.
  3. You have a scsi drive you use to transport large amounts of data to work and home. So sometimes you want to boot your kernel with scsi support and sometimes you don't (when you forget and leave the drive at work). You just modify /etc/lilo.conf and in the "Linux-scsi" section you put an initrd=/boot/initrd-scsi.img

Well thats just a couple instances I thought of off the top of my head, and probably there are many other. Using initrd is just another choice you have in Linux, it's there if you want to/need to use it.

Outabux 03-19-2004 11:53 PM

Hey bin/bash, would u take a look at my post, for I need an initrd for custom dsdt so I can fine tune acpi!


Thanks...2.6.4 acpi patch in debian...

http://www.linuxquestions.org/questi...hreadid=158824


All times are GMT -5. The time now is 10:13 AM.