centos7的xfs配置

 

XFS是扩展性高、高性能的文件系统。也是rhel7/centos7的默认文件系统。
XFS支持metadata journaling,这使其能从crash中更快速的恢复。
它也支持在挂载和活动的状态下进行碎片整理和扩容。
通过延迟分配,XFS 赢得了许多机会来优化写性能。
可通过工具xfsdump和xfsrestore来备份和恢复xfs文件系统,
xfsdump可使用dump级别来完成增量备份,还可通过size,subtree,inode flags来排除文件。
也支持user、group、project配额。

下面将介绍如何创建xfs文件系统,分配配额以及对其扩容:
###############################################################################
将/dev/sdb分区(2G),并启动LVM功能

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@localhost zhongq]#parted /dev/sdb                              
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mkpart primary 4 2048
(parted) set 1 lvm on                                                   
(parted) p                                                            
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
 
Number  Start   End     Size    File system  Name     Flags
 1      4194kB  2048MB  2044MB               primary  lvm

###############################################################################
创建PV

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
[root@localhost zhongq]# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created
 
[root@localhost zhongq]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               centos
  PV Size               24.51 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              6274
  Free PE               0
  Allocated PE          6274
  PV UUID               9hp8U7-IJM6-bwbP-G9Vn-IVuJ-yvE8-AkFjcB
    
  "/dev/sdb1" is a new physical volume of "1.90 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb1
  VG Name              
  PV Size               1.90 GiB
  Allocatable           NO
  PE Size               0  
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               bu7yIH-1440-BPy1-APG2-FpvX-ejLS-2MIlA8

###############################################################################
将/dev/sdb1分配到名为xfsgroup00的VG

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
[root@localhost zhongq]# vgcreate  xfsgroup00 /dev/sdb1
 Volume group "xfsgroup00" successfully created
[root@localhost zhongq]# vgdisplay
 --- Volume group ---
  VG Name               centos
  System ID            
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               24.51 GiB
  PE Size               4.00 MiB
  Total PE              6274
  Alloc PE / Size       6274 / 24.51 GiB
  Free  PE / Size       0 / 0  
  VG UUID               T3Ryyg-R0rn-2i5r-7L5o-AZKG-yFkh-CDzhKm
    
  --- Volume group ---
  VG Name               xfsgroup00
  System ID            
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               1.90 GiB
  PE Size               4.00 MiB
  Total PE              487
  Alloc PE / Size       0 / 0  
  Free  PE / Size       487 / 1.90 GiB
  VG UUID               ejuwcc-sVES-MWWB-3Mup-n1wB-Kd0g-u7jm0H

###############################################################################
使用命令lvcreate来创建xfsgroup00组大小为1G的名为xfsdata的LV

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
[root@localhost zhongq]# lvcreate -L 1024M -n xfsdata xfsgroup00
WARNING: xfs signature detected on /dev/xfsgroup00/xfsdata at offset 0. Wipe it? [y/n] y
  Wiping xfs signature on /dev/xfsgroup00/xfsdata.
  Logical volume "xfsdata" created
[root@localhost zhongq]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/centos/swap
  LV Name                swap
  VG Name                centos
  LV UUID                EnW3at-KlFG-XGaQ-DOoH-cGPP-8pSf-teSVbh
  LV Write Access        read/write
  LV Creation host, time localhost, 2014-08-18 20:15:25 +0800
  LV Status              available
  # open                 2
  LV Size                2.03 GiB
  Current LE             520
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0
    
  --- Logical volume ---
  LV Path                /dev/centos/root
  LV Name                root
  VG Name                centos
  LV UUID                zmZGkv-Ln4W-B8AY-oDnD-BEk2-6VWL-L0cZOv
  LV Write Access        read/write
  LV Creation host, time localhost, 2014-08-18 20:15:26 +0800
  LV Status              available
  # open                 1
  LV Size                22.48 GiB
  Current LE             5754
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:1
    
  --- Logical volume ---
  LV Path                /dev/xfsgroup00/xfsdata
  LV Name                xfsdata
  VG Name                xfsgroup00
  LV UUID                O4yvoY-XGcD-0zPm-eilR-3JJP-updU-rRCSlJ
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2014-09-23 15:50:19 +0800
  LV Status              available
  # open                 0
  LV Size                1.00 GiB
  Current LE             256
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:3

###############################################################################
格式化分区为xfs文件系统。
注意:xfs被创建后,其size将无法缩小,但可以通过xfs_growfs来增大

1
2
3
4
5
6
7
8
9
10
[root@localhost zhongq]# mkfs.xfs /dev/xfsgroup00/xfsdata
meta-data=/dev/xfsgroup00/xfsdata isize=256    agcount=4, agsize=65536 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=262144, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

###############################################################################
挂载xfs系统分区到指定目录,并通过参数uquota,gquota开启文件系统配额。

1
2
3
4
5
[root@localhost zhongq]# mkdir /xfsdata
[root@localhost zhongq]# mount -o uquota,gquota /dev/xfsgroup00/xfsdata /xfsdata
[root@localhost zhongq]# chmod 777 /xfsdata
[root@localhost zhongq]# mount|grep xfsdata
/dev/mapper/xfsgroup00-xfsdata on /xfsdata type xfs (rw,relatime,attr2,inode64,usrquota,grpquota)

###############################################################################
使用xfs_quota命令来查看配额信息以及为用户和目录分配配额,并验证配额限制是否生效。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
[root@localhost zhongq]# xfs_quota -x -c 'report' /xfsdata
User quota on /xfsdata (/dev/mapper/xfsgroup00-xfsdata)
                               Blocks                    
User ID          Used       Soft       Hard    Warn/Grace    
---------- --------------------------------------------------
root                0          0          0     00 [--------]
 
Group quota on /xfsdata (/dev/mapper/xfsgroup00-xfsdata)
                               Blocks                    
Group ID         Used       Soft       Hard    Warn/Grace    
---------- --------------------------------------------------
root                0          0          0     00 [--------]
 
[root@localhost zhongq]# xfs_quota -x -c 'limit bsoft=100M bhard=120M zhongq' /xfsdata
[root@localhost zhongq]#xfs_quota -x -c 'report' /xfsdata
User quota on /xfsdata (/dev/mapper/xfsgroup00-xfsdata)
                               Blocks                    
User ID          Used       Soft       Hard    Warn/Grace    
---------- --------------------------------------------------
root                0          0          0     00 [--------]
zhongq              0     102400     122880     00 [--------]
 
Group quota on /xfsdata (/dev/mapper/xfsgroup00-xfsdata)
                               Blocks                    
Group ID         Used       Soft       Hard    Warn/Grace    
---------- --------------------------------------------------
root                0          0          0     00 [--------]
 
[root@localhost zhongq]# su zhongq
[zhongq@localhost ~]$ dd if=/dev/zero of=/xfsdata/zq00 bs=1M count=100
100+0 records in
100+0 records out
104857600 bytes (105 MB) copied, 28.9833 s, 3.6 MB/s
[zhongq@localhost ~]$ dd if=/dev/zero of=/xfsdata/zq01 bs=1M count=100
dd: error writing ‘/xfsdata/zq01’: Disk quota exceeded
21+0 records in
20+0 records out
20971520 bytes (21 MB) copied, 4.18921 s, 5.0 MB/s
 
[zhongq@localhost ~]$ exit
 
[root@localhost zhongq]# xfs_quota
xfs_quota> help
df [-bir] [-hn] [-f file] -- show free and used counts for blocks and inodes
help [command] -- help for one or all commands
print -- list known mount points and projects
quit -- exit the program
quota [-bir] [-gpu] [-hnNv] [-f file] [id|name]... -- show usage and limits
 
Use 'help commandname' for extended help.
xfs_quota> print
Filesystem          Pathname
/                   /dev/mapper/centos-root
/boot               /dev/sda1
/var/lib/docker     /dev/mapper/centos-root
/xfsdata            /dev/mapper/xfsgroup00-xfsdata (uquota, gquota)
xfs_quota> quota -u zhongq
Disk quotas for User zhongq (1000)
Filesystem                        Blocks      Quota      Limit  Warn/Time      Mounted on
/dev/mapper/xfsgroup00-xfsdata    122880     102400     122880   00  [6 days]   /xfsdata

###############################################################################
先使用命令lvextend将LV扩展为1.5G(初始容量是1G),然后使用命令xfs_growfs来对xfs文件系统扩容(这里以block计数)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[root@localhost zhongq]# lvextend -L 1.5G /dev/xfsgroup00/xfsdata
  Extending logical volume xfsdata to 1.50 GiB
  Logical volume xfsdata successfully resized
   
[root@localhost zhongq]# xfs_growfs /dev/xfsgroup00/xfsdata -D 393216
meta-data=/dev/mapper/xfsgroup00-xfsdata isize=256    agcount=4, agsize=65536 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=262144, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 262144 to 393216
   
[root@localhost zhongq]# df -h|grep xfsdata
/dev/mapper/xfsgroup00-xfsdata  1.5G  153M  1.4G  10% /xfsdata

centos7 xfs 文件系统配置quota 用户磁盘配额的更多相关文章

  1. Linux用户磁盘配额

    一:内核中支持QUOTA: [root@localhost /]# grep  CONFIG_QUOTA /boot/config-3.10.0-123.el7.x86_64 CONFIG_QUOTA ...

  2. 『学了就忘』Linux文件系统管理 — 64、磁盘配额的配置步骤

    目录 1.手工建立一个5GB的分区 2.建立需要做限制的三个用户 3.在分区上开启磁盘配额功能 4.建立磁盘配额的配置文件 5.开始设置用户和组的配额限制 6.启动和关闭配额 7.磁盘配额的查询 8. ...

  3. quota - linux磁盘配额管理

    磁盘管理系列 linux磁盘管理系列一:磁盘配额管理   http://www.cnblogs.com/zhaojiedi1992/p/zhaojiedi_linux_040_quota.html l ...

  4. 『学了就忘』Linux文件系统管理 — 63、磁盘配额介绍

    目录 1.磁盘配额概念 2.磁盘配额条件 3.磁盘配额的相关概念 4.磁盘配额实践规划 1.磁盘配额概念 磁盘配额是限制用户或者用户组在一个分区上可以使用的空间大小和文件个数的限制. 扩展: 管理员可 ...

  5. 磁盘配额quota

    磁盘配额 1 启用磁盘配额 首先创建新的分区 /dev/sd5,并创建文件系统. [root@local ~]# mkfs.ext4 /dev/sda5 由于xfs 不磁盘配额能成功,这里使用ext4 ...

  6. xfs文件系统磁盘配额

    引言 这篇文章简单介绍一下xfs文件系统的磁盘配额配置. 文章目录 0×1.开启分区磁盘配额 0×2.使用xfs_quota命令配置磁盘配额 0×1.开启分区磁盘配额 对于ext4文件以前的文件系统, ...

  7. [转]linux之磁盘配额(quota)

    转自:http://www.jb51.net/LINUXjishu/78446.html 磁盘配额(quota)比较常用的几个情况是: * 针对WWW server,例如:每个人的网页空间的容量限制 ...

  8. Linux:quota磁盘配额设置

    磁盘配额的概念 quota 磁盘配额功能只在指定的文件系统(分区)内有效,未设置配额的文件系统不受限制. quota 针对指定的用户账号.组账号进行限制,其他用户或组不受影响. 磁盘配额可以进行两方面 ...

  9. Linux的磁盘配额详解(Quota)

    1. 检查内核情况 检查当前内核是否支持quota,当前内核配置文件在/boot下 如果当前内核不支持quota,需要重新编译内核将quota support编译进核心: File systems   ...

随机推荐

  1. java10---点餐系统

    public class OrderMsg { public static void main(String[] args) throws Exception { /** * 订餐人姓名.选择菜品.送 ...

  2. 四则运算生成与校检 Python实现

    GitHub地址 https://github.com/little-petrol/Arithmetic.git 合作者: 郭旭 和 卢明凯 设计实现过程 代码的组织主要分为两个部分: 算法与结构体的 ...

  3. Week2《Java程序设计》第二周学习总结

    Week02-Java学习笔记2 1. 本周学习总结 本周学习了java的基本语法与类库,其中介绍了基本数据类型和引用类型,介绍了String类,String对象的拼接以及String的一些常用方法: ...

  4. QA,敢问路在何方?听听微软资深QA怎么说~

    转载地址:http://blog.csdn.net/ocean1ee/article/details/8905031 我已经从事测试工作超过7年,从测试员(SDET)成长为高级测试员(SDET II) ...

  5. linux进程通信全面解析

      进程IPC 的 7种方式 linux下 进程通讯IPC的方式主要有以下7种: 1.文件 2.共享内存 3.信号 4.管道 5.套接字 6.消息列队 7.信号量   以下正文 中 一一 分析下: 1 ...

  6. asp.net identity的学习记录

    # identity数据库 ## 创建空数据库 交给ef管理 ### 添加asp.net identity包 ``` Install-Package Microsoft.AspNet.Identity ...

  7. 转载:将STM32的标准库编译成lib使用【图文】

    from:http://www.cnblogs.com/zyqgold/p/3189719.html 百度上边也有不少关于lib文件的文章,恰巧看到该博文,感觉该博文的条理清晰,步骤明确,故复制到这个 ...

  8. rhel7+apache+c cgi+动态域名实现web访问

    1. 申请动态域名/安装no-ip客户端 https://blog.csdn.net/lee244868149/article/details/44095835 2. yum安装httpd 两种方法安 ...

  9. Spring中的c3p0配置

    转载请注明出处:http://blog.csdn.net/l1028386804/article/details/51162560 今天,我们就来详细谈谈Spring中的c3p0配置问题,好了,不耽搁 ...

  10. 在Git远程管理项目

    新建repository 本地目录下,在命令行里新建一个代码仓库(repository) 里面只有一个README.md 命令如下: touch README.md        git init 初 ...