无法在 CentOS 8 上扩展文件系统

无法在 CentOS 8 上扩展文件系统

我的 CentOS 8 机器中有如下分区:

[root@XXXXX]# fdisk -l
Disk /dev/sda: 80 GiB, 85899345920 bytes, 167772160 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xbccac24e

Device     Boot   Start       End   Sectors Size Id Type
/dev/sda1  *       2048   2099199   2097152   1G 83 Linux
/dev/sda2       2099200 167768063 165668864  79G 8e Linux LVM




Disk /dev/mapper/cl-root: 76.5 GiB, 82137055232 bytes, 160423936 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/cl-swap: 2.5 GiB, 2684354560 bytes, 5242880 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
[root@XXXXX]# 

/dev/mapper/cl-root显示大小为 76.5 GiB。但df -h根目录显示的大小不同,为 22G:

[root@XXXXX]# df -h
Filesystem           Size  Used Avail Use% Mounted on
devtmpfs             1.9G     0  1.9G   0% /dev
tmpfs                1.9G     0  1.9G   0% /dev/shm
tmpfs                1.9G  9.5M  1.9G   1% /run
tmpfs                1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/mapper/cl-root   22G   22G   62M 100% /
/dev/sda1            976M  256M  654M  29% /boot
tmpfs                379M  1.2M  377M   1% /run/user/42
tmpfs                379M  4.6M  374M   2% /run/user/1000
[root@XXXXX]# 

我需要扩展我的根文件系统,因为它的空间不足。我无法为/dev/mapper/cl-root.以下是pvdisplay和 的结果lsblk

[root@XXXXX]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               cl
  PV Size               <79.00 GiB / not usable 1.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              20223
  Free PE               0
  Allocated PE          20223
  PV UUID               XXXXXX-XXXX-XXXX-XXXX-XXXX-XXXXX-XXXXX
   
[root@XXXXX]# lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda           8:0    0   80G  0 disk 
├─sda1        8:1    0    1G  0 part /boot
└─sda2        8:2    0   79G  0 part 
  ├─cl-root 253:0    0 76.5G  0 lvm  /
  └─cl-swap 253:1    0  2.5G  0 lvm  [SWAP]
sr0          11:0    1 1024M  0 rom  
[root@XXXXX]# 

lvdisplay显示以下输出:

[root@XXXXX]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/cl/swap
  LV Name                swap
  VG Name                cl
  LV UUID                000000000000000000000000000
  LV Write Access        read/write
  LV Creation host, time localhost, 2020-01-29 21:17:47 -0500
  LV Status              available
  # open                 2
  LV Size                2.50 GiB
  Current LE             640
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:1
   
  --- Logical volume ---
  LV Path                /dev/cl/root
  LV Name                root
  VG Name                cl
  LV UUID                00000000000000000000000000
  LV Write Access        read/write
  LV Creation host, time localhost, 2020-01-29 21:17:48 -0500
  LV Status              available
  # open                 1
  LV Size                <76.50 GiB
  Current LE             19583
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0
   
[root@XXXXX]# 

我使用的是 CentOS 8。我该怎么办?

答案1

您的 LV/dev/cl/root已达到最大可用大小。您需要的是调整文件系统的大小。如果您使用默认选项,则为xfs,因此命令应为:

xfs_growfs /此命令会将 xfs 卷扩展到所有可用空间。请记住,xfs体积无法缩小。

使用xfs_growfs / -D size,您可以指定要扩展的大小,但它以文件系统块表示,而不是 MB/GB。xfs_info命令将显示块大小。

此命令将帮助您查看 LV 大小和 xfs 卷大小之间的差异:
lsblk -o name,fstype,size,fssize,mountpoint,label,model,vendor

另外pvs,分别对 LVM 物理卷、卷组和逻辑卷进行了很好的总结vgslvs

相关内容