LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 01-04-2012, 03:43 PM   #1
wdli
Member
 
Registered: Sep 2008
Location: California
Posts: 105

Rep: Reputation: 15
Q: Build a ramdisk with root file system for x86.


Hi,

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?

Thanks.

David
 
Old 01-05-2012, 11:50 AM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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.
 
Old 01-06-2012, 02:51 AM   #3
wdli
Member
 
Registered: Sep 2008
Location: California
Posts: 105

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by theNbomr View Post
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?

David
 
Old 01-06-2012, 09:27 AM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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?

--- rod.

Last edited by theNbomr; 01-06-2012 at 09:29 AM.
 
Old 01-09-2012, 06:55 AM   #5
rafe_b
LQ Newbie
 
Registered: Jan 2012
Posts: 3

Rep: Reputation: Disabled
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.
 
Old 01-10-2012, 08:37 AM   #6
wdli
Member
 
Registered: Sep 2008
Location: California
Posts: 105

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by rafe_b View Post
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating root file image into ramdisk shinobi59 Linux - General 8 11-23-2016 03:30 PM
build x86-64 application on 32-bit machine using x86-64 toolchain linuxgentoo Linux - General 16 06-03-2009 03:15 AM
Building a file system ( Ramdisk) ayoub Linux - Newbie 1 11-10-2005 08:48 PM
Boot x86 target from flash, with the image and file system on the x86 host. batsayan Linux - Software 2 08-23-2005 12:09 AM
Core file creation problem on ramdisk system hasse69 Linux - General 1 05-12-2005 03:06 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 01:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration