Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1741721
  • 博文数量: 297
  • 博客积分: 285
  • 博客等级: 二等列兵
  • 技术积分: 3006
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-06 22:04
个人简介

Linuxer, ex IBMer. GNU https://hmchzb19.github.io/

文章分类

全部博文(297)

文章存档

2020年(11)

2019年(15)

2018年(43)

2017年(79)

2016年(79)

2015年(58)

2014年(1)

2013年(8)

2012年(3)

分类: LINUX

2016-08-13 21:43:35

最近学了点ext4 文件系统的知识,记录下。
ext4 支持最大文件系统大小为 1 EB, 最大文件为 16TB。
1. 查询文件系统的manual.

点击(此处)折叠或打开

  1. man ext4
2. 如何在ubuntu 14.04.3上启用quota.
ext3和ext4 是journal 文件系统,而ext2 不是。

点击(此处)折叠或打开

  1. apt-get install quota quotatool
  2. #load kernel module
  3. modprobe quota_v2
在fstab里面添加如下内容,eg. 我在根目录上实施quota.

点击(此处)折叠或打开

  1. #要添加这些,?usrjquota=aquota.user,grpjquota=aquota.grp,jqfmt=vfsv0 ?
  2. /dev/mapper/ubuntu--vg-root / ext4 usrjquota=aquota.user,grpjquota=aquota.grp,jqfmt=vfsv0,errors=remount-ro 0 1
  3. #touch file under mount point 
  4. touch /aquota.user 
  5. touch /aquota.grp 
  6. #remount filesystem  
  7. mount -o remount /
  8. #check file system 
  9. quotacheck -acguvm /
  10. #enable quota 
  11. quotaon -avug
  12. #edit user root quota
  13. edquota -u root 
  14. #also can use setquota to set quota 
  15. setquota -u root
  16. #report on usage
  17. repquota / -u root -v
3. disable or enable journal. 该操作必须在unmount文件系统的情况下才能操作。

点击(此处)折叠或打开

  1. umount /sda6
  2. # Delete has_journal option; remove has_journal from Filesystem features.
  3. tune2fs -O ^has_journal /dev/sda6 
  4. #enable command below 
  5. tune2fs -O has_journal /dev/sda6
  6. #e2fsck 
  7. e2fsck -f /dev/sda6
  8. #verify with dumpe2fs
  9. dumpe2fs -h 
  10.                
4.  显示 Ext2/Ext3/Ext4 档案系统资讯,下面转贴自

要显示一个 Ext2/Ext3/Ext4 档案系统的资讯,可以使用 e2fsprogs 中的 dumpe2fs 或 tune2fs -l 命令,例如:

dumpe2fs /dev/sda6 

或者

tune2fs -l /dev/sdb7 

dumpe2fs 会显示 superblock 上的档案系统资讯和每个区块组 (block group) 的资讯,在一般拥有很多区块组档案系统,会佔据很长的画面。而 tune2fs -l 只会显示 superblock 上的资讯。如果您只想看 superblock 上关整个档案系统的资讯,除了使用 tune2fs -l 外,亦可以在 dumpe2fs 加上 -h 选项:

dumpe2fs -h /dev/sda6

dumpe2fs/tune2fs -l 画面

以下是一个典型的 dumpe2fs 画面:

Filesystem volume name:   /home
Last mounted on:          
Filesystem UUID:          d7a9f647-3364-4ed9-824e-63cd748458bc
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize
Filesystem flags:         signed_directory_hash 
Default mount options:    (none)
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              524288
Block count:              2096466
Reserved block count:     104823
Free blocks:              1426242
Free inodes:              518632
First block:              0
Block size:               4096
Fragment size:            4096
Reserved GDT blocks:      511
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         8192
Inode blocks per group:   512
Flex block group size:    16
Filesystem created:       Mon Dec 15 12:53:47 2008
Last mount time:          n/a
Last write time:          Wed Dec 31 23:15:43 2008
Mount count:              0
Maximum mount count:      23
Last checked:             Sun Dec 28 10:21:57 2008
Check interval:           15552000 (6 months)
Next check after:         Fri Jun 26 10:21:57 2009
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:               256
Required extra isize:     28
Desired extra isize:      28
Journal inode:            8
Default directory hash:   half_md4
Directory Hash Seed:      17e9c71d-5a16-47ad-b478-7c6bc3178f1d
Journal backup:           inode blocks
Journal size:             128M


Group 0: (Blocks 0-32767) [ITABLE_ZEROED]
  Checksum 0x5ca1, unused inodes 8181
  Primary superblock at 0, Group descriptors at 1-1
  Reserved GDT blocks at 2-512
  Block bitmap at 513 (+513), Inode bitmap at 529 (+529)
  Inode table at 545-1056 (+545)
  24025 free blocks, 8181 free inodes, 2 directories, 8181 unused inodes
  Free blocks: 8743-32767
  Free inodes: 12-8192
Group 1: (Blocks 32768-65535) [INODE_UNINIT, ITABLE_ZEROED]
  Checksum 0xa83d, unused inodes 8192
  Backup superblock at 32768, Group descriptors at 32769-32769
  Reserved GDT blocks at 32770-33280
  Block bitmap at 514, Inode bitmap at 530
  Inode table at 1057-1568
  32255 free blocks, 8192 free inodes, 0 directories, 8192 unused inodes
  Free blocks: 33281-65535
  Free inodes: 
...
Group 63: (Blocks 2064384-2096465) [INODE_UNINIT, ITABLE_ZEROED]
  Checksum 0x1f29, unused inodes 8192
  Block bitmap at 1572879, Inode bitmap at 1572895
  Inode table at 1580576-1581087
  32082 free blocks, 8192 free inodes, 0 directories, 8192 unused inodes
  Free blocks: 2064384-2096465
  Free inodes:
[编辑]

档案系统资讯

  • 档案系统 volume 名称 (Filesystem volume name) - 即是档案系统标签 (Filesystem label),用作简述该档案系统的用途或其储存数据。现时 GNU/Linux 都会用 USB 手指/IEEE1394 硬盘等可移除储存装置的档案系统标签作为其挂载目录的名称,方便使用者识别。而个别 GNU/Linux distribution 如 FedoraRHEL 和 CentOS 等亦在 fstab 取代传统装置档案名称 (即 /dev/sda1 和 /dev/hdc5 等) 的指定开机时要挂载的档案系统,避免偶然因为 BIOS 设定或插入次序的改变而引起的混乱。可以使用命令 e2label 或 tune2fs -L 改变。
  • 上一次挂载于 (Last mounted on)' - 上一次挂载档案系统的挂载点路径,此栏一般为空,很少使用。可以使用命令 tune2fs -M 设定。
  • 档案系统 UUID (Filesystem UUID) - 一个一般由乱数产生的识别码,可以用来识别档案系统。个别 GNU/Linux distribution 如 Ubuntu] 等亦在 fstab 取代传统装置档案名称 (即 /dev/sda1 和 /dev/hdc5 等) 的指定开机时要挂载的档案系统,避免偶然因为 BIOS 设定或插入次序的改变而引起的混乱。可以使用命令 tune2fs -U 改变。
  • (Filesystem magic number) - 用来识别此档案系统为 Ext2/Ext3/Ext4 的签名,位置在档案系统的 0x0438 - 0x0439 (Superblock 的 0x38-0x39),现时必定是 0xEF53。
  • 档案系统版本编号 (Filesystem revision #) - 档案系统微版本编号,只可以在格式化时使用 mke2fs -r 设定。现在只支援[1]
    • 0 - 原始格式,Linux 1.2 或以前只支援此格式[2]
    • 1 (dymanic) - V2 格式支援动态 inode 大小 (现时一般都使用此版本)
  • 档案系统功能 (Filesystem features) - 开启了的档案系统功能,可以使用合令 tune2fs -O 改变。现在可以有以下功能:
    • has_journal - 有日志 (journal),亦代表此档案系统必为 Ext3 或 Ext4
    • ext_attr - 支援 extended attribute
    • resize_inode - resize2fs 可以加大档案系统大小
    • dir_index - 支援目录索引,可以加快在大目录中搜索档案。(ext3 ,ext4 支持,ext2 不支持)
    • filetype - 目录项目为否记录档案类型
    • needs_recovery - e2fsck 检查 Ext3/Ext4 档案系统时用来决定是否需要完成日志纪录中未完成的工作,快速自动修复档案系统
    • extent - 支援 Ext4 extent 功能,可以加快档案系系效能和减少 external fragmentation,使用bigalloc 的则必须enable extent
    • flex_bgallows the per-block group metadata (allocation bitmaps and inode tables) to be placed anywhere on the storage ,In addition, mke2fs will place the per-block group metadata together starting at the first block group of each  "flex_bg group" ,The size of the flex_bg group can be specified using the -G option.
    • sparse_super - 只有少数 superblock 备份,而不是每个区块组都有 superblock 备份,节省空间。
    • large_file - 支援大于 2GiB 的档案
    • huge_file - allows files to be larger than 2 terabytes in size
    • uninit_bg - ext4  file system feature indicates that the block group descriptors will be protected using checksums,making it safe for mke2fs(8) to create a file system without initializing all of the block groups.  The kernel will keep a high watermark of unused inodes, and initialize inode tables and block lazily.  This feature speeds up the time to check the file system using e2fsck(8), and it also speeds up the time required for mke2fs(8) to create the file system.
    • dir_nlink - 每个目录支持65000以上的目录数量
    • extra_isize -  reserves a specific amount of space in each inode for extended metadata such as nanosecond timestamps and file creation time,inode size must be 256 bytes in size or larger

    • 下面的则不是dumpe2fs -h 输出的,而是我在man ext4里面看到的

    • bigalloc -  enables clustered block allocation, so that the unit of allocation is a power of two number of blocks.  That is, each bit in the what had traditionally been known as the block allocation bitmap now indicates whether a cluster is in use or not, where a cluster is by  default  composed  of  16  blocks.  This feature can decrease the time spent on doing block allocation and brings smaller fragmentation,especially for large files.  The size can be specified using the mke2fs -C option.
    • encrypt - This  ext4  feature  provides  file-system  level  encryption  of  data  blocks  and file names.  The inode metadata (timestamps, file size, user/group ownership, etc.) is not encrypted.This feature is most useful on file systems with multiple users, or where not all files should be encrypted.  In many use cases,  especially on single-user systems, encryption at the block device layer using dm-crypt may provide much better security.
    • journal_dev - This feature is enabled on the superblock found on an external journal device.  The block size for the external journal must be the same as the file system which uses it.
      The external journal device can be used by a file system by specifying the -J device= option to mke2fs(8) or tune2fs(8).
    • mmp - This ext4 feature provides multiple mount protection (MMP).  MMP helps to protect the filesystem from being multiply mounted and is useful in shared storage environments 
    • project - This ext4 feature provides project quota support. With this feature, the project ID of inode will be managed when the filesystem is mounted.
    • meta_bg - This ext4 feature allows file systems to be resized on-line without explicitly needing to reserve space for growth in the size of the  block group descriptors.  This scheme is also used to resize file systems which are larger than 2^32 blocks.  It is not recommended that this fea ture be set when a file system is created, since this alternate method of storing the block group descriptors will slow down the time needed to mount the file system, and newer kernels can automatically set this feature as necessary when doing an online resize and no more reserved space is available in the resize inode
    • sparse_super2 - This feature indicates that there will only be at most two backup superblocks and block group descriptors.  The block groups used to store the  backup  superblock(s) and blockgroup descriptor(s) are stored in the superblock, but typically, one will be located at the beginning of block group #1, and one in the last block group in the file system.  This feature is essentially a more extreme version of sparse_super and is designed to allow a much larger percentage of the disk to have contiguous blocks available for data files.
    • inline_data -  Allow data to be stored in the inode and extended attribute area

  • 档案系统旗号 (Filesystem flags) - signed_directory_hash
  • 缺省挂载选项 (Default mount options) - 挂载此档案系统缺省会使用的选项
  • 档案系统状态 (Filesystem state) - 可以为 clean (档案系统已成功地被卸载)、not-clean (表示档案系统挂载成读写模式后,仍未被卸载) 或 erroneous (档案系统被发现有问题)
  • 错误处理方案 (Errors behavior) - 档案系统发生问题时的处理方案,可以为 continue (继续正常运作) 、remount-ro (重新挂载成只读模式) 或 panic (即时当掉系统)。可以使用 tune2fs -e 改变。
  • 作业系统类型 (Filesystem OS type) - 建立档案系统的作业系统,可以为 Linux/Hurd/MASIX/FreeBSD/Lites[1]
  • Inode 数目 (Inode count) - 档案系统的总 inode 数目,亦是整个档案系统所可能拥有档案数目的上限
  • 区块数目 (Block count) - 档案系统的总区块数目
  • 保留区块数目 (Reserved block count) - 保留给系统管理员工作之用的区块数目
  • 未使用区块数目 (Free blocks) - 未使用区块数目
  • 未使用 inode 数目 (Free inodes) - 未使用 inode 数目
  • 第一个区块编数 (First block) - Superblock 或第一个区块组开始的区块编数。此值在 1 KiB 区块大小的档案系统为 1,大于1 KiB 区块大小的档案系统为 0。(Superblock/第一个区块组一般都在档案系统 0x0400 (1024) 开始)[1]
  • 区块大小 (Block size) - 区块大小,可以为 1024, 2048 或 4096 字节 (Compaq Alpha 系统可以使用 8192 字节的区块)
  • Fragment 大小 (Fragment size) - 实际上 Ext2/Ext3/Ext4 未有支援 Fragment,所以此值一般和区块大小一样
  • 保留 GDT 区块数目 (Reserved GDT blocks) - 保留作在线 (online) 改变档案系统大小的区块数目。若此值为 0,只可以先卸载才可脱机改变档案系统大小[3]
  • 区块/组 (Blocks per group) - 每个区块组的区块数目
  • Fragments/组 (Fragments per group) - 每个区块组的 fragment 数目,亦用来计算每个区块组中 block bitmap 的大小
  • Inodes/组 (Inodes per group) - 每个区块组的 inode 数目
  • Inode 区块/组 (Inode blocks per group) - 每个区块组的 inode 区块数目
  • (Flex block group size) - 16
  • 档案系统建立时间 (Filesystem created) - 格式化此档案系统的时间
  • 最后挂载时间 (Last mount time) - 上一次挂载此档案系统的时间
  • 最后改动时间 (Last write time) - 上一次改变此档案系统内容的时间
  • 挂载次数 (Mount count) - 距上一次作完整档案系统检查后档案系统被挂载的次数,让 fsck 决定是否应进行另一次完整档案系统检查
  • 最大挂载次数 (Maximum mount count) - 档案系统进行另一次完整检查可以被挂载的次数,若挂载次数 (Mount count) 大于此值,fsck 会进行另一次完整档案系统检查
  • 最后检查时间 (Last checked) - 上一次档案系统作完整检查的时间
  • 检查间距 (Check interval) - 档案系统应该进行另一次完整检查的最大时间距
  • 下次检查时间 (Next check after) - 下一次档案系统应该进行另一次完整检查的时间
  • 保留区块使用者识别码 (Reserved blocks uid) - 0 (user root)
  • 保留区块群组识别码 (Reserved blocks gid) - 0 (group root)
  • 第一个 inode (First inode) - 第一个可以用作存放正常档案属性的 inode 编号,在原格式此值一定为 11, V2 格式亦可以改变此值[1]
  • Inode 大小 (Inode size) - Inode 大小,传统为 128 字节,新系统会使用 256 字节的 inode 令扩充功能更方便
  • (Required extra isize) - 28
  • (Desired extra isize) - 28
  • 日志 inode (Journal inode) - 日志档案的 inode 编号
  • 缺省目录 hash 算法 (Default directory hash) - half_md4
  • 目录 hash 种子 (Directory Hash Seed) - 17e9c71d-5a16-47ad-b478-7c6bc3178f1d
  • 日志备份 (Journal backup) - inode blocks
  • 日志大小 (Journal size) - 日志档案的大小

参考资料:



阅读(3835) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~