Xfs configuration on centos7

XFS is a file system with high scalability and high performance. It is also the default file system of rhel7/centos7.
XFS supports metadata journaling, which enables faster recovery from crashes.
It also supports defragmentation and expansion in a mounted and active state.
Through delayed allocation, XFS has won many opportunities to optimize write performance.
The xfs file system can be backed up and restored through the tools xfsdump and xfsrestore,
xfsdump can use the dump level to complete incremental backups, and can also exclude files through size, subtree, and inode flags.
Also supports user, group, and project quotas.

The following will introduce how to create an xfs file system, allocate quotas and expand its capacity:
###############################################################################
Partition /dev/sdb (2G) and enable LVM function

[ 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 42048(parted)set1 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  4194 kB  2048MB  2044MB               primary  lvm

###############################################################################
Create PV

[ 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 newphysical 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

###############################################################################
Assign /dev/sdb1 to the VG named xfsgroup00

[ 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

###############################################################################
Use the command lvcreate to create an LV named xfsdata with a group size of 1G xfsgroup00

[ 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-1820: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-1820: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-2315: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

###############################################################################
**Format the partition as xfs file system. **Note: After xfs is created, its size cannot be reduced, but it can be increased by xfs_growfs

[ 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

###############################################################################
**Mount the xfs system partition to the specified directory, and enable the file system quota through the parameters uquota and gquota. **

[ 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)

###############################################################################
**Use the xfs_quota command to view quota information and assign quotas to users and directories, and verify that the quota limits are in effect. **

[ 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                00000[--------]

Group quota on /xfsdata(/dev/mapper/xfsgroup00-xfsdata)
        Blocks                     
Group ID         Used       Soft       Hard    Warn/Grace     
------------------------------------------------------------ 
root                00000[--------][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                00000[--------]
zhongq              010240012288000[--------]

Group quota on /xfsdata(/dev/mapper/xfsgroup00-xfsdata)
        Blocks                     
Group ID         Used       Soft       Hard    Warn/Grace     
------------------------------------------------------------ 
root                00000[--------][root@localhost zhongq]# su zhongq
[ zhongq@localhost ~]$ dd if=/dev/zero of=/xfsdata/zq00 bs=1M count=100100+0 records in100+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 in20+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    12288010240012288000[6 days]/xfsdata

###############################################################################
First use the command lvextend to expand the LV to 1.5G (the initial capacity is 1G), and then use the command xfs_growfs to expand the xfs file system (here, count by block)

[ 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 from262144 to 393216[root@localhost zhongq]# df -h|grep xfsdata
/dev/mapper/xfsgroup00-xfsdata  1.5G  153M  1.4G  10%/xfsdata

Recommended Posts

Xfs configuration on centos7
CentOS7.0 network configuration
CentOS 7.0 network configuration
CentOS7 basic configuration
Centos MySQL8 configuration
Install Docker on Centos7
install LNMP on centos7.4
Build k8s1.9.9 on centos7
Configure Ocserv on CentOS 6
Nodejs install on centos7
Install FFmpeg on CentOS 8
Centos kernel compilation configuration
Install RabbitMQ on CentOS 7
Install Node.js on Centos
Maven install on centos7
Install MongoDB on CentOS 7
Jenkins build on centos
Install Surelog on CentOS8
Mysql8.0.15 installation configuration (centos7)
Deploy vuepress on centos7
Openjdk install on centos7
Install Jenkins on centos7
Use RapidSVN on CentOS7
install RabbitMQ on centos
Install RabbitMQ on CentOS 7
install Docker on centos6.5
install oracle on centos
Install Elasticsearch 6 on centos7
Install RabbitMQ on CentOS7
Deploy Jenkin on centos7
MySQL 8.0 installation, deployment and configuration tutorial on CentOS 8
Install mysql online on centos
Centos mysql installation and configuration
Centos7.4 deployment configuration Elasticsearch5.6 cluster
Install ElasticSearch 7.x on CentOS 7
Glusterfs cluster installation on Centos7
Centos7 installation and configuration prometheus
Build MariaDB replication on CentOS
CentOS 7 installation and configuration PPTP
Install MySQL 8.0.16 on Linux Centos
Deployment of graphite on centos7
Install docker transfer on Centos7
CentOS installation and configuration cmake
CentOS 7 user account configuration original
Centos7.5 installation and configuration MongoDB4.0.4
CentOS 7 installation and configuration PPTP
Configure swap space on CentOS7
Install docker on Centos system
CentOS mysql configuration master-slave replication
install EPEL repo on centos
Implementation of CentOS8.0 Network Configuration
CentOS 7 Redis 5.0.8 sentinel mode configuration
Install Zabbix 3.4 based on CentOS 7
install virtualbox on centos server
CentOS8 network card configuration file
Docker EE installation on centos7
Install Nginx server on CentOS 7
How to install MySQL on CentOS 8
Centos7 installation and configuration of Jenkins
Common Linux operations (based on centos7)
Install JDK8 in rpm on CentOS7