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.
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.
How to ?
get a sample redhat initramfs
cp /boot/initramfs-2.6.32-220.el6.x86_64.img initramfs.img
what have we got ?
gunzip it
gunzip < initramfs.img > initramfs.stage1
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 ?
now, compress it.
gzip -9 < ../newinitram.stage2 > newinitrd.stage3
now, booting your kernel should be easy.