How to modify the initrd.img file?

2011-12-28  李琪 

It is based on Linux 2.6 kernel, not for Linux 2.4 kernel.
[root@rhel55build qli]# ll -lh
total 34M
-r--r--r-- 1 root root  34M Dec 29 13:44 initrd-rhel-6.1-x86_64.img
drwxr-xr-x 2 root root 4.0K Dec 29 14:46 tmp
[root@rhel55build qli]# cd tmp
[root@rhel55build tmp]# zcat ../initrd-rhel-6.1-x86_64.img |cpio -div
cpio: .buildstamp not created: newer or same age version exists
cpio: .profile not created: newer or same age version exists
cpio: .bash_history not created: newer or same age version exists
128206 blocks
[root@rhel55build tmp]# ls
bin  dev  etc  firmware  init  lib  lib64  modules  proc  sbin  selinux  sys  tmp  usr  var
[root@rhel55build tmp]# touch -r *
[root@rhel55build tmp]# ll
total 52
lrwxrwxrwx  1 root root    4 Dec 29 14:47 bin -> sbin
drwxr-xr-x  2 root root 4096 Dec 29 14:47 dev
drwxr-xr-x 16 root root 4096 Dec 29 14:47 etc
drwxr-xr-x 21 root root 4096 Dec 29 14:47 firmware
lrwxrwxrwx  1 root root   10 Dec 29 14:47 init -> /sbin/init
drwxr-xr-x  3 root root 4096 Dec 29 14:47 lib
drwxr-xr-x  5 root root 4096 Dec 29 14:47 lib64
drwxr-xr-x  3 root root 4096 Dec 29 14:47 modules
drwxr-xr-x  2 root root 4096 Dec 29 14:47 proc
drwxr-xr-x  2 root root 4096 Dec 29 14:47 sbin
drwxr-xr-x  2 root root 4096 Dec 29 14:47 selinux
drwxr-xr-x  2 root root 4096 Dec 29 14:47 sys
drwxr-xr-x  2 root root 4096 Dec 29 14:47 tmp
drwxr-xr-x  8 root root 4096 Dec 29 14:47 usr
drwxr-xr-x  7 root root 4096 Dec 29 14:47 var
[root@rhel55build tmp]# touch qli
[root@rhel55build tmp]# find . |cpio -o -H newc |gzip -v9 > ../initrd-qli.img
128206 blocks
 46.0%
[root@rhel55build tmp]# ls
bin  etc       init  lib64    proc  sbin     sys  usr
dev  firmware  lib   modules  qli   selinux  tmp  var
[root@rhel55build tmp]# cd ..
[root@rhel55build qli]# ls
initrd-qli.img  initrd-rhel-6.1-x86_64.img  tmp
[root@rhel55build qli]# ll -lh
total 68M
-rw-r--r--  1 root root  34M Dec 29 14:49 initrd-qli.img
-r--r--r--  1 root root  34M Dec 29 13:44 initrd-rhel-6.1-x86_64.img
drwxr-xr-x 15 root root 4.0K Dec 29 14:48 tmp
[root@rhel55build qli]# file initrd-qli.img
initrd-qli.img: gzip compressed data, from Unix, last modified: Thu Dec 29 14:48:56 2011,                                                      max compression
[root@rhel55build qli]# chmod 444 initrd-qli.img
[root@rhel55build qli]# ll -lh
total 68M
-r--r--r--  1 root root  34M Dec 29 14:49 initrd-qli.img
-r--r--r--  1 root root  34M Dec 29 13:44 initrd-rhel-6.1-x86_64.img
drwxr-xr-x 15 root root 4.0K Dec 29 14:48 tmp
[root@rhel55build qli]# mkdir tmp1
[root@rhel55build qli]# cd tmp1
[root@rhel55build tmp1]# zcat ../initrd-qli.img |cpio -div
128206 blocks
[root@rhel55build tmp1]# ls
bin  etc       init  lib64    proc  sbin     sys  usr
dev  firmware  lib   modules  qli   selinux  tmp  var
[root@rhel55build tmp1]#
462°/4628 人阅读/0 条评论 发表评论

登录 后发表评论