cpio打包和压包的方法示例

如何解压和生成initrd.gz 或 initrd.img总结:


<一>如何解压或是打包mini-rootfs-arm64.cpio.gz?如何解压或是打包mini-rootfs-arm64.cpio.gz?
参考:http://blog.csdn.net/u011774239/article/details/51720817

这种类型的包,是通过cpio和gzip这两步压包获得的,所以解压也需要经过这两步。


一:解压
yaolan@ubuntu3:~/fs/test$ ls
test.cpio.gz

yaolan@ubuntu3:~/fs/test$ gunzip test.cpio.gz
yaolan@ubuntu3:~/fs/test$ ls
test.cpio

yaolan@ubuntu3:~/fs/test$ cpio -idmv < test.cpio
.
root
var

.................

boot
116753 blocks

test@ubuntu3:~/fs/test$ ls
bin   dev  home  lib      mnt  proc  run   share  test.cpio  usr
boot  etc  init  linuxrc  opt  root  sbin  sys    tmp        var


二:压包
test@ubuntu3:~/fs/test$ ls
bin   dev  home  lib      mnt  proc  run   share  tmp  var
boot  etc  init  linuxrc  opt  root  sbin  sys    usr

test@ubuntu3:~/fs/test$ find ./* | cpio -H newc -o > test.cpio (或者 find ./* | cpio -H tar -o > test.cpio)
116753 blocks

test@ubuntu3:~/fs/test$ ls
bin   dev  home  lib      mnt  proc  run   share  test.cpio  usr
boot  etc  init  linuxrc  opt  root  sbin  sys    tmp        var

test@ubuntu3:~/fs/test$ gzip test.cpio
test@ubuntu3:~/fs/test$ ls
bin   dev  home  lib      mnt  proc  run   share  test.cpio.gz  usr
boot  etc  init  linuxrc  opt  root  sbin  sys    tmp           var

便以可以获取test.cpio.gz.

对于centos用的initrd.img 

现在可以用  xzcat initrd.img | cpio -d -i -m 直接将initrd包导出(旧版本的除外)

压包方式:find . | cpio -o -H newc | xz --check=crc32 --lzma2=dict=512KiB > ../initrd.img

其他资料还有:http://dreamfromars.blog.sohu.com/219542655.html

  • 2
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值