LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices

Reply
 
Search this Thread
Old 06-09-2008, 09:00 PM   #1
Ken B
LQ Newbie
 
Registered: Jun 2008
Posts: 3

Rep: Reputation: 0
Question How do I edit the initrd.img in the RHEL 5.1 boot disk?


Hello,

I am trying to make a RHEL 5.1 installer that runs from a USB flash drive. I would like to place a kickstart file in the install system's root directory, so that I may use it with ks=file:/ks.cfg. I understand that I must modify the contents of the initrd.img located in the <RHEL 5.1 CD>/images/diskboot.img.

I found a few websites that say initrd.img is a gzipped ext2 filesystem. They give the following procedure for opening initrd.img:

# gzip -dc /mnt/boot/initrd.img >/tmp/initrd.ext2
# mkdir /mnt/initrd
# mount -o loop /tmp/initrd.ext2 /mnt/initrd
(http://www.faqs.org/docs/Linux-HOWTO...WTO.html#ss6.2)

However, I have had no success with this. gzip does successfully decompress the file, but when I attempt to mount it, mount does not recognize the filesystem type. When I specify the filesystem type as ext2 with

# mount -t ext2 -o loop /tmp/initrd.ext2 /mnt/initrd

the output suggests that I may have a bad superblock. (Sorry, but I'm not able to reproduce the exact output at the moment.)

Can anyone please shed some light on my problem? Thank you very much.

Last edited by Ken B; 06-09-2008 at 09:00 PM. Reason: Put the URL for my source in.
 
Old 06-10-2008, 04:40 AM   #2
blacky_5251
Member
 
Registered: Oct 2004
Location: Adelaide Hills, South Australia
Distribution: RHEL 4&5, Fedora 10, CentOS 5.4, IPCop
Posts: 569

Rep: Reputation: 54
Hi,

You're partly correct. The initial ram disk image is a compressed file, but it is a compressed cpio archive. Try this command to see what is inside your initrd file.
Code:
zcat /boot/initrd-$(uname -r).img | cpio -itv | less
You should now see the content of the file.
 
Old 06-10-2008, 07:34 AM   #3
Ken B
LQ Newbie
 
Registered: Jun 2008
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks for the help! That works like a charm.
 
Old 07-17-2008, 06:53 AM   #4
trev_uk
LQ Newbie
 
Registered: Jul 2008
Posts: 2

Rep: Reputation: 0
Hi there, I am having the same problem.
Could you advise which command will extract the kickstart initrd.img
and then how we can mount it in rhel5.

I can view the files with cpio but I want to extract them so I can add new net driver modules.
 
Old 07-17-2008, 05:54 PM   #5
blacky_5251
Member
 
Registered: Oct 2004
Location: Adelaide Hills, South Australia
Distribution: RHEL 4&5, Fedora 10, CentOS 5.4, IPCop
Posts: 569

Rep: Reputation: 54
If you extract the files from the initial ram disk file, you just have a bunch of files - not a mountable file-system. If you want to modify your current initial ram disk file by adding modules, use the mkinitrd command to build a new initrdxxx.img file.

Perhaps some more info about what you're doing might help us provide a better response for you

Ian
 
Old 07-18-2008, 04:59 AM   #6
trev_uk
LQ Newbie
 
Registered: Jul 2008
Posts: 2

Rep: Reputation: 0
I was working on hacking rhel5 kickstart initrd to add new network drivers. I have completed this but for other users here's how:

gzip –dc initrd.img >initrd.x
cpio –id < initrd.x

This will extract all folders.
I extracted the modules.cgz & added new kernel module drivers.
Repackage using cpio & gzip.
Put it back into initrd/modules folder.
Modify modules/pci.ids with details of your new modules.
Then use mkisofs & create a kickstart CD
 
Old 07-18-2008, 08:34 AM   #7
Ken B
LQ Newbie
 
Registered: Jun 2008
Posts: 3

Original Poster
Rep: Reputation: 0
Here's the process I used. The important trick is specifying the "newc" cpio format.

1 Decompress.
gunzip < initrd.img > initrd.cpio
2. Append files.
ls myfile | cpio -oAO initrd.cpio -H newc
3. Recompress.
gzip -cz initrd.cpio > initrd.img
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Failed to symbolic-link boot/initrd.img-2.6.18-4-486 to initrd.img Scotteh Linux - Software 8 06-01-2007 11:24 PM
I want to edit initrd.img in my fedora 6 dvd-iso rishipandit007 Linux - General 7 01-19-2007 12:42 AM
how to make initrd.img for your kernel without boot disk? donaldtalbert Linux - Software 1 06-19-2005 10:30 PM
Mounting boot/initrd.img Law1213 Linux - Software 10 01-25-2005 02:37 PM
No /boot/initrd*.img in RH7? stoub Linux - Newbie 0 12-15-2002 10:59 PM


All times are GMT -5. The time now is 11:45 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration