应用环境:
Linux OS - Version: 1.2 to 1.6
Linux x86
Linux x86-64
解决方案:
许多已经存在的工具可以完成需要的工作:
- debugfs.ocfs2
- ocfs2console
- fsck.ocfs2
以下示例都是在Enterprise Linux 5 system
1、debugfs.ocfs2
debugfs.ocfs2(8) command ,这个工具是在ocfs2-tool包内提供的基于EL4/EL5,可以用此工具来确定OCFS2的文件系统
# uname -a
Linux piston 2.6.18-194.3.1.0.1.el5 #1 SMP Thu May 6 19:58:50 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
# cat /etc/[e,r]*-release
Enterprise Linux Enterprise Linux Server release 5.5 (Carthage)
Red Hat Enterprise Linux Server release 5.5 (Tikanga)
# rpm -qa|grep -i ocfs2 | sort
ocfs2-2.6.18-194.3.1.0.1.el5-1.4.7-1.el5
ocfs2console-1.4.4-1.el5
ocfs2-tools-1.4.4-1.el5
# mounted.ocfs2 -d
Device FS Stack UUID Label
/dev/sda1 ocfs2 o2cb 3D7CDDE446A14D59BD0B24A21DB20958 ocfs1
# mounted.ocfs2 -f
Device FS Nodes
/dev/sda1 ocfs2 piston
# echo stats | debugfs.ocfs2 /dev/sdb1 | grep -i 'size bits'
debugfs.ocfs2 1.4.4
Block Size Bits: 12 Cluster Size Bits: 18
以上只是报告的BLOCK和Cluseter的bits位,可以通过以下表格对应起实际的大小:
Block Size Bits | Bytes |
---|---|
9 | 512 (min.) |
10 | 1024 |
11 | 2048 |
12 | 4096 (max.) |
Cluster Size Bits | Bytes |
---|---|
12 | 4096 (min.) |
13 | 8192 |
14 | 16384 |
15 | 32768 |
16 | 65536 |
17 | 131072 |
18 | 262144 |
19 | 524288 |
20 | 1048576 (max.) |
说明:
以上debugocfs(1)命令可以安全的运行;
2、ocfs2console
ocfs2console(1)是一个图形界面的工具,所以你要运行这个工具在一个OCFS2的环境中,并且是一个graphical mode(x-windows)
执行ocfs2console(1)命令以加载OCFS2控制台
在弹出的控制台里选择device,列出OCFS2文件系统
里面就会显示出相应的CLUSTER和BLOCK大小
3、fsck.ocfs2
fsck.ocfs2(8)工具可以在不挂载的OCFS2系统文件或者是以只读模式打开的文件系统
# umount /media/ocfs2
# mounted.ocfs2 -f | grep sda1
/dev/sda1 ocfs2 Not mounted
# fsck.ocfs2 -vfn /dev/sda1 | more
fsck.ocfs2 1.4.4
Checking OCFS2 filesystem in /dev/loop2:
Label: ocfs1
UUID: 1E9FC543718240F7B3A97E515C830BD2
Number of blocks: 28160
Block size: 4096
Number of clusters: 440
Cluster size: 262144
Number of slots: 2
...
^C