文件查找: 在文件系统上查找符合条件的文件
文件查找:locate、find 非实时查找(数据库查找)locate 实时查找 find
locate 依赖于事先构建的索引:索引的构建是在系统较为空闲时自动进行(周期性任务)手动更新数据库(updatedb) 索引构建过程需要遍历整个根文件系统,极其消耗资源
工作特点 查找速度快、模糊查找、非实时查找
命令语法 locate keyword
find 实时查找工具,通过遍历指定路径下的文件系统完成文件查找
工作特点 查找速度略慢、精确查找、实时查找
命令语法 find [option]… [查找路径] [查找条件] [处理动作] 查找路径:指定具体目标路径,默认为当前目录 查找条件:指定的查找标准,可以为文件名、大小、类型、权限等标准进行,默认为找出指定路径下的所有文件 处理动作:对符合条件的文件做什么操作,默认输出屏幕
查找条件: 根据文件名查找: -name “文件名称” 支持使用glob 字符通配 * ? [] [^] [root@localhost ~]# find /etc -name fstab /etc/fstab
-name “文件名称” 不区分字母大小写 [root@localhost ~]# find /tmp -iname abc /tmp/abc /tmp/ABC
-regex “pattern” 以pattern匹配整个文件路径字符串,而不仅仅是文件名称
根据属主、属组查找: -user username 查找属主为指定用户的文件 [root@localhost ~]# find /tmp -user curry /tmp/curry
-group grpname 查找属组为指定组的文件 [root@localhost ~]# find /tmp -group curry /tmp/curry
-uid userid 查找属主为指定的uid号的文件 [root@localhost ~]# find /tmp -uid 505 /tmp/curry
-gid groupid 查找属组为指定到的gid号的文件 [root@localhost ~]# find /tmp -gid 505 /tmp/curry
-nouser 查找没有属主的文件 [root@localhost ~]# find /tmp -nouser /tmp/curry
-nogroup 查找没有属组的文件 [root@localhost ~]# find /tmp -nogroup /tmp/curry
根据文件类型查找: -type TYPE f 普通文件 [root@localhost ~]# find /tmp -type f /tmp/yum.log
d 目录文件 [root@localhost ~]# find /tmp -type d /tmp
l 符号链接文件 [root@localhost ~]# find /etc -type l /etc/pki/tls/cert.pem
s 套接字文件 [root@localhost ~]# find /dev -type s /dev/log
b 块设备文件 [root@localhost ~]# find /dev -type b /dev/ram7
c 字符设备文件 [root@localhost ~]# find /dev -type c /dev/vcsa6
p 管道文件 [root@localhost ~]# find /var -type p /var/spool/postfix/public/pickup
组合条件: 与 –a [root@localhost ~]# find /tmp -user root -a -type f /tmp/yum.log
或 –o [root@localhost ~]# find /tmp -type d -o -type f /tmp /tmp/yum.log
非 –not ! [root@localhost ~]# find /tmp -not -type d /tmp/yum.log /tmp/curry/.bash_profile /tmp/curry/.bashrc /tmp/curry/.bash_logout
[root@localhost ~]# find /tmp ! -type d /tmp/yum.log /tmp/curry/.bash_profile /tmp/curry/.bashrc /tmp/curry/.bash_logout
!a –a !b=!(a –o b) [root@localhost ~]# find /boot -not -type d -a -not -type f /boot/grub/menu.lst
[root@localhost ~]# find /boot -not ( -type d -o -type f ) /boot/grub/menu.lst
!a –o !b=!(a –a b) [root@localhost ~]# find /tmp -not -type d -o -not -type f /tmp /tmp/yum.log
[root@localhost ~]# find /tmp -not ( -type d -a -type f ) /tmp /tmp/yum.log
找出/tmp目录下,属主不是root,且文件名不是fstab的文件 find /tmp –not –user root –a –not –name ‘fstab’ –ls find /tmp –not ( -user root –o –name ‘fstab’ ) –ls
根据文件大小来查找: -size [+|-]#unit 常用单位 K M G
#unit (#-1,#] [root@localhost ~]# find /etc/sysconfig -size 4k /etc/sysconfig /etc/sysconfig/rhn [root@localhost ~]# ll -dh /etc/sysconfig/ drwxr-xr-x. 8 root root 4.0K Apr 11 08:51 /etc/sysconfig/ [root@localhost ~]# ll -dh /etc/sysconfig/rhn drwxr-xr-x. 4 root root 4.0K Apr 11 08:50 /etc/sysconfig/rhn
[root@localhost ~]# find /dev -size 4k /dev /dev/.udev/db [root@localhost ~]# ll -dh /dev drwxr-xr-x. 17 root root 3.7K May 15 16:27 /dev [root@localhost ~]# ll -dh /dev/.udev/db drwxr-xr-x. 2 root root 3.5K May 15 15:21 /dev/.udev/db
-#unit [0 ,#-1] [root@localhost ~]# find /etc/sysconfig -size -4k /etc/sysconfig/auditd /etc/sysconfig/rsyslog [root@localhost ~]# ll -h /etc/sysconfig/auditd -rw-r-----. 1 root root 646 Jan 14 2010 /etc/sysconfig/auditd [root@localhost ~]# ll -h /etc/sysconfig/rsyslog -rw-r--r--. 1 root root 163 Jul 17 2009 /etc/sysconfig/rsyslog
+#unit (#,00) [root@localhost ~]# find /etc/sysconfig -size +4k /etc/sysconfig/network-scripts/network-functions /etc/sysconfig/network-scripts/ifup-ipv6 [root@localhost ~]# ll -h /etc/sysconfig/network-scripts/network-functions -rw-r--r--. 1 root root 9.8K Sep 1 2010 /etc/sysconfig/network-scripts/network-functions [root@localhost ~]# ll -h /etc/sysconfig/network-scripts/ifup-ipv6 -rwxr-xr-x. 1 root root 11K Sep 1 2010 /etc/sysconfig/network-scripts/ifup-ipv6
根据时间戳查找: 以天为时间 -atime [+|-]#
[#,#+1)
[root@localhost ~]# find /etc -atime 1 /etc/logrotate.d/yum [root@localhost ~]# date Tue May 15 16:40:05 CST 2018 [root@localhost ~]# stat /etc/logrotate.d/yum | grep "Access" Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2018-05-14 15:11:02.117301822 +0800
+# [#+1,00) [root@localhost ~]# find /etc -atime +10 /etc/filesystems [root@localhost ~]# date Tue May 15 16:42:48 CST 2018 [root@localhost ~]# stat /etc/filesystems | grep "Access" Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2013-10-02 17:06:18.000000000 +0800
-# [0,#) [root@localhost ~]# find /etc -atime -1 /etc [root@localhost ~]# date Tue May 15 16:44:09 CST 2018 [root@localhost ~]# stat /etc | grep "Access" Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2018-05-15 16:37:45.580611733 +0800
-mtime -ctime
以分钟为单位 -amin -mmin -cmin
根据权限查找 -perm [/|-]mode mode 精确权限匹配 [root@localhost ~]# find /tmp -perm 644 /tmp/test.txt
/mode 任何一类(u g o)对象的权限中只要有一位能匹配即可 [root@localhost ~]# find /tmp -perm /111 -ls 784897 4 drwxrwxrwt 6 root root 4096 May 15 16:47 /tmp
-mode 每一类对象都必须同时拥有为其指定的权限标准 [root@localhost ~]# find /tmp -perm -111 -ls 784897 4 drwxrwxrwt 6 root root 4096 May 15 16:47 /tmp
处理动作 -print 默认的处理动作,显示至屏幕 [root@localhost ~]# find /etc -name 'fstab' -print /etc/fstab
-ls 类似于对查找到的文件执行”ls -l”命令 [root@localhost ~]# find /etc -name 'fstab' -ls 654087 4 -rw-r--r-- 1 root root 779 Apr 11 08:49 /etc/fstab
-delete 删除查找到的文件 [root@localhost ~]# find /tmp -name 'fstab' –delete
-fls /path/to/somefile 查找到的所有文件的长格式信息保存到指定文件中,覆盖重定向写入该文件 [root@localhost ~]# find /etc -name 'fstab' -fls /tmp/tom [root@localhost ~]# cat /tmp/tom 654087 4 -rw-r--r-- 1 root root 779 Apr 11 08:49 /etc/fstab
-ok command {} ; 对查找到的每个文件执行由command指定的命令;对于每个文件执行命令之前,都会交互式要求用户确认; [root@localhost ~]# find /etc -name 'issue' -ok ls {} ; < ls ... /etc/issue > ? y /etc/issue [root@localhost ~]# find /etc -name 'issue' -ok ls -l {} ; < ls ... /etc/issue > ? y -rw-r--r--. 1 root root 75 Sep 3 2010 /etc/issue
-exec command {} ; 对查找到的每个文件执行由command指定的命令;{} 用于引用查找到的文件名称自身 [root@localhost ~]# find /etc -name 'issue' -exec ls {} ; /etc/issue [root@localhost ~]# find /etc -name 'issue' -exec ls -l {} ; -rw-r--r--. 1 root root 75 Sep 3 2010 /etc/issue
注意find传递查找到的文件至后面指定的命令时,查找到所有符合条件的文件一次性传递给后面的命令;有些命令不能接受过多参数,此时命令执行可能会失败,另一种方式可规避此问题; find | xargs command [root@localhost ~]# find /etc -name 'issue' | xargs ls /etc/issue [root@localhost ~]# find /etc -name 'issue' | xargs ls -l -rw-r--r--. 1 root root 75 Sep 3 2010 /etc/issue
练习: 1、 查找/var目录下属主为root,且属组为mail的所有文件或目录; [root@localhost ~]# find /var -user root -group mail -ls 523542 4 drwxrwxr-x 2 root mail 4096 Apr 12 19:44 /var/spool/mail
2、 查找/usr目录下不属于root、bin或hadoop的所有文件或目录 find /usr -not -user root -a -not -user bin -a -not -user hadoop –ls find /usr -not ( -user root -o -user bin -o -user hadoop ) –ls
3、 查找/etc目录下最近一周内其内容修改过,同时属组不为root,也不是hadoop的文件或目录 find /etc -mtime 7 -not -group root -a -not -group hadoop –ls find /etc -mtime 7 -not ( -group root -o -group hadoop ) –ls
4、 查找当前系统上没有属主或属组,且最近一周内曾被访问过的文件或目录 find / -nouser -a -nogroup -atime 7 –ls
5、 查找/etc目录下大于1M且类型为普通文件的所有文件 find /etc -size +1M -type d –ls
6、 查找/etc目录下所有用户都没有写权限的文件 [root@localhost ~]# find /etc -not -perm /222 -ls 654662 4 -r--r----- 1 root root 3502 Aug 3 2010 /etc/sudoers
7、 查找/etc目录下至少有一类用户没有执行权限的文件 [root@localhost ~]# find /etc -not -perm -111 -ls 654311 4 drwx------ 2 root root 4096 Jun 30 2010 /etc/pki/CA/private
8、 查找/etc/init.d目录下,所有用户都有执行权限,且其他用户有写权限的文件 find /etc/init.d -perm 113 linux文件系统上的特殊权限 suid、sgid、sticky
1、 权限 r、w、x user、group、other
2、 安全上下文 前提:进程有属主和属组,文件有属主和属组 (1) 任何一个可执行程序文件能不能启动为进程,取决发起者对程序文件是否拥有执行权限 (2) 启动为进程后,其进程的属主为发起者,进程的属组为发起者所属的组 (3) 进程访问文件的权限,取决于进程的发起者 (a) 进程的发起者,同文件的属主,则应用文件属主权限 (b) 进程的发起者,属于文件的属组,则应用文件属组权限 (c) 应用文件”其他”权限
3、 suid (1) 任何一个可执行程序文件能不能启动为进程,取决发起者对程序文件是否拥有执行权限 (2) 启动为进程之后,其进程的属主为原程序文件的属主
权限设定: chmod u+s file… [root@localhost ~]# chmod u+s /tmp/123 [root@localhost ~]# ll /tmp/123 -rwsrwxrwx. 1 root root 86 May 14 16:23 /tmp/123
chmod u-s file… [root@localhost ~]# chmod u-s /tmp/123 [root@localhost ~]# ll /tmp/123 -rwxrwxrwx. 1 root root 86 May 14 16:23 /tmp/123
4、 sgid 默认情况下,用户创建文件时,其属组为此用户所属的基本组; 一旦某目录被设定了sgid,则对此目录有写权限的用户在此目录中创建的文件所属的组为此目录的属组;
权限设定: chmod g+s dir… [root@localhost ~]# chmod g+s /tmp/mydir [root@localhost ~]# ll -d /tmp/mydir drwxr-sr-x. 2 root root 4096 May 15 14:39 /tmp/mydir
chmod g-s dir… [root@localhost ~]# chmod g-s /tmp/mydir [root@localhost ~]# ll -d /tmp/mydir drwxr-xr-x. 2 root root 4096 May 15 14:39 /tmp/mydir
5、 sticky 对于一个多人可写的目录,如果设置了sticky,则每个用户仅能删除自己的文件
权限设定: chmod o+t dir… [root@localhost ~]# chmod o+t /tmp/mydir [root@localhost ~]# ll -d /tmp/mydir drwxr-xr-t. 2 root root 4096 May 15 14:39 /tmp/mydir
chmod o-t dir… [root@localhost ~]# ll -d /tmp/mydir drwxr-xr-x. 2 root root 4096 May 15 14:39 /tmp/mydir suid sgid sticky
二进制 八进制 000 0 001 1 010 2 011 3 100 4 101 5 110 6 111 7
chmod 4777 /tmp/a.txt
几个权限位映射 suid user 占据属主的执行权限位 s 属主拥有x权限 [root@localhost ~]# ll /tmp/123 -rwxrwxrwx. 1 root root 86 May 14 16:23 /tmp/123 [root@localhost ~]# chmod u+s /tmp/123 [root@localhost ~]# ll /tmp/123 -rwsrwxrwx. 1 root root 86 May 14 16:23 /tmp/123
S 属主没有x权限 [root@localhost ~]# ll /tmp/123 -rw-rwxrwx. 1 root root 86 May 14 16:23 /tmp/123 [root@localhost ~]# chmod u+s /tmp/123 [root@localhost ~]# ll /tmp/123 -rwSrwxrwx. 1 root root 86 May 14 16:23 /tmp/123
sgid group 占据属组的执行权限位 s 属组拥有x权限 [root@localhost ~]# ll -d /tmp/mydir drwxr-xr-x. 2 root root 4096 May 15 14:39 /tmp/mydir [root@localhost ~]# chmod g+s /tmp/mydir [root@localhost ~]# ll -d /tmp/mydir drwxr-sr-x. 2 root root 4096 May 15 14:39 /tmp/mydir
S 属组没有x权限 [root@localhost ~]# ll -d /tmp/mydir drwxr--r-x. 2 root root 4096 May 15 14:39 /tmp/mydir [root@localhost ~]# chmod g+s /tmp/mydir [root@localhost ~]# ll -d /tmp/mydir drwxr-Sr-x. 2 root root 4096 May 15 14:39 /tmp/mydir
sticky other 占据other的执行权限位 t other拥有x权限 [root@localhost ~]# ll -d /tmp/mydir drwxr-xr-x. 2 root root 4096 May 15 14:39 /tmp/mydir [root@localhost ~]# chmod o+t /tmp/mydir [root@localhost ~]# ll -d /tmp/mydir drwxr-xr-t. 2 root root 4096 May 15 14:39 /tmp/mydir
T other 没有x权限 [root@localhost ~]# ll -d /tmp/mydir drwxr-xr--. 2 root root 4096 May 15 14:39 /tmp/mydir [root@localhost ~]# chmod o+t /tmp/mydir [root@localhost ~]# ll -d /tmp/mydir drwxr-xr-T. 2 root root 4096 May 15 14:39 /tmp/mydir
bash 脚本编程 过程式编程语言 顺序执行 选择执行 循环执行
选择执行 If 判断条件;then 条件为真的分支代码 fi [root@localhost ~]# cat /tmp/if.sh #!/bin/bash if id root &> /dev/null;then echo "user exist." fi [root@localhost ~]# bash /tmp/if.sh user exist.
if 判断条件;then 条件为真的分支代码 else 条件为假的分支代码 fi [root@localhost ~]# cat /tmp/if.sh #!/bin/bash if id abc &> /dev/null;then echo "user exist." else echo "user not exist." fi [root@localhost ~]# bash /tmp/if.sh user not exist.
linux 磁盘管理 I/O ports I/O 设备地址 一切皆文件 open() read() write() close()
块设备 block 存取单位”块” 磁盘 字符设备 char 存取单位”字符” 键盘 [root@localhost ~]# ll /dev | grep "^[bc]" crw-rw----. 1 root root 10, 62 May 17 19:59 crash brw-rw----. 1 root disk 253, 0 May 17 19:59 dm-0
设备文件 关联至一个设备驱动程序,进而能够跟与之对应硬件设备进行通信
设备号码 主设备号 major number 标识设备类型 次设备号 minor number 标识同一类型下的不同设备 [root@localhost ~]# ll /dev | grep "^[bc]" crw-rw----. 1 root video 10, 175 May 16 21:04 agpgart brw-rw----. 1 root disk 253, 0 May 16 21:04 dm-0
[root@localhost ~]# cat /proc/partitions major minor #blocks name
8 0 20971520 sda 8 1 512000 sda1 8 2 20458496 sda2 8 16 20971520 sdb 8 17 1060258 sdb1 8 18 2104515 sdb2 253 0 19472384 dm-0 253 1 983040 dm-1
硬盘接口类型 并行接口 ide 速率 133MB/s scsi 速率 640MB/s
串行接口 sata 速率 6Gbps sas 速率 6Gbps usb 速率 480MB/s
rpm:rotations per minute 每分钟转速
/dev/dev_file 磁盘设备的设备文件命名
ide /dev/hd scsi stat sas usb /dev/sd 不同设备:a-z /dev/sda,/dev/sdb… 不同设备上的不同分区1,2 /dev/sda1,/dev/sda5…
机械式硬盘 track 磁道 cylinder 柱面 sector 扇区
如何分区 按柱面进行分区
0磁盘0扇区 512bytes mbr master boot record 主引导记录 446bytes boot loader 引导加载器 64bytes 分区表 16bytes 标识一个分区 2bytes mbr有效性标识
4个主分区 3个主分区+1个扩展分区(内含多个逻辑分区)
问题:UEFI、GPT
分区管理工具 fdisk parted sfdisk fdisk 对于一块硬盘来讲,最多只能管理15个分区 [root@localhost ~]# fdisk -l
Disk /dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0001e741
Device Boot Start End Blocks Id System /dev/sda1 * 1 64 512000 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 64 2611 20458496 8e Linux LVM
Disk /dev/sdb: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0c5b3623
Device Boot Start End Blocks Id System /dev/sdb1 1 132 1060258+ 83 Linux /dev/sdb2 133 394 2104515 83 Linux
Disk /dev/mapper/VolGroup-lv_root: 19.9 GB, 19939721216 bytes 255 heads, 63 sectors/track, 2424 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000
Disk /dev/mapper/VolGroup-lv_swap: 1006 MB, 1006632960 bytes 255 heads, 63 sectors/track, 122 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000
[root@localhost ~]# fdisk -l /dev/sdb
Disk /dev/sdb: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0c5b3623
Device Boot Start End Blocks Id System /dev/sdb1 1 132 1060258+ 83 Linux /dev/sdb2 133 394 2104515 83 Linux
fdisk device 子命令:管理功能 p print 显示已有分区 p print the partition table Command (m for help): p
Disk /dev/sdb: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0c5b3623
Device Boot Start End Blocks Id System /dev/sdb1 1 132 1060258+ 83 Linux /dev/sdb2 133 394 2104515 83 Linux
n new 创建分区 n add a new partition Command (m for help): n Command action e extended p primary partition (1-4)
d delete 删除分区 d delete a partition
Command (m for help): d
Partition number (1-4):
w write 写入磁盘并退出 w write table to disk and exit
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table. Syncing disks.
q quit 放弃更新并退出 q quit without saving changes
Command (m for help): q
m 获取帮助 m print this menu
Command (m for help): m
Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only)
l 列出所有分区id l list known partition types
Command (m for help): l
0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris
1 FAT12 39 Plan 9 82 Linux swap / So c1 DRDOS/sec (FAT-
2 XENIX root 3c PartitionMagic 83 Linux c4 DRDOS/sec (FAT-
3 XENIX usr 40 Venix 80286 84 OS/2 hidden C: c6 DRDOS/sec (FAT-
4 FAT16 <32M 41 PPC PReP Boot 85 Linux extended c7 Syrinx
5 Extended 42 SFS 86 NTFS volume set da Non-FS data
6 FAT16 4d QNX4.x 87 NTFS volume set db CP/M / CTOS / .
7 HPFS/NTFS 4e QNX4.x 2nd part 88 Linux plaintext de Dell Utility
8 AIX 4f QNX4.x 3rd part 8e Linux LVM df BootIt
9 AIX bootable 50 OnTrack DM 93 Amoeba e1 DOS access
a OS/2 Boot Manag 51 OnTrack DM6 Aux 94 Amoeba BBT e3 DOS R/O
b W95 FAT32 52 CP/M 9f BSD/OS e4 SpeedStor
c W95 FAT32 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi eb BeOS fs
e W95 FAT16 (LBA) 54 OnTrackDM6 a5 FreeBSD ee GPT
f W95 Ext'd (LBA) 55 EZ-Drive a6 OpenBSD ef EFI (FAT-12/16/
10 OPUS 56 Golden Bow a7 NeXTSTEP f0 Linux/PA-RISC b
11 Hidden FAT12 5c Priam Edisk a8 Darwin UFS f1 SpeedStor
12 Compaq diagnost 61 SpeedStor a9 NetBSD f4 SpeedStor
14 Hidden FAT16 <3 63 GNU HURD or Sys ab Darwin boot f2 DOS secondary
16 Hidden FAT16 64 Novell Netware af HFS / HFS+ fb VMware VMFS
17 Hidden HPFS/NTF 65 Novell Netware b7 BSDI fs fc VMware VMKCORE
18 AST SmartSleep 70 DiskSecure Mult b8 BSDI swap fd Linux raid auto
1b Hidden W95 FAT3 75 PC/IX bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 80 Old Minix be Solaris boot ff BBT
1e Hidden W95 FAT1
t 调整分区id t change a partition's system id
Command (m for help): t
Partition number (1-4): 1 Hex code (type L to list codes): 82 Changed system type of partition 1 to 82 (Linux swap / Solaris) 查看内核是否已经识别新的分区 cat /proc/partations [root@localhost ~]# cat /proc/partitions major minor #blocks name
8 0 20971520 sda 8 1 512000 sda1 8 2 20458496 sda2 8 16 20971520 sdb 8 17 1060258 sdb1 8 18 2104515 sdb2 8 19 3156772 sdb3 253 0 19472384 dm-0 253 1 983040 dm-1
通知内核重新读取硬盘分区表 partx –a /dev/device [root@localhost ~]# partx -a /dev/sdb BLKPG: Device or resource busy error adding partition 1 BLKPG: Device or resource busy error adding partition 2 BLKPG: Device or resource busy error adding partition 3
partx –n M:N /dev/device [root@localhost ~]# partx -n 1:3 /dev/sdb
1: 63- 2120579 ( 2120517 sectors, 1085 MB)
2: 2120580- 6329609 ( 4209030 sectors, 2155 MB)
3: 6329610- 12643154 ( 6313545 sectors, 3232 MB)
4: 0- -1 ( 0 sectors, 0 MB)
kpartx –a /dev/device [root@localhost ~]# kpartx -a /dev/sdb
kpartx –f /dev/device [root@localhost ~]# kpartx -f /dev/sdb sdb1 : 0 2120517 /dev/sdb 63 sdb2 : 0 4209030 /dev/sdb 2120580
centos 5 使用partprobe partprobe [dev/device]
linux文件系统管理 linux文件系统 ext2 ext3 ext4 xfs btrfs reiserfs swap 交换分区 虚拟内存 iso9660 光盘分区
windows fat32 ntfs unix ffs ufs jfs2 网络文件系统 nfs cifs 集群文件系统 gfs2 ocfs2 分布式文件系统 ceph moosefs mogilefs glusterfs lustre
根据其是否支持”journal”功能 日志型文件系统 ext3 ext4 xfs… 非日志型文件系统 ext2 vfat
文件系统的组成部分 内核中的模块 ext4 xfs vfat 用户空间的管理工具 mkfs.ext4 mkfs.xfs mkfs.vfat
linux的虚拟文件系统 vfs
创建文件系统 mkfs命令 1、 mkfs.fs_type /dev/device ext4 xfs btrfs vfat [root@localhost ~]# mkfs.ext4 /dev/sdb2 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 131648 inodes, 526128 blocks 26306 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=541065216 17 block groups 32768 blocks per group, 32768 fragments per group 7744 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 33 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
2、 mkfs –t fs_type /dev/device -L ‘LABEL’ 设定卷标 [root@localhost ~]# mkfs -t ext4 -L mydata /dev/sdb2 mke2fs 1.41.12 (17-May-2010) Filesystem label=mydata OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 131648 inodes, 526128 blocks 26306 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=541065216 17 block groups 32768 blocks per group, 32768 fragments per group 7744 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 29 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
mke2fs ext系列文件系统专用管理用具 -t {ext2|ext3|ext4} 文件系统 [root@localhost ~]# mkfs -t ext2 /dev/sdb2 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 131648 inodes, 526128 blocks 26306 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=541065216 17 block groups 32768 blocks per group, 32768 fragments per group 7744 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 29 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
-b {1024|2048|4096} 数据块大小 [root@localhost ~]# mkfs -b 2048 /dev/sdb2 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=2048 (log=1) Fragment size=2048 (log=1) Stride=0 blocks, Stripe width=0 blocks 131560 inodes, 1052256 blocks 52612 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=538968064 65 block groups 16384 blocks per group, 16384 fragments per group 2024 inodes per group Superblock backups stored on blocks: 16384, 49152, 81920, 114688, 147456, 409600, 442368, 802816
Writing inode tables: 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.
-L ‘LABEL’ 设定卷标名 [root@localhost ~]# mkfs -L mydata2 /dev/sdb2 mke2fs 1.41.12 (17-May-2010) Filesystem label=mydata2 OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 131648 inodes, 526128 blocks 26306 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=541065216 17 block groups 32768 blocks per group, 32768 fragments per group 7744 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 39 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
-j 相当于 –t ext3 mkfs.ext3=mkfs –t ext3=mke2fs –j=mke2fs –t ext3 [root@localhost ~]# mkfs -j /dev/sdb2 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 131648 inodes, 526128 blocks 26306 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=541065216 17 block groups 32768 blocks per group, 32768 fragments per group 7744 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 31 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
-i # 为数据空间中每多少个字节创建一个inode;此大小不应该小于block的大小 [root@localhost ~]# mkfs -i 4096 /dev/sdb2 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 526320 inodes, 526128 blocks 26306 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=540801024 17 block groups 32752 blocks per group, 32752 fragments per group 30960 inodes per group Superblock backups stored on blocks: 32752, 98256, 163760, 229264, 294768
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 37 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
-N # 为数据空间创建创建多少个inode [root@localhost ~]# mkfs -N 1024 /dev/sdb2 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 1088 inodes, 526128 blocks 26306 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=541065216 17 block groups 32768 blocks per group, 32768 fragments per group 64 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 39 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
-m # 为管理人员预留的空间占据的百分比 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 131648 inodes, 526128 blocks 15783 blocks (3.00%) reserved for the super user First data block=0 Maximum filesystem blocks=541065216 17 block groups 32768 blocks per group, 32768 fragments per group 7744 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 23 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
-O FEATURE [,…] 启用指定特性 -O ^FEATURE 关闭指定特性 [root@localhost ~]# mke2fs -O has_journal /dev/sdb2 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 131648 inodes, 526128 blocks 26306 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=541065216 17 block groups 32768 blocks per group, 32768 fragments per group 7744 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 20 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
mkswap 创建交换分区 mkswap [option] device -L ‘LABEL’ 前提:调整其分区的ID为82 [root@localhost ~]# mkswap /dev/sdb1 Setting up swapspace version 1, size = 1060252 KiB no label, UUID=c8484109-4bb8-4704-8230-3e78fba11c83 [root@localhost ~]# blkid /dev/sdb1 /dev/sdb1: UUID="c8484109-4bb8-4704-8230-3e78fba11c83" TYPE="swap"
其他常用工具 blkid 块设备属性信息查看 blkid [option]…[device] [root@localhost ~]# blkid /dev/sdb2 /dev/sdb2: UUID="115aefb8-9765-47c4-becf-3b017cfc7024" TYPE="ext2" LABEL="mydata2"
-U UUID 根据指定的UUID来查找对应的设备
[root@localhost ~]# blkid -U '115aefb8-9765-47c4-becf-3b017cfc7024'
/dev/sdb2
-L LABEL 根据指定的LABEL 来查找对应的设备
[root@localhost ~]# blkid -L 'mydata2' /dev/sdb2
/dev/sdb2
e2label 管理ext系列文件系统的LABEL e2label device [LABEL] [root@localhost ~]# e2label /dev/sdb2 mydata1 [root@localhost ~]# blkid /dev/sdb2 /dev/sdb2: UUID="115aefb8-9765-47c4-becf-3b017cfc7024" TYPE="ext2" LABEL="mydata1"
tune2fs 重新设定ext系列系统可调整参数的值 -l 查看指定文件系统超级块信息 super block root@localhost ~]# tune2fs -l /dev/sdb2 tune2fs 1.41.12 (17-May-2010) Filesystem volume name: mydata1 Last mounted on: <not available> Filesystem UUID: 115aefb8-9765-47c4-becf-3b017cfc7024 Filesystem magic number: 0xEF53 Filesystem revision #: 1 (dynamic) Filesystem features: ext_attr resize_inode dir_index filetype spa Filesystem flags: signed_directory_hash Default mount options: (none) Filesystem state: clean Errors behavior: Continue Filesystem OS type: Linux Inode count: 131648 Block count: 526128 Reserved block count: 26306 Free blocks: 517080 Free inodes: 131637 First block: 0 Block size: 4096 Fragment size: 4096 Reserved GDT blocks: 128 Blocks per group: 32768 Fragments per group: 32768 Inodes per group: 7744 Inode blocks per group: 484 Filesystem created: Fri May 18 10:02:08 2018 Last mount time: n/a Last write time: Fri May 18 10:09:07 2018 Mount count: 0 Maximum mount count: 30 Last checked: Fri May 18 10:02:08 2018 Check interval: 15552000 (6 months) Next check after: Wed Nov 14 10:02:08 2018 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 Default directory hash: half_md4 Directory Hash Seed: 5764ea43-ae79-42fb-bb91-add61fe433bd
-L ‘LABEL’ 修改卷标 [root@localhost ~]# tune2fs -L mydata2 /dev/sdb2 tune2fs 1.41.12 (17-May-2010) [root@localhost ~]# blkid /dev/sdb2 /dev/sdb2: UUID="115aefb8-9765-47c4-becf-3b017cfc7024" TYPE="ext2" LABEL="mydata2"
-m # 修改预留给管理员的空间百分比 [root@localhost ~]# tune2fs -m 2 /dev/sdb2 tune2fs 1.41.12 (17-May-2010) Setting reserved blocks percentage to 2% (10522 blocks)
-j 将ext2升级为ext3 [root@localhost ~]# tune2fs -j /dev/sdb2 tune2fs 1.41.12 (17-May-2010) Creating journal inode: done This filesystem will be automatically checked every 30 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@localhost ~]# blkid /dev/sdb2 /dev/sdb2: LABEL="mydata2" UUID="115aefb8-9765-47c4-becf-3b017cfc7024" SEC_TYPE="ext2" TYPE="ext3"
-O 文件系统属性启用或禁用 ^表示禁用 [root@localhost ~]# tune2fs -O has_journal /dev/sdb2 tune2fs 1.41.12 (17-May-2010) [root@localhost ~]# tune2fs -O ^has_journal /dev/sdb2 tune2fs 1.41.12 (17-May-2010)
-o 调整文件系统的默认挂载选项 ^表示禁用 [root@localhost ~]# tune2fs -o acl /dev/sdb2 tune2fs 1.41.12 (17-May-2010) [root@localhost ~]# tune2fs -o ^acl /dev/sdb2 tune2fs 1.41.12 (17-May-2010)
-U UUID 修改UUID号 [root@localhost ~]# tune2fs -U '115aefb8-9765-47c4-becf-3b017cfc7025' /dev/sdb2 tune2fs 1.41.12 (17-May-2010)
dumpe2fs -h 查看超级块信息 [root@localhost ~]# dumpe2fs /dev/sdb2 dumpe2fs 1.41.12 (17-May-2010) Filesystem volume name: mydata2 Last mounted on: <not available> Filesystem UUID: 115aefb8-9765-47c4-becf-3b017cfc7025 Filesystem magic number: 0xEF53 Filesystem revision #: 1 (dynamic) Filesystem features: ext_attr resize_inode dir_index filetype sparse_super large_file Filesystem flags: signed_directory_hash Default mount options: (none) Filesystem state: clean Errors behavior: Continue Filesystem OS type: Linux Inode count: 131648 Block count: 526128 Reserved block count: 10522 Free blocks: 517080 Free inodes: 131637 First block: 0 Block size: 4096 Fragment size: 4096 Reserved GDT blocks: 128 Blocks per group: 32768 Fragments per group: 32768 Inodes per group: 7744 Inode blocks per group: 484 Filesystem created: Fri May 18 10:02:08 2018 Last mount time: n/a Last write time: Fri May 18 10:39:45 2018 Mount count: 0 Maximum mount count: 30 Last checked: Fri May 18 10:02:08 2018 Check interval: 15552000 (6 months) Next check after: Wed Nov 14 10:02:08 2018 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 Default directory hash: half_md4 Directory Hash Seed: 5764ea43-ae79-42fb-bb91-add61fe433bd Journal backup: inode blocks
Group 0: (Blocks 0-32767) Primary superblock at 0, Group descriptors at 1-1 Reserved GDT blocks at 2-129 Block bitmap at 130 (+130), Inode bitmap at 131 (+131) Inode table at 132-615 (+132) 32146 free blocks, 7733 free inodes, 2 directories Free blocks: 622-32767 Free inodes: 12-7744 Group 1: (Blocks 32768-65535) Backup superblock at 32768, Group descriptors at 32769-32769 Reserved GDT blocks at 32770-32897 Block bitmap at 32898 (+130), Inode bitmap at 32899 (+131) Inode table at 32900-33383 (+132) 32152 free blocks, 7744 free inodes, 0 directories Free blocks: 33384-65535 Free inodes: 7745-15488 Group 2: (Blocks 65536-98303) Block bitmap at 65536 (+0), Inode bitmap at 65537 (+1) Inode table at 65538-66021 (+2) 32282 free blocks, 7744 free inodes, 0 directories Free blocks: 66022-98303 Free inodes: 15489-23232 Group 3: (Blocks 98304-131071) Backup superblock at 98304, Group descriptors at 98305-98305 Reserved GDT blocks at 98306-98433 Block bitmap at 98434 (+130), Inode bitmap at 98435 (+131) Inode table at 98436-98919 (+132) 32152 free blocks, 7744 free inodes, 0 directories Free blocks: 98920-131071 Free inodes: 23233-30976 Group 4: (Blocks 131072-163839) Block bitmap at 131072 (+0), Inode bitmap at 131073 (+1) Inode table at 131074-131557 (+2) 32282 free blocks, 7744 free inodes, 0 directories Free blocks: 131558-163839 Free inodes: 30977-38720 Group 5: (Blocks 163840-196607) Backup superblock at 163840, Group descriptors at 163841-163841 Reserved GDT blocks at 163842-163969 Block bitmap at 163970 (+130), Inode bitmap at 163971 (+131) Inode table at 163972-164455 (+132) 32152 free blocks, 7744 free inodes, 0 directories Free blocks: 164456-196607 Free inodes: 38721-46464 Group 6: (Blocks 196608-229375) Block bitmap at 196608 (+0), Inode bitmap at 196609 (+1) Inode table at 196610-197093 (+2) 32282 free blocks, 7744 free inodes, 0 directories Free blocks: 197094-229375 Free inodes: 46465-54208 Group 7: (Blocks 229376-262143) Backup superblock at 229376, Group descriptors at 229377-229377 Reserved GDT blocks at 229378-229505 Block bitmap at 229506 (+130), Inode bitmap at 229507 (+131) Inode table at 229508-229991 (+132) 32152 free blocks, 7744 free inodes, 0 directories Free blocks: 22×××-262143 Free inodes: 54209-61952 Group 8: (Blocks 262144-294911) Block bitmap at 262144 (+0), Inode bitmap at 262145 (+1) Inode table at 262146-262629 (+2) 32282 free blocks, 7744 free inodes, 0 directories Free blocks: 262630-294911 Free inodes: 61953-69696 Group 9: (Blocks 294912-327679) Backup superblock at 294912, Group descriptors at 294913-294913 Reserved GDT blocks at 294914-295041 Block bitmap at 295042 (+130), Inode bitmap at 295043 (+131) Inode table at 295044-295527 (+132) 32152 free blocks, 7744 free inodes, 0 directories Free blocks: 295528-327679 Free inodes: 69697-77440 Group 10: (Blocks 327680-360447) Block bitmap at 327680 (+0), Inode bitmap at 327681 (+1) Inode table at 327682-328165 (+2) 32282 free blocks, 7744 free inodes, 0 directories Free blocks: 328166-360447 Free inodes: 77441-85184 Group 11: (Blocks 360448-393215) Block bitmap at 360448 (+0), Inode bitmap at 360449 (+1) Inode table at 360450-360933 (+2) 32282 free blocks, 7744 free inodes, 0 directories Free blocks: 360934-393215 Free inodes: 85185-92928 Group 12: (Blocks 393216-425983) Block bitmap at 393216 (+0), Inode bitmap at 393217 (+1) Inode table at 393218-393701 (+2) 32282 free blocks, 7744 free inodes, 0 directories Free blocks: 393702-425983 Free inodes: 92929-100672 Group 13: (Blocks 425984-458751) Block bitmap at 425984 (+0), Inode bitmap at 425985 (+1) Inode table at 425986-426469 (+2) 32282 free blocks, 7744 free inodes, 0 directories Free blocks: 426470-458751 Free inodes: 100673-108416 Group 14: (Blocks 458752-491519) Block bitmap at 458752 (+0), Inode bitmap at 458753 (+1) Inode table at 458754-459237 (+2) 32282 free blocks, 7744 free inodes, 0 directories Free blocks: 459238-491519 Free inodes: 108417-116160 Group 15: (Blocks 491520-524287) Block bitmap at 491520 (+0), Inode bitmap at 491521 (+1) Inode table at 491522-492005 (+2) 32282 free blocks, 7744 free inodes, 0 directories Free blocks: 492006-524287 Free inodes: 116161-123904 Group 16: (Blocks 524288-526127) Block bitmap at 524288 (+0), Inode bitmap at 524289 (+1) Inode table at 524290-524773 (+2) 1354 free blocks, 7744 free inodes, 0 directories Free blocks: 524774-526127 Free inodes: 123905-131648
[root@localhost ~]# dumpe2fs -h /dev/sdb2 dumpe2fs 1.41.12 (17-May-2010) Filesystem volume name: mydata2 Last mounted on: <not available> Filesystem UUID: 115aefb8-9765-47c4-becf-3b017cfc7025 Filesystem magic number: 0xEF53 Filesystem revision #: 1 (dynamic) Filesystem features: ext_attr resize_inode dir_index filetype sparse_super large_file Filesystem flags: signed_directory_hash Default mount options: (none) Filesystem state: clean Errors behavior: Continue Filesystem OS type: Linux Inode count: 131648 Block count: 526128 Reserved block count: 10522 Free blocks: 517080 Free inodes: 131637 First block: 0 Block size: 4096 Fragment size: 4096 Reserved GDT blocks: 128 Blocks per group: 32768 Fragments per group: 32768 Inodes per group: 7744 Inode blocks per group: 484 Filesystem created: Fri May 18 10:02:08 2018 Last mount time: n/a Last write time: Fri May 18 10:39:45 2018 Mount count: 0 Maximum mount count: 30 Last checked: Fri May 18 10:02:08 2018 Check interval: 15552000 (6 months) Next check after: Wed Nov 14 10:02:08 2018 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 Default directory hash: half_md4 Directory Hash Seed: 5764ea43-ae79-42fb-bb91-add61fe433bd Journal backup: inode blocks
文件系统检测 fsck:file system check fsck.fs_type fsck –t fs_type -a 自动修复错误 -r 交互式修复错误 [root@localhost ~]# fsck -t ext4 -a /dev/sdb2 fsck from util-linux-ng 2.17.2 /dev/sdb2: clean, 11/131648 files, 25432/526128 blocks
[root@localhost ~]# fsck -t ext4 -r /dev/sdb2 fsck from util-linux-ng 2.17.2 e2fsck 1.41.12 (17-May-2010) /dev/sdb2: clean, 11/131648 files, 25432/526128 blocks
注意 fs_type 一定要与分区上已有文件系统类型相同
e2fsck ext系列文件系统专用的检测修复工具 -y 自动回答为yes -f 强制修复
[root@localhost ~]# e2fsck -y /dev/sdb2 e2fsck 1.41.12 (17-May-2010) /dev/sdb2: clean, 11/131648 files, 25432/526128 blocks
[root@localhost ~]# e2fsck -f /dev/sdb2 e2fsck 1.41.12 (17-May-2010) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/sdb2: 11/131648 files (0.0% non-contiguous), 25432/526128 blocks