Linux系统下生成一个指定大小的文件
(1)首先在要预留空间的分区上使用dd命令生成一个指定大小的文件:
#创建一个10M的文件,名字随便叫,这里为test:
[ ~]# dd if=/dev/zero of=/test/test.file bs=1k count=10000
10000+0 records in
10000+0 records out
10240000 bytes (10 MB) copied, 0.041744 seconds, 245 MB/s
[root@fc6 ~]#ls -lh
total 9.8M
-rw-r--r-- 1 candon123 36973 9.8M Mar 3 20:25 test.file
(2)将这个文件格式化:
[root@fc6 ~]#mke2fs -vFm0 /test/test.file 100000000
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
12500992 inodes, 25000000 blocks
0 blocks (0.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
763 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
(3)将这个文件mount,之后就可以向这个文件中写内容了,就好比向一个目录中写内容一样:
[root@fc6 ~]#mount -o loop /test/test.file /mnt/test
阅读(930) | 评论(0) | 转发(0) |