LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-19-2010, 01:10 PM   #1
Caldus
Member
 
Registered: Oct 2007
Posts: 36

Rep: Reputation: 15
How to make initrd that contains root file system?


Hello all,

I am attempting to PXE boot Redhat 5.4 and load the OS into RAM. Here is how far I have gotten so far:

I have successfully configured my DHCP, TFTP, and PXE servers. The PC that is booting up Redhat 5.4 is able to get a DHCP IP address from the server, grab the kernel and initrd from the TFTP server, and boot up from there. I have this setup working if I store the root file system on a NFS share on the server and use the kernel's NFSROOT parameter. Long story short, I now need to get this same setup working without using NFS if possible. I have spent several hours google searching how to create a RAM disk (initrd) that also contains the root file system. I must be searching the wrong keywords. Anyway, based on what I have read so far, I need to do the following:

1. I need to pass different kernel parameters. It needs to look something like:

kernel initrd=/initrd_with_root_file_system.gz rw root=/dev/ram0

2. It seems like newer versions of initrd are created using the cpio tool. So would this simply be a matter of booting to my hard drive that has Redhat 5.4 loaded on it and running:

% find . -depth -print | cpio -ov > initrd.img

to create the RAM disk with a root file system attached to it? I have a feeling it has to be more complicated than that but I just cannot find any sites that specifically explain what would be involved with creating an initrd file that can also be used as the root file system.

3. Would I need to modify the init script (many sites call it "linuxrc") at all in order to accomplish what I want to do? For example, I found this site:

http://www.jacobstoner.com/index.php...oot-on-ramdisk

My understanding of this page is that you have to create a linuxrc script that basically does the work of decompressing the file system into /dev/ram0 and mounting it to /root. Is something like this actually needed?

4. The kernel must have certain parameters set such as enabling RAM disk support.

I have most of this setup working. I just need to figure out how to basically store the contents of the OS on the TFTP server and then tell the kernel to load that OS into memory. Based on what I have read, this should be possible (otherwise, how do Live CD's work?).

Thanks for any help!

Last edited by Caldus; 05-19-2010 at 01:17 PM.
 
Old 05-19-2010, 01:40 PM   #2
brucehinrichs
Member
 
Registered: Mar 2008
Location: US
Distribution: Debian Sid; Sabayon, UbuntuStudio, Slackware-multilib 13.1, Peppermint Ice, CentOS
Posts: 575

Rep: Reputation: 69
What did Redhat customer service say? I would pick their brains first, that's what you're paying them for.
 
Old 05-19-2010, 01:48 PM   #3
Caldus
Member
 
Registered: Oct 2007
Posts: 36

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by brucehinrichs View Post
What did Redhat customer service say? I would pick their brains first, that's what you're paying them for.
I probably could, but it would take a looong while to finally get to someone who could actually help (big company politics and bureaucracy you know :P). I'm assuming that creating root file system RAM disks should be independent of what distribution I am running anyway.
 
Old 05-19-2010, 01:57 PM   #4
brucehinrichs
Member
 
Registered: Mar 2008
Location: US
Distribution: Debian Sid; Sabayon, UbuntuStudio, Slackware-multilib 13.1, Peppermint Ice, CentOS
Posts: 575

Rep: Reputation: 69
Then why pay them? Use CentOS for free if you can't get the help you're paying for.

Anyway, not knowing what you tried already, a google search for 'root file system RAM disks' yields some promising results...
 
Old 05-19-2010, 07:21 PM   #5
Caldus
Member
 
Registered: Oct 2007
Posts: 36

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by brucehinrichs View Post
Then why pay them? Use CentOS for free if you can't get the help you're paying for.

Anyway, not knowing what you tried already, a google search for 'root file system RAM disks' yields some promising results...
Wasn't my decision to go to Redhat. :P

Thanks for the keywords. It seems like based on what I have read, all I need to do is just put what I want into a new initrd.img file and change the kernel boot parameters to:

kernel initrd=/initrd.img rw ramdisk_size=2097152 init=/linuxrc root=/dev/ram0

(Allocate 2 GB for the ram disk)

The diskless PC has 4 GB of RAM, so I should be fine I would think.
 
Old 05-19-2010, 10:33 PM   #6
Caldus
Member
 
Registered: Oct 2007
Posts: 36

Original Poster
Rep: Reputation: 15
OK so here's what I tried out. I wanted to try and accomplish this in small steps. So what I tried first is to simply boot any PC up using a custom initrd.img. I figured out that I needed to use the following command to extract the contents of the existing initrd.img so that I can edit the image as needed. I ran the following commands:

Code:
mkdir /tmp/ramdisk
cp /boot/initrd.img /tmp/ramdisk
cd /tmp/ramdisk
mv initrd.img initrd.img.gz
gzip -d initrd.img.gz
cpio --extract < initrd.img
That will now allow me to see the files that are on the ram disk under /tmp/ramdisk. Once I am finished adding files, etc., I run these commands to create the new custom initrd.img:

Code:
find . | cpio -o -H newrc | gzip > /boot/initrd.img
After that, this is the part where I am still just totally confused about. I know I have to modify the kernel parameters somehow to tell it that the RAM disk is going to be the root file system. I tried all kinds of different combinations of kernel parameters with no success. Does anyone know what the correct kernel parameters are for loading a RAM disk image as the root file system?
 
  


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
[SOLVED] Make the root file system read-only on RHEL 5.3 ursusca Linux - Security 17 11-28-2009 04:18 PM
How to make root file system be read-only? Completely Clueless Linux - Security 10 04-19-2009 06:00 AM
make bootable CD from hard disk image and mount root file system as ramfs Mr.J Linux - Embedded & Single-board computer 1 08-19-2008 07:29 AM
making kernel RPM. does not make initrd file mindcry Linux - Software 5 08-12-2004 10:20 PM
How do you make a initrd and vmlinux file? britishnemesis Linux - General 10 11-03-2003 09:30 AM

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

All times are GMT -5. The time now is 10:28 PM.

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