0

I have written a customized shell script(command) ,which i want to put in initrd /bin and then, i want it to be copied to Linux OS /opt/xyz directory .Where xyz is customized directory created during installation.

How can i achieve this task.

0

How to ?

get a sample redhat initramfs

cp /boot/initramfs-2.6.32-220.el6.x86_64.img initramfs.img

what have we got ?

  • initramfs.img: gzip compressed data, from Unix, last modified: Thu Oct 22 07:04:25 2015, max compression

gunzip it

gunzip < initramfs.img > initramfs.stage1
  • initramfs.stage1: ASCII cpio archive (SVR4 with no CRC)

extract it

cpio -icv < initramfs.stage1
(lots of line)
usr/sbin
usr/sbin/eject
usr/sbin/chroot
96258 blocks

add my stuff

mkdir opt/xyz
date > opt/xyz/foo.txt

no leading / !!

remake the cpio (I delete initramfs.* files)

find . -type f -print | cpio -ocv > ../newinitram.stage2
(lots of lines)
./usr/bin/mkfifo
./usr/sbin/eject
./usr/sbin/chroot
96186 blocks

what have we got ?

  • ../newinitram.stage2: ASCII cpio archive (SVR4 with no CRC)

now, compress it.

gzip -9 < ../newinitram.stage2 > newinitrd.stage3
  • newinitrd.stage3: gzip compressed data, from Unix, last modified: Sat Dec 19 06:32:08 2015, max compression

now, booting your kernel should be easy.

| improve this answer | |
  • Thanks.So, if i have iso image ,then how can i extract initrd and again compress it and put it back to iso .So,that during installation my changes will be effective. – Gaurav KS Dec 20 '15 at 8:12
  • 0 - Given that you want to edit initrd, I thought you know how to build a iso file/disk, however you are not intending to put a whole application in initrd ? 1- I don't have my iso building scripts at hand, I'll be replying tomorrow. 2- If you feel this question as helpfull you might gav point. – Archemar Dec 20 '15 at 9:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.