您的位置:首页 > 其它

修改ramdisk文件总结

2015-08-18 21:59 323 查看

简介

本文总结如何对已有的RAMDISK文件进行修改。

配置步骤

用户可以在任一Linux发布版本中操作下列步骤,但要求有root权限:

创建文件夹rootfs
将initrd.img拷贝到rootfs目录下
重命名initrd.img为initrd.cpio.gz
使用gunzip解压initrd.cpio.gz文件,解压后的文件名为initrd.cpio
使用su命令登录root账户
使用"cpio -idv < initrd.cpio"解压
删除initrd.cpio临时文件
根据需要对解压后的文件进行修改
在root用户下,进入rootfs的根目录,使用"find . | cpio -H newc -o | gzip -9 > ../initrd.img"命令重新打包ramdisk文件,将在rootfs的上级目录生成新的initrd.img文件
注:具体解压的方式与文件的格式(--format)有关,可能与此处示例不同。

命令解析

cpio是用来建立、还原备份档的工具程序,它可以加入、解开cpio或tar备份档内的文件。其常用选项如下:

-o :将数据copy到文件或设备上
-i :将数据从文件或设备上还原到系统中
-t :查看cpio建立的文件或设备内容
-c :一种比较新的portableformat方式存储
-v :在屏幕上显示备份过程中的文件名
-B :让预设的blocks可以增加到5120bytes,默认是512bytes,这样可以使备份速度加快
-d :自动建立目录,这样还原时才不会出现找不到路径的问题
-u :更新,用较新的文件覆盖旧的文件
-H : 指定文件格式
cpio支持的文件格式如下:
-H, --format=format
Use archive format format. The valid formats are listed below with file size limits for individual files in parentheses; the same names are also recognized in all-caps. The default in copy-in mode is to automatically detect the archive format, and in copy-out mode is‘bin’.
‘bin’
The obsolete binary format. (2147483647 bytes)
‘odc’
The old (POSIX.1) portable format. (8589934591 bytes)
‘newc’
The new (SVR4) portable format, which supports file systems having more than 65536 i-nodes. (4294967295 bytes)
‘crc’
The new (SVR4) portable format with a checksum added.
‘tar’
The old tar format. (8589934591 bytes)
‘ustar’
The POSIX.1 tar format. Also recognizes GNU tar archives, which aresimilar but not identical. (8589934591 bytes)
‘hpbin’
The obsolete binary format used by HPUX's cpio (which stores devicefiles differently).
‘hpodc’
The portable format used by HPUX's cpio (which stores device files differently).
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: