LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices



Reply
 
Search this Thread
Old 09-10-2011, 04:22 PM   #1
launchpadtt
Member
 
Registered: May 2005
Location: Brooklyn, originally from Trinidad and Tobago
Distribution: (Ku, Xu, U)buntu
Posts: 30

Rep: Reputation: 15
How do I successfully edit an initramfs / initrd?


I have an interesting problem that I pose to the community.

Here's the short version of my question:

I need to edit an initrd in order to make a change to a file in a LiveCD.

I do the following commands to edit the initrd. Here dtk_3.5.1_27_Linux.iso is the LiveCD and the initrd is located on isolinux/SA.2 on the LiveCD

Code:
# first i get my initrd out of the ISO
mount -o loop dtk_3.5.1_27_Linux.iso dtk_3.5.1_27_Linux
cp dtk_3.5.1_27_Linux dtk_3.5.1_27_Linux_root
cd dtk_3.5.1_27_Linux_root && mkdir -p ~/SA-contents && cp isolinux/SA.2 ~/SA-contents

# then i extract its contents
cd ~/SA-contents && gunzip -S "2" SA.2
cpio -it < SA

# then i make the changes
vi bin/start-stage3.sh

# then i put the initrd back together
find . -depth -print | cpio -ov -H newc > ~/build.initramfs
cd ~ && gzip -9 build.initramfs && mv build.initramfs.gz SA.2
chmod +x SA.2

# and i put it back into the ISO and put the ISO back together
cp SA.2 dtk_3.5.1_27_Linux_root/isolinux
cd dtk_3.5.1_27_Linux_root
mkisofs -o ../dtk_3.5.1_27_Linux_smb.iso -b isolinux/isolinux.bin -c isolinux/boot.catalog -no-emul-boot -boot-load-size 4 -iso-level 2 -relaxed-filenames -r -J -pad -boot-info-table .
Then I boot into the ISO and during boot it gives me this error:

Kernel panic - not syncing: No init found. Try passing init= option to kernel.

Now the SA.2 initrd has an init script in the root of the image. I've reextracted it to be sure that its there.

The entry in isolinux/isolinux.cfg on the LiveCD is the following

Code:
# Modify this if dtk files are on modified dtk CD.
# the mount command will be....
# mount /dev/cdroms/cdrom0 /opt/dell/toolkit/systems/
label cdrom
    kernel SA.1
    append initrd=SA.2 ramdisk_size=156482  Stage3_type=cdrom DEBUG=0 quiet share_type=cdrom share_script=setbootfloppy.sh selinux=0
There's no init option here. and it successfully boots with the original SA.2 even though there's no init option, so why is asking it for it now even though I've made a very minor change?

Did I miss an option or command in all this? Is what I'm trying to do even possible?

--------------------------------------------------------------
Here's the long version of my question with all the background:

I need to use the Dell Deployment Toolkit for my job. located here: http://support.us.dell.com/support/d...&fileid=461457

Documentation here: http://support.dell.com/support/edoc...f/OMDTUGMR.pdf

Apparently the way it works is that you have to extract the contents of the iso into a folder, then make the changes to the isolinux/isolinux.cfg on the CD based on how you want it to find a script, that you've written, that you want to run. Based on which preset you made the default in isolinux.cfg, the /bin/start-stage3.sh script in the LiveCD's init image on startup will run the script accordingly. Then you reburn the CD contents to a new ISO. (The documentation gives the mkisofs command to run)

The script that you use when mounted and run from that LiveCD makes use of tools in the ISO to deploy things I guess (I just need it to run a few commands so I can change the BIOS boot order on a machine non-interactively). Then you boot into the CD or ISO on the target system and its supposed to run it.

So one of the options in the isolinux.cfg is cdrom. In that one, when you're making changes to the ISO and its files, you add the script that you want to it and then during the LiveCD's startup, /bin/start-stage3.sh will mount that CD to /opt/dell/toolkit/systems/ then your script which is at the root of the CD will be run.

The isolinux.cfg looks like the following:
Code:
# Modify this if dtk files are on modified dtk CD.
# the mount command will be....
# mount /dev/cdroms/cdrom0 /opt/dell/toolkit/systems/
label cdrom
    kernel SA.1
    append initrd=SA.2 ramdisk_size=156482  Stage3_type=cdrom DEBUG=0 quiet share_type=cdrom share_script=setbootfloppy.sh selinux=0
This is all well and good. The problem is that there's an easy to fix but major bug in /bin/start-stage3.sh in the initrd (isolinux/SA.2 in the CD) and it's not successfully running the script properly. I've attached the bug here, and I'm able to fix it. THE PROBLEM is that I need to edit the file SA.2, then save those changes back and I can't seem to get the initramfs to work when I makes those changes.

I tried the stuff at the top of the story in an attempt to make the change to the initrd and that's why I'm getting the init error also at the top of the story.

Kernel panic - not syncing: No init found. Try passing init= option to kernel.

The reason I even mention the long version of this story is to ask whether I should even be doing this? The LiveCD also has the RPMs for the tools that I need so if I could make a LiveCD via some other method and incorporate those tools would that be better? If so, which would be the easiest method to apply to try to do that?
 
Old 09-12-2011, 02:33 AM   #2
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655
I think the problem may be that iso9660 is a read only file system, so saving the new initrd file may be failing. After mounting the image, you may need to copy the contents to a directory, and use that directory to build a new iso image, after replacing the init file. Also, don't change the name of the initrd file. The menu.lst file contains the name of the file.
 
Old 09-12-2011, 11:09 AM   #3
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 1,610

Rep: Reputation: 674Reputation: 674Reputation: 674Reputation: 674Reputation: 674Reputation: 674
You should omit the "-depth" option in your "find" command. See filesystems/ramfs-rootfs-initramfs.txt in your kernel documentation, to wit:
Quote:
Note: The cpio man page contains some bad advice that will break your initramfs archive if you follow it. It says "A typical way to generate the list of filenames is with the find command; you should give find the -depth option to minimize problems with permissions on directories that are unwritable or not searchable." Don't do this when creating initramfs.cpio.gz images, it won't work. The Linux kernel cpio extractor won't create files in a directory that doesn't exist, so the directory entries must go before the files that go in those directories.
 
1 members found this post helpful.
Old 09-12-2011, 06:36 PM   #4
launchpadtt
Member
 
Registered: May 2005
Location: Brooklyn, originally from Trinidad and Tobago
Distribution: (Ku, Xu, U)buntu
Posts: 30

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by rknichols View Post
You should omit the "-depth" option in your "find" command. See filesystems/ramfs-rootfs-initramfs.txt in your kernel documentation, to wit:
That was the problem. I tried it without -depth and it worked. Thanks!
 
  


Reply

Tags
cpio, dell, initramfs, initrd


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
initrd vs. initramfs rrlangly Gentoo 1 05-24-2010 10:05 AM
Initramfs vs Initrd Potatos Linux - Kernel 1 05-03-2010 06:13 AM
Making a livecd without initrd or initramfs unitedroad Linux - General 3 01-14-2008 03:40 AM
Confusion PLEASE HELP!!!! Initrd + initramfs aroche Linux - General 2 08-18-2006 02:59 PM
difference between initrd and initramfs shrndegruv Linux - General 1 02-14-2006 01:03 AM


All times are GMT -5. The time now is 11:20 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration