How to boot and using ramdisk in a diskless environment?
Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Your bootloader is the thing that needs to know about the initrd. I use pxelinux, and on the 'append=' line, I have the clause 'initrd=my/initrd/myInitrd-stable.gz'. The bootloader will then load the initrd, and using some system involving 'atags', tell the kernel where to find the initrd. The exact reference to the initrd is with respect to the filesystem on the boot host, relative to the tftp server root.
--- rod.
That's exactly what I did in PXEboot. My bootloader (pxelinux.0) was able to find the kernel and initrd and downloaded them. The crash happened when the kernel started and was looking for root filesystem to mount.
Click here to see the post LQ members have rated as the most helpful post in this thread.
That's exactly what I did in PXEboot. My bootloader (pxelinux.0) was able to find the kernel and initrd and downloaded them. The crash happened when the kernel started and was looking for root filesystem to mount.
Then you have something wrong in your initrd (it is at this stage not the kernel that is searching for the /-partition), a system that runs from RAM shouldn't actually search for it. Try it with an unmodified kernel and initrd to see if that works.
What messages did you get as the boot progressed? do you see the kernel starting and initializing drivers? The kernel shouldn't have to 'find' the root filesystem, per se.
What messages did you get as the boot progressed? do you see the kernel starting and initializing drivers? The kernel shouldn't have to 'find' the root filesystem, per se.
--- rod.
I dug into the init code and lookslike this is what happened:
During the uncompression of my ramdisk (gzip format), there was an error. The total uncompressed length was 32768. But sys_write could only write 21079 to the file descriptor pointing to /dev/ram. So the error was "write error".
However I haven't found out why this could happen. Is there a hard limit somewhere? My ramdisk.img.gz file is about 395MB. Is it too big?
I don't know if there is a 'too big' size. I am curious how you will get that 395MB file on your boot host that has only 250MB of storage. Doesn't that make it a moot point? Can you try to remove a lot of stuff, until you get the initrd size down to something more manageable? How much memory does your target host have? Don't forget that the initrd is compressed, and it will be larger, maybe a lot larger, when uncompressed. It also takes some memory for the bootloader to actually perform the de-compression. I forget what type of compression is implied by '.gz', but some types of compression can require up to 2 times the size of the final uncompressed image to actually perform the de-compression. Some other methods are more thrifty.
I don't know if there is a 'too big' size. I am curious how you will get that 395MB file on your boot host that has only 250MB of storage. Doesn't that make it a moot point? Can you try to remove a lot of stuff, until you get the initrd size down to something more manageable? How much memory does your target host have? Don't forget that the initrd is compressed, and it will be larger, maybe a lot larger, when uncompressed. It also takes some memory for the bootloader to actually perform the de-compression. I forget what type of compression is implied by '.gz', but some types of compression can require up to 2 times the size of the final uncompressed image to actually perform the de-compression. Some other methods are more thrifty.
--- rod.
Rod,
Good question! I do need to cut it down significantly. But as a starter, I just use whatever RHEL6 gives me to make the initrd. Obviously I can't use it on the real boot host. But I can test it using a regular server host which has a big HD. If this works, then I will think about removing stuff. So far I don't even know how this big initrd would work. I am digging into my kernel's init code to understand more about this beast.
IMHO, you are going about the process backward (been there, done that). Start with a minimal system, and build up by adding what you know you need. Much less reverse-engineering required, and the end result will be closer to optimal.
IMHO, you are going about the process backward (been there, done that). Start with a minimal system, and build up by adding what you know you need. Much less reverse-engineering required, and the end result will be closer to optimal.
--- rod.
That sounds reasonable. So if the end goal is a RHEL6-based initrd, where should I start? Any suggestions?
What does RHEL have that you can't get from other sources? Start with a micro distribution, then replace those components that don't meet your spec, and add the components that are required. If you need the whole kit and kaboodle, then perhaps a fully initrd-based system is unrealistic.
Another approach might be to use one RAM disk to boot the system, and then another that can be populated post-boot from your TFTP server. I've never instantiated a RAM disk filesystem after boot time, but I imagine it can't be that much different from a conventional spinning-media filesystem.
If I recall correctly, Redhat systems use an initrd to boot, by default. Have you unrolled one of those to see how you could build up from that?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.