I have never been exposed to CentOS 7 before and do not understand the features it has changed. I came across LVM in centos 7 by chance. The method of creating LVM is the same as that in 6, but the expansion of LVM is a little different. Use the previous method. After the expansion, it never took effect. It took me a long time to figure out how to expand it. Xfs is the default file system type of CentOS7, and different file system types have different creation, inspection, and adjustment commands . |
Xfs is the default file system type of CentOS7, and different file system types have different creation, inspection, and adjustment commands .
In the xfs file system, the partition can only be increased but not reduced.
[root@localhost ~]# ls /lib//modules/3.10.0-229.20.1.el7.x86_64/kernel/fs #View all file system types supported by the kernel binfmt_misc.ko ceph dlm fat gfs2 lockd nfs_common overlayfs udf btrfs cifs exofs fscache isofs mbcache.ko nfsd pstore xfs cachefiles cramfs ext4 fuse jbd2 nfs nls squashfs
I have previously created a new partition and added it to vg, and the physical boundaries have also been expanded.
When extending the logical boundary, the error message is as follows:
[root@localhost ~]# resize2fs -p /dev/mapper/centos-root resize2fs 1.42.9 (28-Dec-2013) resize2fs: Bad magic number in super-block when trying to open /dev/mapper/centos-root A valid file system superblock was not found.
First I thought of using fsck to repair it, but it didn’t work. After seeing the error message, I realized that the xfs file needs to be repaired using xfs_repair.
[root@localhost ~]# fsck /dev/mapper/centos-root fsck,来自 util-linux 2.23.2 If you wish to check the consistency of an XFS filesystem or repair a damaged filesystem, see xfs_repair(8).
Then I tried to repair it, but it didn't work. It needs to be uninstalled to repair it, and this file system is mounted under /, so don't even think about it.
[root@localhost ~]# xfs_repair /dev/mapper/centos-root xfs_repair: /dev/mapper/centos-root contains a mounted filesystem xfs_repair: /dev/mapper/centos-root contains a mounted and writable filesystem fatal error -- couldn't initialize XFS library
Finally, after some research on the Internet, I found out that after the logical expansion of the xfs file system, there is still one more step to complete:
[root@localhost ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root centos -wi-ao---- 95.00g swap centos -wi-ao---- 3.88g [root @localhost ~]# df -lh file system capacity used available used % mount point /dev/mapper/centos-root 46G 42G 4.5G 91% / ------------>46G devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 1.9G 164K 1.9G 1% /dev/shm tmpfs 1.9G 8.7M 1.9G 1% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/sda1 497M 208M 290M 42% /boot [root@localhost ~]# xfs_growfs /dev/mapper/centos-root #Perform adjustments, this step is required after expansion meta-data=/dev/mapper/centos-root isize=256 agcount=4, agsize=2987776 blks = sectsz=512 attr=2, projid32bit=1 = crc=0 finobt=0 data = bsize=4096 blocks=11951104, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=0 log =internal bsize=4096 blocks=5835, version=2 = sectsz=512 sunit=0 blks, lazy- count=1 [root@localhost ~]# df -lh file system capacity used available used % mount point realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 11951104 to 24903680 /dev/mapper/centos-root 95G 42G 54G 44% / ----------> Completed expansion of devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 1.9G 164K 1.9G 1% /dev /shm tmpfs 1.9G 8.7M 1.9G 1% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/sda1 497M 208M 290M 42% /boot
Commonly used commands related to xfs
xfs_admin: adjust various parameters of the xfs file system xfs_copy: copy the contents of the xfs file system to one or more target systems (in parallel mode) xfs_db: debug or detect the xfs file system (view file system fragments, etc.) xfs_check: detect the xfs file system Integrity xfs_bmap: View the block map of a file xfs_repair: Attempt to repair a damaged xfs file system xfs_fsr : Defragment Medium xfs_mdrestore: restore metadata (metadata) from a file to the xfs file system xfs_growfs: resize an xfs file system (can only be extended) xfs_freeze pause (-f) and resume (-u) xfs file system xfs_logprint: print xfs File system log xfs_mkfile: create xfs file system xfs_info: query file system details xfs_ncheck: generate pathnames from i-numbers for XFS xfs_rtcp: XFS real-time copy command xfs_io: debug xfs I/O path
Note:
After using the mke2fs command on the Xfs file system, it becomes ext2. You need to modify the corresponding file system type in the file /etc/fstab!