使用mkbootfs制作ramdisk根文件系统
span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }.cm-searching {background: #ffa; background: rgba(255, 255, 0, .4);}.cm-force-border { padding-right: .1px; }@media print { .CodeMirror div.CodeMirror-cursors {visibility: hidden;}}.cm-tab-wrap-hack:after { content: ""; }span.CodeMirror-selectedtext { background: none; }.CodeMirror-activeline-background, .CodeMirror-selected {transition: visibility 0ms 100ms;}.CodeMirror-blur .CodeMirror-activeline-background, .CodeMirror-blur .CodeMirror-selected {visibility:hidden;}.CodeMirror-blur .CodeMirror-matchingbracket {color:inherit !important;outline:none !important;text-decoration:none !important;}.CodeMirror-sizer {min-height:auto !important;}
-->
li {list-style-type:decimal;}.wiz-editor-body ol.wiz-list-level2 > li {list-style-type:lower-latin;}.wiz-editor-body ol.wiz-list-level3 > li {list-style-type:lower-roman;}.wiz-editor-body blockquote {padding: 0 12px;}.wiz-editor-body blockquote > :first-child {margin-top:0;}.wiz-editor-body blockquote > :last-child {margin-bottom:0;}.wiz-editor-body img {border:0;max-width:100%;height:auto !important;margin:2px 0;}.wiz-editor-body table {border-collapse:collapse;border:1px solid #bbbbbb;}.wiz-editor-body td,.wiz-editor-body th {padding:4px 8px;border-collapse:collapse;border:1px solid #bbbbbb;min-height:28px;word-break:break-word;box-sizing: border-box;}.wiz-hide {display:none !important;}
-->
环境
概述
/* NOTES
**
** - see buffer-format.txt from the linux kernel docs for
** an explanation of this file format
** - dotfiles are ignored
** - directories named 'root' are ignored
** - device notes, pipes, etc are not supported (error)
*/
上面的信息说明了如下几点:
The full format of the initramfs buffer is defined by the following
grammar, where:
* is used to indicate "0 or more occurrences of"
(|) indicates alternatives
+ indicates concatenation
GZIP() indicates the gzip() of the operand
ALGN(n) means padding with null bytes to an n-byte boundary initramfs := ("\0" | cpio_archive | cpio_gzip_archive)* cpio_gzip_archive := GZIP(cpio_archive) cpio_archive := cpio_file* + (<nothing> | cpio_trailer) cpio_file := ALGN() + cpio_header + filename + "\0" + ALGN() + data cpio_trailer := ALGN() + cpio_header + "TRAILER!!!\0" + ALGN()
2. 名为"."的文件会被忽略,不会进行打包。
用法
lib_path=`readlink -f ./lib`
bin_path=`readlink -f ./bin/` export LD_LIBRARY_PATH=${lib_path}:$LD_LIBRARY_PATH
export PATH=${bin_path}:$PATH rm -f ramdisk.img ramdisk.cpio
rm -rf ./tmp/ # pack
pushd rootfs2
mkbootfs -f ../config.txt . | minigzip > ../ramdisk.img
mkbootfs -f ../config.txt . > ../ramdisk.cpio
popd # unpack
mkdir -p tmp
pushd tmp
cpio -i < ../ramdisk.cpio
popd
其中config.txt是一个配置文件,内容如下:
etc/init.d/rcS
第1行,把"etc/init.d/rcS"文件的uid设置为0,gid设置为0,权限设置为0755
/* Rules for directories.
** These rules are applied based on "first match", so they
** should start with the most specific path and work their
** way up to the root.
*/ static const struct fs_path_config android_dirs[] = {
{ , AID_SYSTEM, AID_CACHE, , "cache" },
{ , AID_ROOT, AID_ROOT, , "config" },
{ , AID_SYSTEM, AID_SYSTEM, , "data/app" },
{ , AID_SYSTEM, AID_SYSTEM, , "data/app-private" },
{ , AID_SYSTEM, AID_SYSTEM, , "data/app-ephemeral" },
{ , AID_ROOT, AID_ROOT, , "data/dalvik-cache" },
{ , AID_SYSTEM, AID_SYSTEM, , "data/data" },
{ , AID_SHELL, AID_SHELL, , "data/local/tmp" },
{ , AID_SHELL, AID_SHELL, , "data/local" },
{ , AID_SYSTEM, AID_MISC, , "data/misc" },
{ , AID_DHCP, AID_DHCP, , "data/misc/dhcp" },
{ , AID_SHARED_RELRO, AID_SHARED_RELRO, , "data/misc/shared_relro" },
{ , AID_MEDIA_RW, AID_MEDIA_RW, , "data/media" },
{ , AID_MEDIA_RW, AID_MEDIA_RW, , "data/media/Music" },
{ , AID_ROOT, AID_SHELL, , "data/nativetest" },
{ , AID_ROOT, AID_SHELL, , "data/nativetest64" },
... ...
针对其他文件的规则:
static const struct fs_path_config android_files[] = {
{ , AID_ROOT, AID_SHELL, , "system/etc/init.goldfish.rc" },
{ , AID_ROOT, AID_SHELL, , "system/etc/init.goldfish.sh" },
{ , AID_ROOT, AID_SHELL, , "system/etc/init.ril" },
{ , AID_ROOT, AID_ROOT, , "system/etc/ppp/*" },
{ , AID_ROOT, AID_ROOT, , "system/etc/rc.*" },
{ , AID_ROOT, AID_ROOT, , "system/etc/recovery.img" },
{ , AID_ROOT, AID_ROOT, , conf_dir + },
{ , AID_ROOT, AID_ROOT, , conf_file + },
{ , AID_SYSTEM, AID_SYSTEM, , "data/app/*" },
{ , AID_MEDIA_RW, AID_MEDIA_RW, , "data/media/*" },
{ , AID_SYSTEM, AID_SYSTEM, , "data/app-private/*" },
{ , AID_SYSTEM, AID_SYSTEM, , "data/app-ephemeral/*" },
{ , AID_APP, AID_APP, , "data/data/*" },
{ , AID_ROOT, AID_SHELL, , "data/nativetest/tests.txt" },
{ , AID_ROOT, AID_SHELL, , "data/nativetest64/tests.txt" },
... ...
验证
kernel_dir=./Linux-4.14.
kernel_image=${kernel_dir}/arch/arm/boot/zImage
dtb_image=${kernel_dir}/arch/arm/boot/dts/vexpress-v2p-ca9.dtb
qemu_path=/home/pengdonglin/disk_ext/Qemu/qemu-3.1./build/install/bin ${qemu_path}/qemu-system-arm \
-M vexpress-a9 \
-m 1024M \
-smp \
-kernel ${kernel_image} \
-nographic \
-append "root=/dev/ram0 rw rootfstype=ramfs console=ttyAMA0 init=/init ignore_loglevel" \
-initrd ./rootfs/ramdisk.img \
-dtb ${dtb_image}
[ 0.609270] Trying to unpack rootfs image as initramfs...
[ 0.965940] Freeing initrd memory: 3616K
kernel_dir=./Linux-4.14.
kernel_image=${kernel_dir}/arch/arm/boot/zImage
dtb_image=${kernel_dir}/arch/arm/boot/dts/vexpress-v2p-ca9.dtb
qemu_path=/home/pengdonglin/disk_ext/Qemu/qemu-3.1./build/install/bin ${qemu_path}/qemu-system-arm \
-M vexpress-a9 \
-m 1024M \
-smp \
-kernel ${kernel_image} \
-nographic \
-append "root=/dev/ram0 rw rootfstype=ramfs console=ttyAMA0 init=/init ignore_loglevel" \
-initrd ./rootfs/ramdisk.cpio \
-dtb ${dtb_image}
[ 0.610055] Trying to unpack rootfs image as initramfs...
[ 0.760468] Freeing initrd memory: 7040K
GEN usr/initramfs_data.cpio.gz
GZIP kernel/config_data.gz
CHK kernel/config_data.h
UPD kernel/config_data.h
CC kernel/configs.o
AR kernel/built-in.o
AS usr/initramfs_data.o
AR usr/built-in.o
/bin/bash ./scripts/gen_initramfs_list.sh -o usr/initramfs_data.cpio.gz -u -g /home/pengdonglin/disk_ext/Qemu/aarch32/rootfs/rootfs
kernel_dir=./Linux-4.14.
kernel_image=${kernel_dir}/arch/arm/boot/zImage
dtb_image=${kernel_dir}/arch/arm/boot/dts/vexpress-v2p-ca9.dtb
qemu_path=/home/pengdonglin/disk_ext/Qemu/qemu-3.1./build/install/bin ${qemu_path}/qemu-system-arm \
-M vexpress-a9 \
-m 1024M \
-smp \
-kernel ${kernel_image} \
-nographic \
-append "root=/dev/ram0 rw rootfstype=ramfs console=ttyAMA0 init=/init ignore_loglevel" \
-dtb ${dtb_image}
#!/bin/sh # Copyright Rob Landley <rob@landley.net> and TimeSys Corporation.
# Licensed under GPL version if [ $# -ne ]
then
echo "usage: mkinitramfs directory imagename.cpio.gz"
exit
fi if [ -d "$1" ]
then
echo "creating $2 from $1"
(cd "$1"; find . | cpio -o -H newc | gzip) > "$2"
else
echo "First argument must be a directory"
exit
fi
使用mkbootfs制作ramdisk根文件系统的更多相关文章
- Ramdisk根文件系统映像的修改与创建
本文简述Ramdisk根文件系统映像的修改以及创建,并附相关脚本以实现自动化配置,而根文件系统的制作过程请网上自行搜索.相关过程尽可能以图的方式展示出来,重在说明操作的过程,仅供参考. Ramdisk ...
- 使用BusyBox制作linux根文件系统(CramFS+mdev)
转:http://www.360doc.com/content/10/0428/11/496343_25245348.shtml 操作系统:Ubuntu9.04 内核版本:linux-2.6.24.7 ...
- 嵌入式linux内核制作、根文件系统制作
嵌入式系统构成: 主要由bootloader.kernel.以及根文件系统三部分组成. 内核制作步骤: 制作嵌入式平台使用的linux内核制作方法与pc平台上的linux内核基本一致 1.清除原有配置 ...
- 制作linux根文件系统
转载地址:http://wenku.baidu.com/view/2cb1b4707fd5360cba1adb14.html 2011十一月 24 转 嵌入式根文件系统制作 (3985) (0) 转自 ...
- 使用BusyBox制作Linux根文件系统
STEP 1:构建目录结构 创建根文件系统目录,主要包括以下目录/dev /etc /lib /usr /var /proc /tmp /home /root /mnt /bin /sbin ...
- 制作ramdisk-u.img根文件系统
具体步骤如下:1.解压内核源码树解压linux-2.6.29-mini2440-20090708.tgz到自己的工作目录,会生成一个友善之臂修改过的并且有几个mini2440默认配置文件的内核源码目录 ...
- 从ramdisk根文件系统启动Linux成功,及使用initramfs启动linux
下面两篇文章是ARM9论坛上的讲解ramdisk文件系统的很不错的文章 今天做了个试验,让Linux2.6.29.4从ramdisk根文件系统启动成功,总结一下. 其中涉及的内容较多,很多东西不再详述 ...
- 从ramdisk根文件系统启动Linux 二
今天做了个试验,让Linux2.6.29.4从ramdisk根文件系统启动成功,总结一下.其中涉及的内容较多,很多东西不再详述,如需深入研究请查阅相关资料(百度或谷歌一下一大堆). 开发环境:Fedo ...
- 从ramdisk根文件系统启动Linux成功
这几天参考国嵌的实验手册和网上的资料完成了u-boot定制.内核定制.ramdisk根文件系统的制作,并成功.趁热打铁,总结一下.本文引用了很多网络上的文章,就不一一注明了.感谢各大侠的帮助,如有雷同 ...
随机推荐
- 【Android】ScaleAnimation 详解
ScaleAnimation类是Android系统中的尺寸变化动画类,用于控制View对象的尺寸变化,该类继承于Animation类.ScaleAnimation类中的很多方法都与Animation类 ...
- 关于SQL Server中的系统表之一 sysobjects
微软Sql Server数据库是企业开发管理中最常用的数据库系统之一.其功能强大而且使用简单.方便.我们在数据库中创建数据库.表.视图.触发器.存储过程.函数等信息. 最常用的功能之一,查询数据,例如 ...
- BZOJ3583 杰杰的女性朋友 矩阵
原文链接https://www.cnblogs.com/zhouzhendong/p/BZOJ3583.html 题目传送门 - BZOJ3583 题意 有一个 $n$ 个点构成的有向图. 对于每一个 ...
- Codeforces 264C Choosing Balls 动态规划
原文链接https://www.cnblogs.com/zhouzhendong/p/CF264C.html 题目传送门 - CF264C 题意 给定一个有 $n$ 个元素的序列,序列的每一个元素是个 ...
- OpenSSL-Win64创建IdentityServer证书
d:cd xx C:\OpenSSL-Win64\bin\openssl req -newkey rsa:2048 -nodes -keyout identity.key -x509 -days 36 ...
- 20165235 2018-3 《Java程序设计》第5周学习总结
20165235 2018-3 <Java程序设计>第5周学习总结 教材学习内容总结 第六章 内部类与异常类 (一)内部类:1.java支持在一个类中定义另一个类,这个类叫内部类.2.内部 ...
- [dotnet core]使用Peach简化Socket网络通讯协议开发
Peach是基于DotNetty的Socket网络通讯帮助类库,可以帮助开发者简化使用DotNetty,关于DotNetty可参考我之前的这篇文章. Peach内置实现了一个基于文本协议的Comman ...
- 大数据技术 - 分布式文件系统 HDFS 的设计
本章内容介绍下 Hadoop 自带的分布式文件系统,HDFS 即 Hadoop Distributed Filesystem.HDFS 能够存储超大文件,可以部署在廉价的服务器上,适合一次写入多次读取 ...
- asp.net core 依赖注入实现全过程粗略剖析(1)
转载请注明出处: https://home.cnblogs.com/u/zhiyong-ITNote/ 常用扩展方法 注入依赖服务: new ServiceCollection().AddSingle ...
- 杭电1024----Max Sum Plus Plus
/* 这题还没有理解透彻.某个dalao也不写注释.只能自己理解了... 先求为i个元素(1<=i<=M)为一个区间的最大和,保证元素个数大于等于i个,递推到M个即可 借鉴原址:http: ...