sparse image
来源:互联网 发布:淘宝客服怎么应聘 编辑:程序博客网 时间:2024/05/18 02:35
前言
在使用make_ext4fs的时候有一个参数为-s,意思是sparse。使用这个参数制作出来的镜像就是sparse image。当时不明白是什么意思,所以查找了一下并记录下来。
简单地来说,sparse image是一种需要多少空间就分配多少的镜像(虚拟机的磁盘镜像文件就是这种镜像,虽然安装系统时候指定了磁盘大小,但占用的磁盘空间并没有那么大,而是随里面的文件大小增大而变大)。关于sparse image更详细的说明请看维基百科:https://en.wikipedia.org/wiki/Sparse_image
sparse image与raw image比较
我们可以用make_ext4fs命令使用-s参数与不使用时生成的镜像文件的比较(即sparse image与raw image的大小比较):
$ make_ext4fs -s -T -1 -l 838860800 -a system ./system_sparse.img ./system$ make_ext4fs -T -1 -l 838860800 -a system ./system_raw.img ./system
其中,system_raw.img是make_ext4fs命令没有使用-s参数生成的镜像文件,而system_sparse.img是make_ext4fs命令使用-s参数生成的镜像文件。
关于make_ext4fs命令的使用在这里不做深究。
(1)du命令不使用–apparent-size参数时得到的是文件占用磁盘空间的实际大小:
$ du -sh system*454M system_raw.img454M system_sparse.img
(2)du使用–apparent-size参数查看”明显的大小”,即文件自身的大小
$ du -sh system* --apparent-size 800M system_raw.img454M system_sparse.img
(3)看一下文件类型:
$ file system*system_raw.img: Linux rev 1.0 ext4 filesystem data, UUID=57f8f4bc-abf4-655f-bf67-946fc0f9f25b (extents) (large files)system_sparse.img: data
其实这里分为raw和sparse两种格式。raw ext4 image,即raw image,使用file可以看到它是一个完整的ext4分区镜像(包含很多全零的无效填充区),可以直接使用mount进行挂载。而sparse image是一个非常普通的data文件,是通过将raw ext4进行稀疏描述得到的,因此尺寸比较小(没有全零的无效填充区)
dd命令制作sparse image
创建sparse image file还可以通过dd命令的seek参数,比如要创建一个10M的虚拟磁盘映像:
$ dd if=/dev/zero of=./test.img bs=1 count=0 seek=10M 0+0 records in0+0 records out0 bytes (0 B) copied, 1.1683e-05 s, 0.0 kB/s
PS:表示先跳到偏移10M的地址,然后创建大小为bs * count的数据块。
看起来的文件大小为:
$ du -sh test.img --apparent-size 10M test.img
实际占用空间大小为:
$ du -sh test.img0 test.img
参考:
- 维基百科
- sparse image file的创建和使用
- Android中system.img的两种格式及其相互转换方法
- sparse image
- raw or sparse ext4 image
- sparse image file的创建和使用
- Image Classification——Sparse Code
- Non-local Sparse Models for Image Restoration
- Image Super-Resolution as Sparse Representation of Raw Image Patches
- sparse
- sparse
- Sparse
- Are sparse representations really relevant for image classification?
- Hyperspectral image super-resolution via non-local sparse tensor factorization
- image super-resolution as sparse representation of raw image patches详解
- image super-resolution as sparse representation of raw image patches 论文详解
- 关于2009_CVPR_Linear spatial pyramid matching using sparse coding for image classification
- 《Sparse and Redundant Representations:From Theory to Applications in Signal and Image Processing》序论
- Linear Spatial Pyramid Matching Using Sparse Coding for Image Classification 理解
- Linear Spatial Pyramid Matching Using Sparse Coding for Image Classification代码解
- ICCV Tutorial on Sparse Coding and Dictionary Learning for Image Analysis
- Android中各种Adapter的介绍及使用
- 问题以及解决办法:hadoop 不在 sudoers 文件中。此事将被报告
- 【奔跑的FPGA】part seven DE1-SOC引脚分配与导入方法
- 技术看百度,产品看腾讯,运营看阿里;
- 回调函数和函数指针
- sparse image
- s16384 —— 全国高校网安联赛逆向专题
- 七大查找算法
- 【codevs1582】【BZOJ1228】E和D,博弈
- CF717D
- 火狐浏览器
- 实现淘宝放大镜的两种方式
- Java程序打包成jar文件包并执行
- 直接插入排序