在装系统,因此在这里随便记点东西。

 

从前与经理讨论NVR项目的时候,他提到要预先将用户指定好的磁盘空间预留出来,这是比较容易实现的功能。不容易实现的是自己写一个文件系统,这种方法我是不太敢照量啊,不过感兴趣的话可以到SourceForge找找开源的项目来学习,呵呵,说实在的,让我看都不一定能理解。在李素梅的帮助下,我做了在磁盘预留空间的实验,本质上是这样的:

 

(1)首先在要预留空间的分区上使用dd命令生成一个指定大小的文件:

 

#创建一个10M的文件,名字是foobar:

 

# dd if=/dev/zero of=/home/foobar bs=1K count=10000

 

/dev/zero

From Wikipedia, the free encyclopedia

In Unix-like operating systems, /dev/zero is a special file that provides as many null characters (ASCII NULL, 0x00; not ASCII character "digit zero", "0", 0x30) as are read from it. One of the typical uses is to provide a character stream for overwriting information. Another might be to generate a clean file of a certain size. Using mmap to map /dev/zero to RAM is the BSD way of implementing shared memory.

 

(2)将这个文件格式化:

 

# mke2fs -vFm0 /home/foobar 100000000 //(1K * 10000)

 

(3)将这个文件mount,之后就可以向这个文件中写内容了,就好比向一个目录中写内容一样:

 

# mount -o loop home/foobar /mnt/mountpoint

(责任编辑:A6)

本站文章仅代表作者观点,本站仅传递信息,并不表示赞同或反对.转载本站点内容时请注明来自www.linuxeden.com-Linux伊甸园。如不注明,www.linuxeden.com将根据《互联网著作权行政保护办法》追究其相应法律责任。