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.
I have been struggling with this problem for a while.
I have a x86 server board that has no disk. My requirements are:
1. Build a ramdisk with a build-in root file system based on a Redhat 6 distribution.
2. PXEboot the board with the kernel and ramdisk. The GRUB legacy is used as bootloader.
3. Let the kernel mount the root file system inside the ramdisk as the final file system. Note this is not NFS-mounted the rootfs from another storage ( I have done this already but this is not what I need).
I know how to do the PXEboot in step 2. But I am not quite sure if there tools to help me to do step 1 and 3. In an embedded PowerPC architecture, buildroot is often used to accomplish these tasks. Is there similar tool for x86-based architecture? Can Redhat's dracut be used?
I don't know what dracut is, but I've done exactly what you're attempting in a more or less homegrown manner. I started out with the Microcore Linux ISO image. I mounted the ISO image on a loop device, so I could extract files from it. There is an existing initrd, microcore.gz, and you can uncompress it, and extract its root filesystem contents as a cpio archive. That creates the root filesystem directory structure. Then, using the existing framework, modify the root filesystem according to your needs (or, just use it as-is). If you modify it, you then re-build the compressed cpio archive. Copy the kernel image and initrd image to your PXE boot host, and you're done.
I started out with the Microcore distro mostly because I wanted something with a minimal footprint to boot headless, diskless CPUs. I don't know if there might be some size thresholds to cross if you want to put a complete Redhat 6 (assume you mean RHEL 6) distro in a RAM disk. It would take quite a while to download and boot such a large image, plus it would require a substantial amount of memory. There is a reason for the name initrd.
This question has come up a couple of times here recently, so I might try to put together a more detailed recipe. If I do so, I'll come back here and post a link.
I don't know what dracut is, but I've done exactly what you're attempting in a more or less homegrown manner. I started out with the Microcore Linux ISO image. I mounted the ISO image on a loop device, so I could extract files from it. There is an existing initrd, microcore.gz, and you can uncompress it, and extract its root filesystem contents as a cpio archive. That creates the root filesystem directory structure. Then, using the existing framework, modify the root filesystem according to your needs (or, just use it as-is). If you modify it, you then re-build the compressed cpio archive. Copy the kernel image and initrd image to your PXE boot host, and you're done.
I started out with the Microcore distro mostly because I wanted something with a minimal footprint to boot headless, diskless CPUs. I don't know if there might be some size thresholds to cross if you want to put a complete Redhat 6 (assume you mean RHEL 6) distro in a RAM disk. It would take quite a while to download and boot such a large image, plus it would require a substantial amount of memory. There is a reason for the name initrd.
This question has come up a couple of times here recently, so I might try to put together a more detailed recipe. If I do so, I'll come back here and post a link.
--- rod.
Rod,
How do I know if the initrd microcore.gz was created for my own x86 board? Does it matter?
As long as there is a correct driver for all of your hardware, it will work. You can only establish that by knowing which drivers are required, and which are either built into the kernel, or installed in the initrd as loadable modules. In most distros, the kernel config file is included with the kernel, so you can see what was built into the kernel. You can look inside the initrd to see what has been included, and add more as required.
Typically, there is enough built into the initrd to permit the kernel to access more drivers from a filesystem, as the initrd is intended as part of a bootstrap system. I your case, you want everything necessary to run all of the system to be built into the initrd. That requires you to add the accordant drivers manually, and presumably to remove those which you don't need. When I did this, my needs were relatively pedestrian, requiring only the most basic functionality, although I did have to add some custom drivers for test and measurement instrumentation (GPIB & VME). That was simple enough, so adding kernel-included driver should also be easy.
Do you believe your target hardware to require some non-standard or atypical drivers? Are you targetting a single hardware architecture, or do you need to accommodate generic hardware?
I'm a newb myself at all this, but I think initramfs is what you're looking for. It's what's used to build the initrd.img file for modern Linux distributions and replaces mkinitrd. Or so I understand.
Myself, I'm still seeking out good tutorials on using initramfs, so any leads in that direction would be useful.
I'm a newb myself at all this, but I think initramfs is what you're looking for. It's what's used to build the initrd.img file for modern Linux distributions and replaces mkinitrd. Or so I understand.
Myself, I'm still seeking out good tutorials on using initramfs, so any leads in that direction would be useful.
yes, you are right. initramfs is the new thing (already since 2.6) to replace initrd. initramfs can grow/shrink but initrd can't. There are many tools to make both. Redhat/Fedora has a new tool call dracut.
I was just able to boot up an small initramfs as the final root file system. I use RHEL6 with kernel 2.6.39.4. The initramfs was built as part of the kernel build process (by dracut). In other words, it's generated as part of the kernel build (make, make modules_install and make install) in /boot. It's about 12MB.
The trick to use it in PXEBoot is you need to specify the following initrd options: root=/dev/ram0 and rdinit=/bin/sh.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.