使用#file system.img
输出:system.img: Linux rev 0.0 ext2 filesystem data,
UUID=4eb0489c-647d-49d8-9111-94657b5fd342, volume name
"system"。
然而本人使用命令#mkyaffs2image system/ system.img,
再使用#file system.img,却输出:system.img: VMS Alpha executable
前一个system.img文件时可用的,而使用mkyaffs2image命令生成的system.img却不能使用(将ramdisk.img,system.img,install.img等打包成iso文件,用virtualbox运行)。
谁 清楚android编译系统是用什么命令生成system.img的?本人使用#make
systemimage命令,只显示出如下信息: Install system fs image:
out/target/product/eeepc/system.img
out/host/linux-x86/bin/acp -fpt
out/target/product/eeepc/obj/PACKAGING /systemimage_unopt_intermediates/system.img
out/target/product/eeepc/system.img
true
没能查到是哪个脚本生成的system.img
根据这个网址
... /03/04/3957749.aspx,
1.执行#make showcommands snod
2.得出android制作system.img命令为:
#!/bin/bash
export PATH="/home/tony/tmp/e2fsprogs-1.41.3/prefix/sbin:$PATH"
num_blocks=`du -sk out/target/product/eeepc/system | tail -n1 |
awk '{print $1;}'`
if [ $num_blocks -lt 20480 ]; then
extra_blocks=3072;
else
extra_blocks=20480;
fi
num_blocks=`expr $num_blocks + $extra_blocks`
num_inodes=`find out/target/product/eeepc/system | wc -l`
num_inodes=`expr $num_inodes + 500`
out/host/linux-x86/bin/genext2fs -a -d
out/target/product/eeepc/system -b $num_blocks -N $num_inodes -m 0
out/target/product/eeepc/system.img
tune2fs -L system out/target/product/eeepc/system.img
tune2fs -C 1 out/target/product/eeepc/system.img
e2fsck -fy out/target/product/eeepc/system.img
一.android2.3系统的generic文件系统生成命令:
out/host/linux-x86/bin/mkyaffs2image -f out/target/product/generic/system out/target/product/generic/obj/PACKAGING/systemimage_intermediates/system.img
chmod a+r
out/target/product/generic/obj/PACKAGING/systemimage_intermediates/system.img
Install system fs image:
out/target/product/generic/system.img
out/host/linux-x86/bin/acp -fpt
out/target/product/generic/obj/PACKAGING/systemimage_intermediates/system.img
out/target/product/generic/system.img
true
out/host/linux-x86/bin/mkbootfs
out/target/product/generic/root | out/host/linux-x86/bin/minigzip
> out/target/product/generic/ramdisk.img
out/host/linux-x86/bin/mkyaffs2image -f out/target/product/generic/data
out/target/product/generic/userdata.img
chmod a+r
out/target/product/generic/userdata.imgtrue
二.android2.2系统的MID文件系统生成命令:
file out/target/product/mid/system.img
out/target/product/mid/system.img: u-boot legacy uImage, Android,
Linux/ARM, Filesystem Image (any type) (Not compressed), 143233024
bytes, Tue Nov 22 10:48:07 2011, Load Address: 0x40008000, Entry
Point: 0x40008000, Header CRC: 0x6D462E1C, Data CRC: 0xE1876EFF
file sys.img
sys.img: Linux rev 1.0 ext3 filesystem data,
UUID=2c363e3e-f731-4800-9553-a0613a1264eb, volume name "system
dd if=system.img of=sys.img bs=64 skip=1
sudo mount -t ext3 -o loop sys.img mnt
修改
sudo umount mnt
./rcmkimage sys.img system.img(./mkimage -A arm -O linux -C none
-T filesystem -a 1 -e 1 -n "system.img" -d $1 $2)
make showcommands
Target system fs image:
out/target/product/mid/obj/PACKAGING/systemimage_unopt_intermediates/system.img
Target system fs image: ext2image
out/target/product/mid/system/framework
if [ -f
out/target/product/mid/system/framework/framework-res-TG.apk ];
then mv
out/target/product/mid/system/framework/framework-res-TG.apk
out/target/product/mid/system/framework/framework-res.apk; fi
num_blocks=`du -sk out/target/product/mid/system | tail -n1 | awk
'{print $1;}'`; if [ $num_blocks -lt 20480 ]; then
extra_blocks=3072; else extra_blocks=20480; fi ; num_blocks=`expr
$num_blocks + $extra_blocks` ; num_inodes=`find
out/target/product/mid/system | wc -l` ; num_inodes=`expr
$num_inodes + 500`;
out/host/linux-x86/bin/genext2fs -a
-d out/target/product/mid/system -b $num_blocks -N $num_inodes -m 0
out/target/product/mid/obj/PACKAGING/systemimage_unopt_intermediates/system.img
tune2fs -L system
out/target/product/mid/obj/PACKAGING/systemimage_unopt_intermediates/system.img
tune2fs 1.41.14 (22-Dec-2010)
tune2fs -C 1
out/target/product/mid/obj/PACKAGING/systemimage_unopt_intermediates/system.img
tune2fs 1.41.14 (22-Dec-2010)
Setting current mount count to 1
e2fsck -fy
out/target/product/mid/obj/PACKAGING/systemimage_unopt_intermediates/system.img
; [ $? -lt 4 ]e2fsck 1.41.14
(22-Dec-2010)
文件系统 did not have a UUID; generating one.
第一步: 检查inode,块,和大小
第二步: 检查目录结构
第3步: 检查目录连接性
/lost+found未找到.创建? 是
Pass 4: Checking reference counts
第5步: 检查簇概要信息
system: ***** 文件系统已修改 *****
system: 648/1152 files (1.7% non-contiguous), 119292/139876
blocks
Install system fs image: out/target/product/mid/system.img
out/host/linux-x86/bin/acp -fpt
out/target/product/mid/obj/PACKAGING/systemimage_unopt_intermediates/system.img
out/target/product/mid/system.img
true
Generate system.img for iNAND
mv out/target/product/mid/system.img
out/target/product/mid/system.img.ext3
tune2fs -j
out/target/product/mid/system.img.ext3
tune2fs 1.41.14 (22-Dec-2010)
Creating journal inode: 完成
This filesystem will be automatically checked every 20 mounts
or
0 days, whichever comes first. Use tune2fs -c or
-i to override.
out/host/linux-x86/bin/mkimage -A arm
-O linux -T filesystem -C
none \
-a 40008000 -n "Android" -d out/target/product/mid/system.img.ext3
out/target/product/mid/system.imgImage
Name: Android
Created: Tue Nov 22 11:05:21 2011
Image Type: ARM Linux
Filesystem Image (uncompressed)
Data Size: 143233024 Bytes = 139876.00 kB = 136.60 MB
Load Address: 40008000
Entry Point: 40008000
gzip -9
out/target/product/mid/system.img.ext3
out/host/linux-x86/bin/mkimage -A arm
-O linux -T filesystem -C
none \
-a 40008000 -n "zAndroid" -d
out/target/product/mid/system.img.ext3.gz
out/target/product/mid/zSYS.img
Image Name: zAndroid
Created: Tue Nov 22 11:05:34 2011
Image Type: ARM Linux
Filesystem Image (uncompressed)
Data Size: 80767125 Bytes = 78874.15 kB = 77.03 MB
Load Address: 40008000
Entry Point: 40008000
rm -f out/target/product/mid/system.img.ext3.gz
out/host/linux-x86/bin/mkbootfs out/target/product/mid/root |
out/host/linux-x86/bin/minigzip >
out/target/product/mid/ramdisk.img
mv out/target/product/mid/ramdisk.img
out/target/product/mid/ramdisk.img.ori
out/host/linux-x86/bin/mkimage -A arm -O linux -T ramdisk \
-C none -a 0x41000000 -n "hRamdisk" -d
out/target/product/mid/ramdisk.img.ori
out/target/product/mid/ramdisk.img
Image Name: hRamdisk
Created: Tue Nov 22 11:05:35 2011
Image Type: ARM Linux RAMDisk
Image (uncompressed)
Data Size: 170001 Bytes = 166.02 kB = 0.16 MB
Load Address: 41000000
Entry Point: 41000000
Installed file list:
out/target/product/mid/installed-files.txt
build/tools/fileslist.py out/target/product/mid/system
out/target/product/mid/data >
out/target/product/mid/installed-files.txt
三.相关命令使用说明:
genext2fs:
out/host/linux-x86/bin/genext2fs --help
Usage: out/host/linux-x86/bin/genext2fs [options] image
Create an ext2 filesystem image from directories/files
-x, --starting-image
-d, --root
-D, --devtable
-b, --size-in-blocks
-i, --bytes-per-inode
-N, --number-of-inodes
-m, --reserved-percentage
-g, --block-map
Generate a block map file for this path.
-e, --fill-value
Fill unallocated blocks with
value.
-z,
--allow-holes Allow files with holes.
-f,
--faketime Set filesystem timestamps to 0 (for testing).
-q,
--squash Same as "-U -P".
-U,
--squash-uids Squash owners making all files be owned by root.
-P,
--squash-perms Squash permissions on all files.
-a,
--fix-android-stats Fix-up file stats (user, perms, ...)
-h, --help
-V, --version
-v, --verbose
tune2fs :
tune2fs
tune2fs 1.41.14 (22-Dec-2010)
Usage: tune2fs [-c max_mounts_count] [-e errors_behavior] [-g
group]
[-i interval[d|m|w]] [-j] [-J journal_options] [-l]
[-m reserved_blocks_percent] [-o [^]mount_options[,...]]
[-r reserved_blocks_count] [-u user] [-C mount_count] [-L
volume_label]
[-M last_mounted_dir] [-O [^]feature[,...]]
[-E extended-option[,...]] [-T last_check_time] [-U UUID]
[ -I new_inode_size ] device
一.简介:
调整/查看ext2/ext3文件系统的文件系统参数,Windows下面如果出现意外断电死机情况,下次开机一般都会出现系统自检。Linux系统下面也有文件系统自检,而且是可以通过tune2fs命令,自行定义自检周期及方式。
二.用法:
tune2fs [ -l ] [ -c max-mount-counts ] [ -e errors-behavior ] [
-f ] [ -i interval-between-checks ] [ -j ] [ -J journal-options ] [
-m
reserved-blocks-percentage ] [ -o [^]mount-options[,...] ] [ -r
reserved-blocks-count ] [ -s sparse-super-flag ] [ -u user ] [
-g
group ] [ -C mount-count ] [ -L volume-name ] [ -M
last-mounted-directory ] [ -O [^]feature[,...] ] [ -T
time-last-checked ] [ -U
UUID ] device
常用选项说明:
-l 查看文件系统信息
-c max-mount-counts 设置强制自检的挂载次数,如果开启,每挂载一次mount
conut就会加1,超过次数就会强制自检
-i interval-between-checks[d|m|w] 设置强制自检的时间间隔[d天m月w周]
-m reserved-blocks-percentage 保留块的百分比
-j 将ext2文件系统转换为ext3类型的文件系统
-L volume-label 类似e2label的功能,可以修改文件系统的标签
-r reserved-blocks-count 调整系统保留空间
-o [^]mount-option[,...] Set or clear the indicated default mount
options in the filesystem. 设置或清除默认挂载的文件系统选项
三.示例:
tune2fs -c 30 /dev/hda1 设置强制检查前文件系统可以挂载的次数
tune2fs -c -l /dev/hda1 关闭强制检查挂载次数限制。
tune2fs -i 10 /dev/hda1 10天后检查
tune2fs -i 1d /dev/hda1 1天后检查
tune2fs -i 3w /dev/hda1 3周后检查
tune2fs -i 6m /dev/hda1 半年后检查
tune2fs -i 0 /dev/hda1 禁用时间检查
tune2fs -j /dev/hda1 添加日志功能,将ext2转换成ext3文件系统
tune2fs -r 40000 /dev/hda1 调整/dev/hda1分区的保留空间为40000个磁盘块
tune2fs -o acl,user_xattr /dev/hda1 设置/dev/hda1挂载选项,启用Posix
Access Control Lists和用户指定的扩展属性
e2fsck :
e2fsck
Usage: e2fsck [-panyrcdfvtDFV] [-b superblock] [-B blocksize]
[-I inode_buffer_blocks] [-P process_inode_size]
[-l|-L bad_blocks_file] [-C fd] [-j external_journal]
[-E extended-options] device
Emergency help:
-p Automatic repair (no questions)
-n Make no changes to the filesystem
-y Assume "yes" to all questions
-c Check for bad blocks and add them to the badblock list
-f Force checking even if filesystem is marked clean
-v Be verbose
-b
superblock Use alternative superblock
-B
blocksize Force blocksize when looking for superblock
-j external_journal Set
location of the external journal
-l
bad_blocks_file Add to
badblocks list
-L
bad_blocks_file Set badblocks
list
e2fsck(ext2
file system
check)
功能说明:检查ext2文件系统的正确性。
语法:e2fsck [-acCdfFnprsStvVy][-b
<
href="http://www.linuxso.com/command/su.html">superblock>][-B
][-l ][-L ][设备名称]
补充说明:e2fsck执行后的传回值及代表意义如下。
0 没有任何错误发生。
1 文件系统发生错误,并且已经修正。
2 文件系统发生错误,并且已经修正。
4 文件系统发生错误,但没有修正。
8 运作时发生错误。
16 使用的语法发生错误。
128 共享的函数库发生错误。
参数:
-a 不询问使用者意见,便自动修复文件系统。
-b 指定superblock,而不使用预设的superblock。
-B 指定区块的大小,单位为字节。
-c 一并执行badblocks,以标示损坏的区块。
-C 将检查过程的信息完整记录在file
descriptor中,使得整个检查过程都能完整监控。
-d 显示排错信息。
-f 即使文件系统没有错误迹象,仍强制地检查正确性。
-F 执行前先清除设备的缓冲区。
-l 将文件中指定的区块加到损坏区块列表。
-L 先清除损坏区块列表,再将文件中指定的区块加到损坏区块列表。因此损坏区块列表的区块跟文件中指定的区块是一样的。
-n 以只读模式开启文件系统,并采取非互动方式执行,所有的问题对话均设置以"no"回答。
-p 不询问使用者意见,便自动修复文件系统。
-r 此参数只为了兼容性而存在,并无实际作用。
-s 如果文件系统的字节顺序不适当,就交换字节顺序,否则不做任何动作。
-S 不管文件系统的字节顺序,一律交换字节顺序。
-t 显示时间信息。
-v 执行时显示详细的信息。
-V 显示版本信息。
-y 采取非互动方式执行,所有的问题均设置以"yes"回答。
acp :
out/host/linux-x86/bin/acp -?
out/host/linux-x86/bin/acp: invalid option -- '?'
Unexpected arg -?
Usage: acp [OPTION]... SOURCE DEST
or: acp [OPTION]... SOURCE...
DIRECTORY
Options:
-d never follow (dereference)
symbolic links
-e if source file doesn't
exist, try adding '.exe' [Win32 only]
-f use force, removing
existing file if it's not writeable
-p preserve mode,
ownership
-r recursive copy
-t preserve timestamps
-u update only: don't copy if
dest is newer
-v verbose output (-vv is more
verbose)
mkimage --help
Usage: mkimage -l image
-l ==> list image header information
mkimage [-x] -A arch -O os -T type -C comp -a addr -e ep -n name -d
data_file[:data_file...] image
-A ==> set architecture to 'arch'
-O ==> set operating system to 'os'
-T ==> set image type to 'type'
-C ==> set compression type 'comp'
-a ==> set load address to 'addr' (hex)
-e ==> set entry point to 'ep' (hex)
-n ==> set image name to 'name'
-d ==> use image data from 'datafile'
-x ==> set XIP (execute in place)
mkimage [-D dtc_options] -f fit-image.its fit-image