快捷搜索:   nginx

Ext3和Reiserfs文件系统占用空间的比较

Ext3文件系统和reiserfs文件系统现在linux系统上是非常流行的两种。下面我们来比较一下这两种文件系统本身对硬盘空间的占用情况。因为我的硬盘分区已经基本定好,不容易更改了,所以就使用文件的方式创建文件来进行比较──毕竟我们这里比较的不是速度,而是空间──然而这样做不知是否和实际设备上有区别。
 
  (一)首先,我们需要一个有足够空闲空间的分区来做这个实验。我的空闲的空间还不到5GB,所以只好把实验的每个最大分区做到2GB.我的实验中先是做100MB的“分区”的比较,然后是1GB分区的比较,最后是2GB分区的比较。我们所需要的工具也十分简单:dd工具,用于较快地取得一个大文件;创建文件的工具mkfs.ext3和mkfs.reiserfs;df工具,用来查看分区占用情况。
 
  这里提前说明我的系统的简单情况:内核为2.6.23.1,自己编译的。命令替换有alias ll='ls -l'.reiserfs版本是3.6的。
 
  (二)现在就开工:
 
  1.创建100M的文件:
 
  dd if=/dev/zero of=d-ext3fs bs=1M count=100
 
  dd if=/dev/zero of=d-reiserfs bs=1M count=100
 
  2.创建文件系统:
 
  2.1创建ext3文件系统:
 
   togry@xiaowp:~/disks$ sudo mkfs.ext3 d-ext3fs mke2fs 1.40.4 (31-Dec-2007) d-ext3fs is not a block special device. Proceed anyway? (y,n) y Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) 25688 inodes, 102400 blocks 5120 blocks (5.00%) reserved for the super user First data block=1 Maximum filesystem blocks=67371008 13 block groups 8192 blocks per group, 8192 fragments per group 1976 inodes per group Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729 Writing inode tables: done Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 31 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. 2.2创建reiserfs文件系统: togry@xiaowp:~/disks$ sudo mkfs.reiserfs d-reiserfs mkfs.reiserfs 3.6.19 (2003 www.namesys.com) A pair of credits: Lycos Europe (www.lycos-europe.com) had a support contract with us that consistently came in just when we would otherwise have missed payroll, and that they kept doubling every year. Much thanks to them. Jeremy Fitzhardinge wrote the teahash.c code for V3. Colin Plumb also contributed to that. d-reiserfs is not a block special device Use -f to force over ///////////////呵呵,不让我默认在文件上创建文件系统。 togry@xiaowp:~/disks$ sudo mkfs.reiserfs d-reiserfs -f mkfs.reiserfs 3.6.19 (2003 www.namesys.com) A pair of credits: The Defense Advanced Research Projects Agency (DARPA, www.darpa.mil) is the primary sponsor of Reiser4. DARPA does not endorse this project; it mer ely sponsors it. Jeremy Fitzhardinge wrote the teahash.c code for V3. Colin Plumb a lso contributed to that. d-reiserfs is not a block special device Continue (y/n):y Guessing about desired format.. Kernel 2.6.23.1.build51 is running. Format 3.6 with standard journal Count of blocks on the device: 25600 Number of blocks consumed by mkreiserfs formatting process: 8212 Blocksize: 4096 Hash function used to sort names: "r5" Journal Size 8193 blocks (first block 18) Journal Max transaction length 1024 inode generation number: 0 UUID: 3bb7a2da-b78a-462f-9ea0-a004171c8667 Initializing journal - 0%....20%....40%....60%....80%....100% Syncing..ok Tell your friends to use a kernel based on 2.4.18 or later, and especially n ot a kernel based on 2.4.9, when you use reiserFS. Have fun. ReiserFS is successfully created on d-reiserfs.


  3.这样创建好文件系统之后,开始挂载它们,查看他们的可用空间吧。
 
  togry@xiaowp:~/disks$ sudo mount d-ext3fs ext/ -t ext3 -o loop
 
  togry@xiaowp:~/disks$ sudo mount d-reiserfs rei/ -t reiserfs -o loop
 
  togry@xiaowp:~/disks$ df
 
  文件系统 1K-块 已用 可用 已用% 挂载点
 
  ……(此处将不相干的东西略去)
 
  /home/togry/disks/d-ext3fs
 
  99150 5664 88366 7% /home/togry/disks/ext
 
  /home/togry/disks/d-reiserfs
 
  102392 32840 69552 33% /home/togry/disks/rei
 
  哟!reiserfs文件系统竟然占用了这么大的地方,三分之一都没有了。
 
  4.创建两个1GB的文件进行比较。相比前面,这里要简略一些。
 
  drwxr-xr-x 2 togry togry 48 2008-01-11 17:07 ext
 
  -rw-r——r—— 1 togry togry 1073741824 2008-01-22 20:53 ext3
 
  drwxr-xr-x 2 togry togry 48 2008-01-11 17:07 rei
 
  -rw-r——r—— 1 togry togry 1073741824 2008-01-22 20:50 reiserfs
 
  其中etc3和reiserfs两个文件就是“设备”。
 
  5.创建文件系统
 
   togry@xiaowp:~/disks$ sudo mkfs.reiserfs reiserfs -f mkfs.reiserfs 3.6.19 (2003 www.namesys.com) A pair of credits: Edward Shushkin wrote the encryption and compression file plugins, and the V3 journal relocation code. Lycos Europe (www.lycos-europe.com) had a support contract with us that consistently came in just when we would otherwise have missed payroll, and that they kept doubling every year. Much thanks to them. reiserfs is not a block special device Continue (y/n):y Guessing about desired format.. Kernel 2.6.23.1.build51 is running. Format 3.6 with standard journal Count of blocks on the device: 262144 Number of blocks consumed by mkreiserfs formatting process: 8219 Blocksize: 4096 Hash function used to sort names: "r5" Journal Size 8193 blocks (first block 18) Journal Max transaction length 1024 inode generation number: 0 UUID: 2b05d990-54b3-49c7-a197-79807a173c5b Initializing journal - 0%....20%....40%....60%....80%....100% Syncing..ok Tell your friends to use a kernel based on 2.4.18 or later, and especially not a kernel based on 2.4.9, when you use reiserFS. Have fun. ReiserFS is successfully created on reiserfs. togry@xiaowp:~/disks$ sudo mkfs.ext mkfs.ext2 mkfs.ext3 togry@xiaowp:~/disks$ sudo mkfs.ext3 ext ext/ ext3 togry@xiaowp:~/disks$ sudo mkfs.ext3 ext3 mke2fs 1.40.4 (31-Dec-2007) ext3 is not a block special device. Proceed anyway? (y,n) y Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 131072 inodes, 262144 blocks 13107 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=268435456 8 block groups 32768 blocks per group, 32768 fragments per group 16384 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376 Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 28 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.  
  6.挂载文件系统之后查看空间的剩余情况
 
  togry@xiaowp:~/disks$ df
 
  文件系统 1K-块 已用 可用 已用% 挂载点
 
  ……
 
  /home/togry/disks/ext3
 
  1032088 34092 945568 4% /home/togry/disks/ext
 
  /home/togry/disks/reiserfs
 
  1048540 32840 1015700 4% /home/togry/disks/rei
 
  togry@xiaowp:~/disks$ df -h
 
  文件系统 容量 已用 可用 已用% 挂载点
 
  ……
 
  /home/togry/disks/ext3
 
  1008M 34M 924M 4% /home/togry/disks/ext
 
  /home/togry/disks/reiserfs
 
  1.0G 33M 992M 4% /home/togry/disks/rei
 
  似乎文件空间的占用情况相当了。让我们再看看2GB文件系统里的情况:
 
  7.创建文件:
 
  dd if=/dev/zero of=ext3 bs=1G count=2
 
  dd if=/dev/zero of=reiserfs bs=1G count=2
 
  看一下结果:
 
  drwxr-xr-x 2 togry togry 48 2008-01-11 17:07 ext
 
  -rw-r——r—— 1 togry togry 2147483648 2008-01-22 21:30 ext3
 
  drwxr-xr-x 2 togry togry 48 2008-01-11 17:07 rei
 
  -rw-r——r—— 1 togry togry 2147483648 2008-01-22 21:35 reiserfs
 
  8.创建文件系统:
 
   togry@xiaowp:~/disks$ sudo mkfs.ext3 ext3 mke2fs 1.40.4 (31-Dec-2007) ext3 is not a block special device. Proceed anyway? (y,n) y Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 262144 inodes, 524288 blocks 26214 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=536870912 16 block groups 32768 blocks per group, 32768 fragments per group 16384 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912 Writing inode tables: done Creating journal (16384 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 25 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. togry@xiaowp:~/disks$ sudo mkfs.reiserfs reiserfs -f mkfs.reiserfs 3.6.19 (2003 www.namesys.com) A pair of credits: BigStorage (www.bigstorage.com) contributes to our general fund every month, and has done so for quite a long time. Lycos Europe (www.lycos-europe.com) had a support contract with us that consistently came in just when we would otherwise have missed payroll, and that they kept doubling every year. Much thanks to them. reiserfs is not a block special device Continue (y/n):y Guessing about desired format.. Kernel 2.6.23.1.build51 is running. Format 3.6 with standard journal Count of blocks on the device: 524288 Number of blocks consumed by mkreiserfs formatting process: 8227 Blocksize: 4096 Hash function used to sort names: "r5" Journal Size 8193 blocks (first block 18) Journal Max transaction length 1024 inode generation number: 0 UUID: 0d3e668d-77e5-4b5d-a157-a3e937cbc7f4 Initializing journal - 0%....20%....40%....60%....80%....100% Syncing..ok Tell your friends to use a kernel based on 2.4.18 or later, and especially not a kernel based on 2.4.9, when you use reiserFS. Have fun. ReiserFS is successfully created on reiserfs. 
  这回创建文件系统的时间都比以前长了。
 
  9.挂载文件系统,看结果:
 
  togry@xiaowp:~/disks$ sudo mount ext3 ext -t ext3 -o loop && sudo mount reiserfs rei -t reiserfs -o loop
 
  togry@xiaowp:~/disks$ df
 
  文件系统 1K-块 已用 可用 已用% 挂载点
 
  ……
 
  /home/togry/disks/ext3
 
  2064208 68680 1890672 4% /home/togry/disks/ext
 
  /home/togry/disks/reiserfs
 
  2097084 32840 2064244 2% /home/togry/disks/rei
 
  togry@xiaowp:~/disks$ df -h
 
  文件系统 容量 已用 可用 已用% 挂载点
 
  ……
 
  /home/togry/disks/ext3
 
  2.0G 68M 1.9G 4% /home/togry/disks/ext
 
  /home/togry/disks/reiserfs
 
  2.0G 33M 2.0G 2% /home/togry/disks/rei
 
  (三)综上所做的实验,我可以比较肯定的说对于ext3文件系统,当分区增大时,它本身所使用的空间也随之较快的增长;而reiserfs系统的增长速度却远没有ext3文件系统那样快。此外由于reiserfs是真正的日志文件系统,所以它比较适用于经常对文件读和写的地方;而ext3文件系统也具有一定的日志功能,但是它的性能就没那么好了。而对于小的分区,比如/boot,使用ext3或者是ext2作为基本上是只读的分区就是非常理想的。
 

顶(0)
踩(0)

您可能还会对下面的文章感兴趣:

最新评论