免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12
最近访问板块 发新帖
楼主: edisonmar
打印 上一主题 下一主题

求助:映射硬盘的一个怪事 [复制链接]

论坛徽章:
0
11 [报告]
发表于 2007-08-07 09:25 |只看该作者
原帖由 Largem 于 2007-8-6 20:53 发表
在创建EXT3文件系统时,缺省会有百分之几的空间保留给管理使用,具体的数字我记不得了,

用tune2fs -l /dev/md0 可以看到具体的使用情况。查看一下的几个数值
Inode count:
Block count:
Reserved block  ...

Inode count:              73269248
Block count:              146518752
Reserved block count:     7325937
Free blocks:              11355606
Free inodes:              72135605
First block:              0
Block size:               4096
Fragment size:            4096
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         16384
Inode blocks per group:   512

论坛徽章:
0
12 [报告]
发表于 2007-08-07 10:12 |只看该作者
http://blog.csdn.net/ak47mig/archive/2007/01/28/1496378.aspx

linux文件系统维护(四)
http://www.cnblogs.com/jenry/archive/2006/05/17/402101.html

一、优化ext2/ext3文件系统
1、磁盘文件系统的数据块的大小,影响磁盘的存储空间与读取数据速度,磁盘的工作效率,优化文件系统主要是正确划分磁盘数据块的大小。
mkfs.ext3 -b 1024 /dev/hda1
mdfs.ext3 -b 4096 /dev/hda1

mkfs.ext3 -b 4096 -i 4096 /dev/hda1
i代表节点代表的数据块数:
如mkfs.ext3 -b 4096 -i 8192 /dev/hda2 一个节点代表两个数据块,对大数据块寻址读取有好处。

2、tune2fs 查看文件系统的信息

[root@server root]# tune2fs -l /dev/hda10
tune2fs 1.32 (09-Nov-2002)
Filesystem volume name:   <none>
Last mounted on:          <not available>
Filesystem UUID:          6a364843-8db8-405f-a305-67ca5e1aa3e6
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal filetype sparse_super
Default mount options:    (none)
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              26112   #节点
Block count:              26097   #数据块
Reserved block count:     1304
Free blocks:              24246
Free inodes:              26101
First block:              0
Block size:               4096
Fragment size:            4096
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         26112
Inode blocks per group:   816
Filesystem created:       Tue May 16 13:02:25 2006
Last mount time:          n/a
Last write time:          Tue May 16 13:02:25 2006
Mount count:              0
Maximum mount count:      29   #最大挂载次数,超过次数,分区会自检;如果为-1分区永远不会自检(系统启动时)
Last checked:             Tue May 16 13:02:25 2006
Check interval:           15552000 (6 months)
Next check after:         Sun Nov 12 13:02:25 2006
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:               128
Journal UUID:             <none>
Journal inode:            8
Journal device:           0x0000
First orphan inode:       0

3、保留块:为管理员保留的磁盘管理空间,默认为总数据块的5%
mkfs.ext3 -b 4096 -i 8192 -m 3 /dev/hda10
设置保留块的数量点总数的百分比为3%

4、调整ext2/ext3文件系统
1)tune2fs — 调整ext2/ext3文件系统特性的工具
-l <device> 查看文件系统信息
-c <count> 设置强制自检的挂载次数
-i <n day> 设置强制自检的时间间隔
-m <percentage> 保留块的百分比
-j 将ext2文件系统转换成ext3格式

二、文件系统的检查工具
1、fsck — 检查文件系统数据完整性工具
用法一:fsck -t ext2 /dev/hda10   fsck -t ext3 [-y] /dev/hda10
用法二:fsck.ext2 [-y] /dev/hda10 fsck.ext3 [-y] /dev/hda10
2、e2fsck 检查ext2/ext3文件系统的工具(不太安全)

三、使用磁盘配额
磁盘配额作用是限制普通用户使用的磁盘空间,不至于因为个别人的浪费影响所有人的使用
需要内核支持
只有ext2/ext3的文件系统目前被支持
需要用户程序quota的软件包

1、使用usrquota,grpquota选项挂载一个分区,激活内核的支持
mount -o usrquota,grpquota /dev/hda10 /mnt/d1 或
mount -o remount,usrquota,grpquota /
2、init 1(进入单用户环境)
3、quotacheck -cvuga 检查并创建磁盘配额的数据库文件
4、edquota -u <username> 为指定用户分配磁盘空间和节点数量
5、quota命令可查看用户的配额使用情况
6、quotaon /quotaoff激活/除去(删除相关磁盘配额的数据库文件aquota.group 、aquota.user)磁盘配额
[root@server root]#  mount /dev/hda10 /mnt/d1 -o usrquota,grpquota
[root@server root]# mount
/dev/hda7 on / type ext3 (rw)
none on /proc type proc (rw)
usbdevfs on /proc/bus/usb type usbdevfs (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/hda9 on /opt type ext3 (rw)
none on /dev/shm type tmpfs (rw)
/dev/hda10 on /mnt/d1 type ext3 (rw,usrquota,grpquota)


[root@server root]# more /etc/mtab
/dev/hda7 / ext3 rw 0 0
none /proc proc rw 0 0
usbdevfs /proc/bus/usb usbdevfs rw 0 0
none /dev/pts devpts rw,gid=5,mode=620 0 0
/dev/hda9 /opt ext3 rw 0 0
none /dev/shm tmpfs rw 0 0
/dev/hda10 /mnt/d1 ext3 rw,usrquota,grpquota 0 0

[root@server root]# edquota -u redhat
Disk quotas for user redhat (uid 500):
  Filesystem                   blocks       soft       hard     inodes     soft     hard
  /dev/hda10                        0          0          0          0        0        0

blocks:数据块soft、hard限制
inodes:代表文件个数soft、hard限制

论坛徽章:
0
13 [报告]
发表于 2007-08-07 10:25 |只看该作者
http://www.newsforge.com/article.pl?sid=03/10/07/1943256

Optimizing Linux filesystems
Friday October 10, 2003 (08:09 AM GMT)
By: Roderick W. Smith

  Printer-friendly   Email story  
Last time we introduced a few common Linux filesystems and examined their features. If you've already installed Linux, your partitions are already set up and configured with particular filesystems, but you may decide you want to modify this configuration. What's the best way to begin?

Click here!

    This article is excerpted from the recently published book Linux Power Tools.

Some changes are tedious to implement. For instance, changing from one filesystem to another requires you to back up, create a new filesystem, and restore your files. One exception to this rule is changing from ext2fs to ext3fs. If you switch filesystems, you may be able to use filesystem-creation options to improve the performance of the new filesystem. Other changes can also be done relatively painlessly. These include defragmenting a disk (that is, repositioning file contents so that they're not spread out over the entire partition) and resizing partitions to give you space where you need it.

Creating a filesystem for optimal performance

Most filesystems support a variety of options that may impact performance. For instance, large allocation blocks can improve performance by reducing fragmentation and the number of operations needed to retrieve an entire file. Some of these options can be set only at filesystem creation time, but some can be changed after the fact. Not all of these features are available in all filesystems. Across all Linux filesystems, important and popular performance-enhancing (or performance-degrading) options include:

Allocation block size

As noted in the earlier section, "Minimizing Space Consumption," small allocation blocks can facilitate more efficient use of disk space, but the cost is a small degradation in disk-access speed. Therefore, to improve performance slightly, you can increase your block size. This option is not easily changed after creating a filesystem. With ext2fs or ext3fs, you can use the -b block-size option to mke2fs; with XFS, the -b size=block-size option to mkfs.xfs does the job. For ext2fs and ext3fs, block-size must be 1024, 2048, or 4096; with XFS, the block size can theoretically be any power-of-two multiple of 512 bytes up to 64KB (65536 bytes), although in practice you can only mount a filesystem with block sizes up to 4KB or 8KB using common CPUs. ReiserFS and Linux's version of JFS do not yet support adjusting this feature.

Journaling options

All the journaling filesystems support various journal options. One common option is the location of the journal. By placing the journal on a separate physical disk from the main filesystem, you can improve performance (provided the target disk isn't too sluggish itself). You can use the -J device=journal-device option in mke2fs or the -j journal-device option in mkreiserfs or mkfs.jfs to set this feature. Ext3fs also supports setting the journal size with the -J size=journal-size option, where journal-size is specified in megabytes and must be between 1,024 and 102,400 filesystem blocks. Specifying a too-small journal may degrade performance, but setting one too large may rob you of too much disk space. If in doubt, let mke2fs decide on the journal size itself.

Reserved blocks

Ext2fs and ext3fs reserve a number of blocks for use by the superuser (or some other user you specify). The default value of 5 percent reserved space may be overkill on large partitions or on less critical partitions (such as /home). You can gain a bit more space by using the -m reserved-percentage option to mke2fs. Changing this percentage won't affect actual disk performance, but it may gain you just a bit more available disk space. You can change this option after you create a filesystem by passing the same parameter that mke2fs accepts to the tune2fs program, as in tune2fs -m 1 /dev/hda4 to set the reserved blocks percentage to 1.

Check interval

Ext2fs and ext3fs force a filesystem check after a specified number of mounts or a specified amount of time between mounts. The idea is to catch errors that might creep onto the filesystem due to random disk write errors or filesystem driver bugs. You can change these intervals by using the -c max-mount-counts and -i interval-between-checks options to tune2fs. For the latter option, you specify an interval in days, weeks, or months by providing a number followed by a d, w, or m, respectively. Altering the check interval won't modify day-to-day performance, but it will change how frequently the computer performs a full disk check on startup. This disk check can be quite lengthy, even for ext3fs; it doesn't restrict itself to recent transactions as recorded in the journal, as a forced check after a system crash does.

Directory hash

ReiserFS uses a sorted directory structure to speed directory lookups, and mkreiserfs provides several options for the hash (a type of lookup algorithm) used for this purpose. You set this option with the -h hash option to mkreiserfs, where hash can be r5, rupasov, or tea. Some hashes may yield improved or degraded performance for specific applications. The Squid Web proxy documentation suggests using the rupasov hash, whereas the qmail documentation recommends r5, for instance. One problem with the r5 and rupasov hashes is that they can greatly slow file creation in directories with very many (a million or so) files. In fact, rupasov is very prone to such problems, and so should be avoided on most systems. The tea hash is much less subject to this problem, but it is also much slower than r5 for directories with more typical numbers of files. In general, you should use the default r5 hash unless you know you'll be creating many files or the disk will be used by one performance-critical application, in which case checking the application's documentation or doing a web search for advice may be worthwhile.

Inode options

XFS enables you to set the inode size at filesystem creation time using the -i size=value option to mkfs.xfs. The minimum and default size is 256 bytes; the maximum is 2,048 bytes. (The inode size can't exceed half the allocation block size, though.) One impact of the inode size option relates to small file access times; because XFS tries to store small files within the inode whenever possible, specifying a large inode enables storing larger files within the inode. Doing so will speed access to these files. Therefore, if a partition will store many small files (under 2KB), you may want to increase the inode size. Depending on the exact mix of file sizes, the result may save or waste disk space. If few files will be smaller than 2KB, there's little point to increasing the inode size.

The default filesystem creation options usually yield acceptable performance. Modifying these options can help in some unusual cases, such as filesystems storing huge numbers of files or a computer that's restarted frequently. I don't recommend trying random changes to these options unless you intend to run tests to discover what works best for your purposes.

Converting ext2fs to ext3fs

One of the advantages of ext3fs over the other journaling filesystems is that it's easy to turn an existing ext2 filesystem into an ext3 filesystem. You can do this using the tune2fs program and its -j option:

# tune2fs -j /dev/hda4

If the filesystem to which you add a journal is mounted when you make this change, tune2fs creates the journal as a regular file, called .journal, in the filesystem's root directory. If the filesystem is unmounted when you run this command, the journal file doesn't appear as a regular file. In either case, the filesystem is now an ext3 filesystem, and it can be used just as if you created it as an ext3 filesystem initially. If necessary, you may be able to access the filesystem as ext2fs (say, using a kernel that has no ext3fs support); however, some older kernels and non-Linux utilities may refuse to access it in this way, or they may provide merely read-only access.

On rare occasion, an ext3 filesystem's journal may become so corrupted that it interferes with disk recovery operations. In such cases, you can convert the filesystem back into an ext2 filesystem using the debugfs tool:

# debugfs -w /dev/sda4
debugfs 1.32 (09-Nov-2002)
debugfs:  features -needs_recovery -has_journal
Filesystem features: dir_index filetype sparse_super
debugfs:  quit

After performing this operation, you should be able to use fsck.ext2 with its -f option, as described in the upcoming section, "Filesystem Check Options," to recover the filesystem. The newly deactivated journal will cause fsck.ext2 to report errors even if the filesystem did not previously have them. If you like, you can then add the journal back by using tune2fs, as just described. (Don't try to remove the journal from a mounted filesystem.)

Next time we'll talk about other filesystem operations, such as resizing filesystems and defragmenting a disk.

Slashdot Slashdot it!

论坛徽章:
0
14 [报告]
发表于 2007-08-07 10:44 |只看该作者
恐怕不是楼上所说的 所谓保留空间的问题,
因为事实上,创建的时候不会预留多大空间的,除非手动指定保留多少,

所以我想楼主试试在本地COPY文件看看,看是否显示满了,一般是可以达到100%的呀

root@Worksever ~]# df -h
Filesystem            容量  已用 可用 已用% 挂载点
/dev/hda2             4.9G  4.4G  185M  97% /
/dev/hda1             190M   29M  153M  16% /boot
none                 1014M     0 1014M   0% /dev/shm
/dev/hda5             141G  126G  8.0G  95% /disk/disk1
/dev/md0              688G  650G  3.0G 100% /disk/disk2
/dev/md1              587G  460G   98G  83% /disk/disk3
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP