centos8 platform uses xfs file system

First, the characteristics xfs file system

XFS is a high performance file system log,

It was designed by the SGI, known as the industry's most advanced, most scalable file system technology.

Initially transplanted from unix (irix) to linux system.

From centos7 start, xfs become the default file system

 

Description: Liu association of forest architecture is a framework focused blog, address: https://www.cnblogs.com/architectforest

         The corresponding source code can be accessed here for:  https://github.com/liuhongdi/

 Description: Author: Liu association E-mail: [email protected]

 

Description: the need to create a partition before formatting the file system, please refer to this one

https://www.cnblogs.com/architectforest/p/12642634.html

 

Two, centos8 the xfs

1, the maximum single file size: 500TB

The maximum partition size: 1024TB

2. By comparison, centos6 the ext4:

The maximum single file size: 16TB

The maximum partition size: 16TB

 

Visible support for large file systems, xfs much better than ext4

 

Three, xfs related utilities belong to which package and installation

1, see the package belongs

[root@blog ~]# whereis mkfs.xfs
mkfs: /usr/sbin/mkfs /usr/sbin/mkfs.cramfs /usr/sbin/mkfs.minix /usr/sbin/mkfs.xfs
/usr/sbin/mkfs.ext2 /usr/sbin/mkfs.ext3 /usr/sbin/mkfs.ext4
/usr/sbin/mkfs.fat /usr/sbin/mkfs.msdos /usr/sbin/mkfs.vfat /usr/share/man/man8/mkfs.8.gz [root@blog ~]# rpm -qf /usr/sbin/mkfs.xfs xfsprogs-4.19.0-2.el8.x86_64

 

2, can not find mkfs.xfs command can be installed with yum

[root@blog ~]# yum install xfsprogs

 

Fourth, view the version of xfs tools

1, View mkfs.xfs version

[root@blog ~]# mkfs.xfs -V
mkfs.xfs version 5.0.0

 

2, see Help: If no argument, print help information

[root@blog ~]# mkfs.xfs 

 

Five examples: format a partition for the xfs file system and mount

1, view the partition's file system:

[root@blog ~]# parted --list
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 537GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End    Size   File system  Name     Flags
 1      1049kB  537GB  537GB               primary

You can see the file system below the fields are empty, no formatting

 

2, xfs format

# Use mkfs.xfs plus partition

[root@blog ~]# mkfs.xfs /dev/vdb1
meta-data=/dev/vdb1              isize=512    agcount=4, agsize=32767872 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1
data     =                       bsize=4096   blocks=131071488, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=63999, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0 

Note: If the current file system partitions already exist, you need to add -f parameter

/* force overwrite */   [-f]

 

3, once again view the partition:

[root@blog ~]# parted --list
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 537GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End    Size   File system  Name     Flags
 1      1049kB  537GB  537GB  xfs          primary

You can see the file system partition is formatted xfs

 

4, after the good formatted partition mounted to / databak this directory

Check the partition mount case

[root@blog ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        7.5G     0  7.5G   0% /dev
tmpfs           7.5G     0  7.5G   0% /dev/shm
tmpfs           7.5G  480K  7.5G   1% /run
tmpfs           7.5G     0  7.5G   0% /sys/fs/cgroup
/dev/vda1       100G   14G   87G  14% /
tmpfs           1.5G     0  1.5G   0% /run/user/1000 

Create a directory and mount

[Blog the root @ ~] # mkdir / databak 
when the mount with the mount command # [@ Blog the root
~] # mount / dev / vdb1 / databak

Mount View case again

[root@blog ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        7.5G     0  7.5G   0% /dev
tmpfs           7.5G     0  7.5G   0% /dev/shm
tmpfs           7.5G  480K  7.5G   1% /run
tmpfs           7.5G     0  7.5G   0% /sys/fs/cgroup
/dev/vda1       100G   14G   87G  14% /
tmpfs           1.5G     0  1.5G   0% /run/user/1000
/dev/vdb1       500G  3.6G  497G   1% /databak

We can see / dev / vdb1 mounted to the lower / databak listings, descriptions have been successfully mount

 

5, edit / etc / fstab, make this file system mount automatically when the machine starts

  Get partition with blkid uuid

[root@blog ~]# blkid
/dev/vda1: UUID="e32cfa7a-df48-4031-8fdf-5eec92ee3039" TYPE="xfs" PARTUUID="1863aa79-01"
/dev/vdb1: UUID="7b7af437-97ef-4f76-8ea1-bb6498ae0f44" TYPE="xfs" PARTLABEL="primary" PARTUUID="c124c0e4-3626-4abf-a3e5-503c52e31417" 

Edit / etc / fstab

[root@blog ~]# vi /etc/fstab

Add a line, save and exit:

UUID=7b7af437-97ef-4f76-8ea1-bb6498ae0f44 /databak                xfs     defaults        0 2 

 

Fifth, / etc / fstab file format Description:

The first column: device id, centos default with uuid specified device, we recommend this format

The second column: mount point, it needs to be an existing directory, you can write directly if the swap is a swap partition

The third column: the file system type, must be the same type of file system format

The fourth column: Mounting parameters:

  • auto: The system automatically mount, fstab is the default option

  • defaults: The most common parameters, to meet the needs of most file system

  • noauto boot does not automatically mount

  • nouser Only the superuser can mount

  • ro mount read-only access by

  • rw mount read and write permissions Press

  • user Any user can mount

  • Please note that the CD-ROM drive and a floppy drive only when equipped with medium can be mounted, so it is noauto

The fifth column: whether to allow backup operation

When set to the value 1, the backup programs allow backup dump; is set to 0, the backup operation is ignored;

Check the order of the boot disk: The sixth column

The lower the number the more the priority check, if the same number of two partitions, while checking it.

When its value is 0, never checked.

Root "/" partition is always 1. Other partitions from 2 start

 

Six examples: xfs file system repair

1, if the file system error occurs, needs to be fixed

Note that the repair to be done before umount

# Xfs_repair name plus the partition, this partition is done xfs file system repair

[root@blog ~]# umount /databak 
[root@blog ~]# xfs_repair /dev/vdb1
Phase 1 - find and verify superblock...
Phase 2 - using internal log
        - zero log...
        - scan filesystem freespace and inode maps...
        - found root inode chunk
Phase 3 - for each AG...
        - scan and clear agi unlinked lists...
        - process known inodes and perform inode discovery...
        - agno = 0
        - agno = 1
        - agno = 2
        - agno = 3
        - process newly discovered inodes...
Phase 4 - check for duplicate blocks...
        - setting up duplicate extent list...
        - check for inodes claiming duplicate blocks...
        - agno = 0
        - agno = 1
        - agno = 2
        - agno = 3
Phase 5 - rebuild AG headers and trees...
        - reset superblock...
Phase 6 - check inode connectivity...
        - resetting contents of realtime bitmap and summary inodes
        - traversing filesystem ...
        - traversal finished ...
        - moving disconnected inodes to lost+found ...
Phase 7 - verify and correct link counts...
done

 

2, Note: Production environments should separate the system disk and data disk, the system disk directly redo system

 

3, several parameters used

# -L is a last resort to repair xfs file system, carefully chosen, it will clear the log files and user data will be lost

[root@blog ~]# xfs_repair -L /dev/vdb1 

# -N, check the file system is damaged, if the damage to the operation to be performed are listed

           That just does not deal with checks

[root@blog ~]# xfs_repair -n /dev/vdb1

 

Seven examples: xfs file system backup and recovery

1, the backup:

Create a file for backup and recovery test success

[root@blog databak]# vi a.txt

Content: abcdefg

 

# -F specify the backup file path

[root@blog ~]# xfsdump -f /root/databak.xfsdump /databak
xfsdump: using file dump (drive_simple) strategy
xfsdump: version 3.1.8 (dump format 3.0) - type ^C for status and control

 ============================= dump label dialog ==============================

please enter label for this dump session (timeout in 300 sec)
 -> databak backup
session label entered: "databak backup"

 --------------------------------- end dialog ---------------------------------

xfsdump: level 0 dump of blog:/databak
xfsdump: dump date: Mon Apr  6 15:53:46 2020
xfsdump: session id: 08fdf1fd-2056-4010-bb8e-43fbbc053b9f
xfsdump: session label: "databak backup"
xfsdump: ino map phase 1: constructing initial dump list
xfsdump: ino map phase 2: skipping (no pruning necessary)
xfsdump: ino map phase 3: skipping (only one dump stream)
xfsdump: ino map construction complete
xfsdump: estimated dump size: 25216 bytes

 ============================= media label dialog =============================

please enter label for media in drive 0 (timeout in 300 sec)
 -> vdb1
media label entered: "vdb1 "

 --------------------------------- end dialog ---------------------------------

xfsdump: creating dump session media file 0 (media 0, file 0)
xfsdump: dumping ino map
xfsdump: dumping directories
xfsdump: dumping non-directory files
xfsdump: ending media file
xfsdump: media file size 21872 bytes
xfsdump: dump size (non-dir files) : 544 bytes
xfsdump: dump complete: 26 seconds elapsed
xfsdump: Dump Summary:
xfsdump:   stream 0 /root/databak.xfsdump OK (success)
xfsdump: Dump Status: SUCCESS

 

Label are two: this dump session and media

We entered: databak backup and vdb1

 

2, view the backup files case

# -I: uppercase i, to display information to back up

[root@blog ~]# xfsdump -I
file system 0:
        fs id:          7b7af437-97ef-4f76-8ea1-bb6498ae0f44
        session 0:
                mount point:    blog:/databak
                device:         blog:/dev/vdb1
                time:           Mon Apr  6 15:53:46 2020
                session label:  "databak backup"
                session id:     08fdf1fd-2056-4010-bb8e-43fbbc053b9f
                level:          0
                resumed:        NO
                subtree:        NO
                streams:        1
                stream 0:
                        pathname:       /root/databak.xfsdump
                        start:          ino 132 offset 0
                        end:            ino 133 offset 0
                        interrupted:    NO
                        media files:    1
                        media file 0:
                                mfile index:    0
                                mfile type:     data
                                mfile size:     21872
                                mfile start:    ino 132 offset 0
                                mfile end:      ino 133 offset 0
                                media label:    "vdb1 "
                                media id:       0ff37aa0-a15e-43ed-a0b0-2b432570545f
xfsdump: Dump Status: SUCCESS

 

3, delete the file and then restore the backup:

[root@blog ~]# cd /databak
[root@blog databak]# ls
a.txt
[root@blog databak]# rm a.txt
rm: remove regular file 'a.txt'? y
[root@blog databak]# ls
[root@blog databak]#

 

# -F specify the backup file path

[root@blog databak]# xfsrestore -f /root/databak.xfsdump /databak
xfsrestore: using file dump (drive_simple) strategy
xfsrestore: version 3.1.8 (dump format 3.0) - type ^C for status and control
xfsrestore: searching media for dump
xfsrestore: examining media file 0
xfsrestore: dump description:
xfsrestore: hostname: blog
xfsrestore: mount point: /databak
xfsrestore: volume: /dev/vdb1
xfsrestore: session time: Mon Apr  6 15:53:46 2020
xfsrestore: level: 0
xfsrestore: session label: "databak backup"
xfsrestore: media label: "databak "
xfsrestore: file system id: 7b7af437-97ef-4f76-8ea1-bb6498ae0f44
xfsrestore: session id: 08fdf1fd-2056-4010-bb8e-43fbbc053b9f
xfsrestore: media id: 0ff37aa0-a15e-43ed-a0b0-2b432570545f
xfsrestore: using online session inventory
xfsrestore: searching media for directory dump
xfsrestore: reading directories
xfsrestore: 1 directories and 1 entries processed
xfsrestore: directory post-processing
xfsrestore: restoring non-directory files
xfsrestore: restore complete: 0 seconds elapsed
xfsrestore: Restore Summary:
xfsrestore:   stream 0 /root/databak.xfsdump OK (success)
xfsrestore: Restore Status: SUCCESS

 

Check to see deleted files has been restored

[root@blog databak]# ls
a.txt
[root@blog databak]# more a.txt
abcdefg

 

Eight View centos version

[root@blog databak]# cat /etc/redhat-release
CentOS Linux release 8.0.1905 (Core) 

 

Guess you like

Origin www.cnblogs.com/architectforest/p/12642735.html