分享

嵌入式系统中常用文件系统的制作总结

 darkhero 2006-11-15
Creating a Compressed RAM Disk
a) Decide on the RAM disk size that you want. Say 8 MB for this example.


    dd if=/dev/zero of=ramdisk bs=1k count=8192

 

b) Make a filesystem on it. Say ext2fs for this example.

 

$mke2fs -F -vm0 ramdisk

 

mke2fs 1.38 (22-April-2006)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
2048 inodes, 8192 blocks
409 blocks (4.99%) reserved for the super user
First data block=1
1 block group
8192 blocks per group, 8192 fragments per group
2048 inodes per group

Writing inode tables: done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 16 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

 

c) Mount it, copy the files you want to it (eg: /etc/* /dev/* ...)
   and unmount it again.

 

$mount -o loop ramdisk /mnt

$ls /mnt

lost+found

$df -h /mnt

Filesystem            容量  已用 可用 已用% 挂载点
/mnt                  7.8M  1.0K  7.4M   1% /mnt

 

$umount /mnt

 

d)compress

 

$gzip -9 ramdisk 

-9使用最高级的压缩算法,大约60%的压缩比.得到ramdisk.gz

$mv ramdisk.gz ramdisk.image.gz

$gunzip ramdisk.image.gz





JFFS2

 

mkdir  /jffs2_dir
这样做就是你新做的jffs2.img里面除了你刚刚添加的hello外没有任何目录和文件,而这完全可以工作,启动后自己添加即可。
mkfs.jffs2 -d  /jffs2_dir  -o  jffs2.img
这个mkfs.jffs2工具是要额外提供的,如果您没有,可发信索取。

 

mkfs.jffs2 -r rootfs/ -o jffs2.img

-r指定内含有根文件系统的目录,并使用-o来指定文件系统映像的输出文件名称.

-l or -b建立字节顺序为little endian或big endian.

 

jffs2的压缩比仅为10%高一点..

 

eraseall /dev/mtd5

    Erased 8192 Kibyte @ 0 -- 100% complete.

cat jffs2.img >/dev/mtd5

 

mount -t jffs2 /dev/mtdblock/5 /jffs2

与磁盘文件系统不同,无法在loopback设备上使用mount -o loop ...命令jffs2。你必须从真正的MTD设备来安装jffs2。




CRAMFS
 

对于CRAMFS:
和JFFS2完全相同的做法,你也完全可以自己
mkdir /cramfs_dir
mkcramfs /cramfs_dir cramfs.img
当然了,和JFFS2不同的是,它是只读的,你在PC机上添加了什么,到板子上就只能有什么,不能再动态创建目录和复制进去文件了,要添加必须重做cramfs.img烧写到FLASH上才行。
这个mkcramfs的工具是REDHAT LINUX自带的。

mount -t cramfs /dev/mtdblock/5 /cramfs

 


  1. 每个文件最大不超过16M;
  2. 不提供.和..目录;
  3. 文件的uid具有16bits的width,gid有8bits的宽度.一般的文件系统通常会支持宽度16/32的uid和gid,CRAMFS, GIDs are truncated to the lower 8 bits.In other words, the maximum GID usable in a root filesystem built on CRAMFS is 255.
  4. 所有文件的时间戳会被设成Unix epoch(00:00:00 GMT, January 1, 1970).The timestamps may be
    updated at runtime, but the updated values will last only as long as the inode is cached in memory;Once the file is reloaded, its timestamp will revert to epoch.
  5. CRAMFS images can be read only by kernels using 4096-byte page sizes (The value of
    PAGE_CACHE_SIZE must be 4096).
  6. All files, whether they are linked or not, have a link count of 1. Even when multiple filesystem entries point to the same file, that file has a link count of only 1. This is fine for most operations,however, since no files can actually be deleted from CRAMFS.

 





NFTL

 

mke2fs /dev/nftla1

 

mount -t ext2 /dev/nftla1 /mnt

NFTL上的ext2并不提供"断电可靠性"。如有这方面需要,可使用日志型文件系统,如ext3,XFS,jfs或reiserfs.




Filesystem characteristics
Filesystem       Write     Persistent    Power down reliability   Compression     Lives in RAM
CRAMFS           No         N/A          N/A                         Yes             No
JFFS2            Yes         Yes         Yes                         Yes             No
JFFS             Yes         Yes         Yes                         No              No
Ext2overNFTL     Yes         Yes         No                          No              No
Ext3overNFTL     Yes         Yes         Yes                         No              No
Ext2overRAMdisk  Yes         No          No                          No              Yes

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多