Linux ext3等分区是具有inode table的,用于存储文件的位置等信息。一般来讲,一个文件将占用1~2个inode值。在WEB系统中,如果采用生称html方式,会产生大量的小文件,这样会暂用大量的inode值。所以,常常出现文件空间还剩余很多,但是由于inode满了,LINUX也会报警说没有空间了,不允许增加文件。
根据这一状况,你可能需要对磁盘的inode大小进行调整。
如果磁盘中主要为小文件,你可以适当的增加inode值。
如果大文件居多,可以适量减少inode空间,当然这并不是很必要,inode也暂用的空间并不是很大,节省不了很多。
可以使用 mkfs来调整inode数值。
具体方法&案例:
0. 预热,准备一些数据和资料
我目前需要将我的分区 /dev/sda9 (mount at /var/www)的inode值增加到2500000(原值为2000640)。
我的系统: ubuntu 8.04 Desktop
df #获得目前磁盘加载情况己使用情况 df -i #获得目前磁盘inode使用情况,便于估计目标inode将要调整为多少 cat /etc/fstab #输出当前fstab,修改inode之后,uuid会被修改。因此,该文件也需要作相应调整。需要记录一下,最好的,cp备份一下 cp -aR /var/www /home/bak/ #备份所有数据到另一个分区/home,调整inode会格式化整个分区,分区将被删除
1. umount
sudo umount /var/www #www是我准备调整inode的磁盘。当然,umount之前你需要关闭一些使用它的进程。比如apache,或者其他service
2. mkfs.ext2,调整inode
注意!!!!!!!!!!该操作将删除整个分区数据,在进行此操作之前,请再次确认你已经对该分区的信息做好了备份。
请再次确认你的数据已经全部备份完毕。
sudo mkfs.ext2 -N 2500000 /dev/sda9 # 2500000 是我需要的inode值 /dev/sda9是我 /var/www的磁盘。
会有类似于这样的一些输出,具体含义不表:
mke2fs 1.40.8 (13-Mar-2008)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
2503680 inodes, 3905795 blocks
195289 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4001366016
120 block groups
32768 blocks per group, 32768 fragments per group
20864 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208Writing inode tables: done
Writing superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
3. 更新分区
sudo tune2fs -j /dev/sda9
4. 更新系统uuid。
sudo udevtrigger
5. 获取新的uuid,记录它
sudo vol_id -u /dev/sda9
6. 修改fstab,将新的uuid替换进去
sudo vi /etc/fstab
有可能,你也需要相应调整 /dev/sda1的uuid值或其他,你可以通过下列语句来检查并更新uuid,直到mount -a 不报错。
sudo umount -a sudo mount -a
7. 最终,在mount -a通过之后,使用预热阶段的命令查看一下新的设置。
rollenc@rollenc-Kubuntu:~$ df -i
文件系统 Inode (I)已用 (I)可用 (I)已用% 挂载点
/dev/sda9 2503680 11 2503669 1% /var/www
inode值已经增加了。当然,有一些偏差,这是正常的可以接受的。
How can I change the default size of an inode when I create an ext2/ext3 filesystem?
It is possible to define a non-standard sized inode by using the mke2fs tool with an undocumented option, -I. The size of the inode has to be a power of two and between the size of EXT2_GOOD_OLD_INODE_SIZE (128 bytes) and size of blocks in bytes. One reason for doing this could be that user is going to use extended attributes. Extended attributes are arbitrary name/value pairs used to store system objects like Access Control Lists (ACL). If the size of the inodes is larger than the default size, then sufficiently small attributes can be stored in inode. However, use this option with caution because of compatibility issues. It may render the filesystem unusable on most systems. Use the command man 8 mke2fs for more details.
Below is a part of the source file of mke2fs. The source files can be downloaded from http://e2fsprogs.sourceforge.net/. As this is an undocumented feature, the code below shows what the -I option do.
The source file can be found under the directory e2fsprogs-1.39/misc/mke2fs.c
while ((c = getopt (argc, argv,
"b:cf:g:i:jl:m:no:qr:s:tvE:FI:J:L:M:N:O:R:ST:V")) != EOF) {
switch (c) {
...
case 'I':
inode_size = strtoul(optarg, &tmp, 0);
...
if (inode_size) {
if (inode_size EXT2_BLOCK_SIZE(&fs_param) ||
inode_size & (inode_size - 1)) {
com_err(program_name, 0,
_("invalid inode size %d (min %d/max %d)"),
inode_size, EXT2_GOOD_OLD_INODE_SIZE,
blocksize);
exit(1);
}
if (inode_size != EXT2_GOOD_OLD_INODE_SIZE)
fprintf(stderr, _("Warning: %d-byte inodes not usable "
"on most systems\n"),
inode_size);
fs_param.s_inode_size = inode_size;
}
Here are some examples how a user can specify the -I option:
# mke2fs -I 127 /dev/hda1 mke2fs 1.39 (29-May-2006) mke2fs: invalid inode size 127 (min 128/max 4096)
# mke2fs -I 4097 /dev/hda1 mke2fs 1.39 (29-May-2006) mke2fs: invalid inode size 4097 (min 128/max 4096)
# mke2fs -I 256 /dev/hda1 mke2fs 1.39 (29-May-2006) Warning: 256-byte inodes not usable on most systems ...
# mke2fs -j -I 256 /dev/hda1 mke2fs 1.39 (29-May-2006) Warning: 256-byte inodes not usable on most systems ... Creating journal (8192 blocks): done
How do I Change The Inode Size of an Existing Partition?
Computers store information on storage devices following organizational patterns called filesystems. All filesystems maintain a set of data structures called inodes --- one for each file, directory or other link that can exist in the filesystem. The amount of space allocated for each inode is a trade-off: bigger inodes can contain richer metadata (e.g., access control lists) for each file, but they take more disk space away from storing user data. Linux- and Unix-based filesystems such as ext2 and ext3 allow finer control than Windows-based filesystems (e.g., NTFS and FAT) over the space allocated for metadata at filesystem creation time. Unfortunately, inodes can be resized by only re-creating the filesystem from scratch.
本日志由 flyinweb 于 2011-09-03 10:02:46 发表,目前已经被浏览 812 次,评论 0 次;
作者添加了以下标签: inode size;
引用通告:http://www.517sou.net/Article/666/Trackback.ashx
而且直接配置文件是效率最高的,通过其它驱动效率都相对较低,BDB
这个测试不太准确,看官方的测试结果:http://bind-dlz.sourceforg
为什么使用BDB时QPS这么低? 我在bind版本基本相似的环境中测试的
It is quite useful and interesting too.
VIRT 的上限是64G,也就是36位, cat /proc/cpuinfo的结果是:addre
昨天要准备用线程重写webbench,试验了下Fedora Linux 2.6.35.14
不明白您的具体的意思是什么?
已经发送到你QQ邮箱