文件系统管理工具介绍

 

 

 

 

文件系统管理工具介绍

 

 

 

 

一tune2fs的介绍和使用

 

 

tune2fs:重新设定ext系列文件系统可调整参数的值


-l:查看指定文件系统超级块信息;super block


-L 'LABEL':修改卷标


-m #:修预留给管理员的空间百分比


-j: 将ext2升级为ext3


-O: 文件系统属性启用或禁用, –O ^has_journal


-o: 调整文件系统的默认挂载选项,–o ^acl


-U UUID: 修改UUID号

 

 

 

 

修改UUID号,一般不修改

方法指定UUID和设备名称即可

[root@centos65 ~]# blkid
/dev/sda1: UUID="6bbd9da4-0c3d-4496-a4b1-44bf79912740" TYPE="ext4" 
/dev/sda2: UUID="10d2b40d-dcd8-4c16-aa81-511c520213f6" TYPE="ext4" 
/dev/sda3: UUID="e432b350-a9a6-429b-8f07-592058efc6e2" TYPE="ext4" 
/dev/sda5: UUID="b25a8a7e-40d8-485b-a5af-1b583698864d" TYPE="swap" 
/dev/sdb2: UUID="b5e3fb3c-48be-49ff-b610-2b244d18639c" TYPE="ext4" 
/dev/sdd: UUID="c4a0e490-aa52-4c8b-bcad-b20dd895971d" TYPE="ext4" 
/dev/sdb3: UUID="bef91525-93b8-48a8-a2af-4ba463dc48ce" SEC_TYPE="ext2" TYPE="ext3" LABEL="/mnt/sdb3" 
/dev/sdb5: UUID="53bc9bdb-6256-4ad9-bddb-361e3a4728fd" SEC_TYPE="ext2" TYPE="ext3" 
[root@centos65 ~]# tune2fs   -U  "53bc9bdb-6256-4ad9-bddb-12343a4728fd"     /dev/sdb5
tune2fs 1.41.12 (17-May-2010)
[root@centos65 ~]# blkid
/dev/sda1: UUID="6bbd9da4-0c3d-4496-a4b1-44bf79912740" TYPE="ext4" 
/dev/sda2: UUID="10d2b40d-dcd8-4c16-aa81-511c520213f6" TYPE="ext4" 
/dev/sda3: UUID="e432b350-a9a6-429b-8f07-592058efc6e2" TYPE="ext4" 
/dev/sda5: UUID="b25a8a7e-40d8-485b-a5af-1b583698864d" TYPE="swap" 
/dev/sdb2: UUID="b5e3fb3c-48be-49ff-b610-2b244d18639c" TYPE="ext4" 
/dev/sdd: UUID="c4a0e490-aa52-4c8b-bcad-b20dd895971d" TYPE="ext4" 
/dev/sdb3: UUID="bef91525-93b8-48a8-a2af-4ba463dc48ce" SEC_TYPE="ext2" TYPE="ext3" LABEL="/mnt/sdb3" 
/dev/sdb5: UUID="53bc9bdb-6256-4ad9-bddb-12343a4728fd" SEC_TYPE="ext2" TYPE="ext3" 

 

 

 

 

 

 

 

 

 

 

二文件系统标签的相关命令——blkid,e2label,findfs

 

 

 

文件系统标签是指向设备的另一种方法,与设备无关

blkid:块设备属性信息查看


blkid [OPTION]... [DEVICE]


-U UUID: 根据指定的UUID来查找对应的设备


-L LABEL:根据指定的LABEL来查找对应的设备


e2label:管理ext系列文件系统的LABEL


e2label DEVICE [LABEL]


findfs :查找分区


findfs [options] LABEL=<label>


findfs [options] UUID=<uuid>

 

 

 

 


(一)blkid:块设备属性信息查看

 


blkid [OPTION]... [DEVICE]


-U   UUID: 根据指定的UUID来查找对应的设备

[root@centos65 ~]# blkid   -U  53bc9bdb-6256-4ad9-bddb-12343a4728fd
/dev/sdb5

 

 

 

 

 

-L LABEL:根据指定的LABEL来查找对应的设备

[root@centos65 ~]# blkid    -L   /mnt/sdb3  
/dev/sdb3

 

 

 

 

 

注意L只能写在中间

[root@centos65 ~]# blkid  /mnt/sdb3  -L
blkid: option requires an argument -- 'L'
blkid from util-linux-ng 2.17.2 (libblkid 2.17.0, 22-Mar-2010)
Usage:
  blkid -L <label> | -U <uuid>

 

 

 



 

 

 

查看文件里面挂载目录的分区

[root@centos65 ~]# cat  /etc/fstab 

#
# /etc/fstab
# Created by anaconda on Wed Jan 23 16:50:34 2019
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=10d2b40d-dcd8-4c16-aa81-511c520213f6 /                       ext4    defaults        1 1
UUID=e432b350-a9a6-429b-8f07-592058efc6e2 /app                    ext4    defaults        1 2
UUID=6bbd9da4-0c3d-4496-a4b1-44bf79912740 /boot                   ext4    defaults        1 2
UUID=b25a8a7e-40d8-485b-a5af-1b583698864d swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/cdrom   /media   iso9660  defaults  0 0

 

 

 

 

 

注意目录是不能重复的,如果有两个app开头,但是结尾不同的,那么就要在目录名后面加空格,确保唯一

[root@centos65 ~]# sed  -r       -n    's#^UUID=(.*) /app.*#\1#p'       /etc/fstab 
e432b350-a9a6-429b-8f07-592058efc6e2

[root@centos65 ~]#  blkid  -U    `sed  -r       -n    's#^UUID=(.*) /app.*#\1#p'       /etc/fstab`     
/dev/sda3

 

 

 

 

下面目录名前后都有空格

[root@centos65 ~]#  blkid  -U    `sed  -r       -n    's#^UUID=(.*) /app .*#\1#p'       /etc/fstab`     
/dev/sda3

 

 

 

 

 

 

两个文件找交集,取出文件相同的行

法1:使用正则表达式

[root@centos65 ~]# grep   -f  f1  f2
a
c
d
[root@centos65 ~]# cat f1
a
c
b
c
d
[root@centos65 ~]# cat f2
a
e
f
c
d

 

 

 

 

 

 

法2:

[root@centos65 ~]# cat  f1  f2   |  sort
a
a
b
c
c
c
d
d
e
f
[root@centos65 ~]# cat  f1  f2   |  sort  |  uniq
a
b
c
d
e
f
[root@centos65 ~]# cat  f1  f2   |  sort  |  uniq  -c
      2 a
      1 b
      3 c
      2 d
      1 e
      1 f

 

 

 

 

 

 

只要删除有1的行就可以,注意为了确保1前面没空格就要在分隔符前后加空格

但是如果在一个文件里面就有重复的行,比如多次出现a,那么就会有误了。

[root@centos65 ~]# cat  f1  f2   |  sort  |  uniq  -c  |  sed    '/ 1 /d'
      2 a
      3 c
      2 d
[root@centos65 ~]# cat  f1  f2   |  sort  |  uniq  -c  |  sed    '/1/d'
      2 a
      3 c
      2 d

 

 

 

 

 

 

法3:如果在一个文件里面就有重复的行,比如多次出现a,那么就会有误了。这种逻辑关系和法2一样,是有问题的

[root@centos65 ~]# cat  f1  f2   |  sort  |  uniq  -d
a
c
d

 

 

 

 

 

 

下面出现问题了

[root@centos65 ~]# cat  f1  f2   |  sort  |  uniq  -d
a
c
d
g
[root@centos65 ~]# cat  f1
a
c
b
c
d
[root@centos65 ~]# cat  f2
a
e
f
g
g
c
d

 

 

 

 

 

 

 

 

(二)e2label:管理ext系列文件系统的LABEL


e2label DEVICE [LABEL]

 

 

 

 

(三)findfs :查找分区


findfs  [options]    LABEL=<label>


findfs   [options]    UUID=<uuid>

 

[root@centos65 ~]# blkid
/dev/sda1: UUID="6bbd9da4-0c3d-4496-a4b1-44bf79912740" TYPE="ext4" 
/dev/sda2: UUID="10d2b40d-dcd8-4c16-aa81-511c520213f6" TYPE="ext4" 
/dev/sda3: UUID="e432b350-a9a6-429b-8f07-592058efc6e2" TYPE="ext4" 
/dev/sda5: UUID="b25a8a7e-40d8-485b-a5af-1b583698864d" TYPE="swap" 
/dev/sdb2: UUID="b5e3fb3c-48be-49ff-b610-2b244d18639c" TYPE="ext4" 
/dev/sdd: UUID="c4a0e490-aa52-4c8b-bcad-b20dd895971d" TYPE="ext4" 
/dev/sdb3: UUID="bef91525-93b8-48a8-a2af-4ba463dc48ce" SEC_TYPE="ext2" TYPE="ext3" LABEL="/mnt/sdb3" 
/dev/sdb5: UUID="53bc9bdb-6256-4ad9-bddb-12343a4728fd" SEC_TYPE="ext2" TYPE="ext3" 
[root@centos65 ~]# findfs    UUID="53bc9bdb-6256-4ad9-bddb-12343a4728fd"
/dev/sdb5
[root@centos65 ~]# findfs    UUID="53bc9bdb-6256-4ad9-bddb-12343a4728fd"^C
[root@centos65 ~]# findfs  LABEL="/mnt/sdb3" 
/dev/sdb3

 

 

 

 

 

 

 

 

dumpe2fs:
块分组管理,32768块
-h:查看超级块信息,不显示分组信息

[root@centos65 ~]# dumpe2fs   -h  /dev/sdb3
dumpe2fs 1.41.12 (17-May-2010)
Filesystem volume name:   <none>
Last mounted on:          <not available>
Filesystem UUID:          bef91525-93b8-48a8-a2af-4ba463dc48ce
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal 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:     26306
Free blocks:              500679
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:       Wed Feb 27 11:39:57 2019
Last mount time:          n/a
Last write time:          Wed Feb 27 11:39:59 2019
Mount count:              0
Maximum mount count:      21
Last checked:             Wed Feb 27 11:39:57 2019
Check interval:           15552000 (6 months)
Next check after:         Mon Aug 26 11:39:57 2019
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:      fba196ac-6692-4dfa-a19b-b721e3ad325e
Journal backup:           inode blocks
Journal features:         (none)
Journal size:             64M
Journal length:           16384
Journal sequence:         0x00000001
Journal start:            0

 

 

 

 

 

 

 

 dumpe2fs -h /dev/sdb3和 tune2fs -l /dev/sdb3显示的是一样的结果

[root@centos65 ~]# tune2fs   -l  /dev/sdb3
tune2fs 1.41.12 (17-May-2010)
Filesystem volume name:   <none>
Last mounted on:          <not available>
Filesystem UUID:          bef91525-93b8-48a8-a2af-4ba463dc48ce
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal 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:     26306
Free blocks:              500679
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:       Wed Feb 27 11:39:57 2019
Last mount time:          n/a
Last write time:          Wed Feb 27 11:39:59 2019
Mount count:              0
Maximum mount count:      21
Last checked:             Wed Feb 27 11:39:57 2019
Check interval:           15552000 (6 months)
Next check after:         Mon Aug 26 11:39:57 2019
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:      fba196ac-6692-4dfa-a19b-b721e3ad325e
Journal backup:           inode blocks

 

上一篇:No FileSystem for scheme:file解决方法


下一篇:es在数据量很大的情况下(数十亿级别)如何提高查询效率啊?