在 CentOS 7 虚拟机中似乎无法扩展 /dev/mapper/centos-root LV

在 CentOS 7 虚拟机中似乎无法扩展 /dev/mapper/centos-root LV

我总是用尽空间,/dev/mapper/centos-root作为临时解决方案,我删除了正在使用的文件/目录,但这妨碍了我的工作效率。我应该一开始就将 CentOS VM 设置为大于 20 GB,但现在为时已晚。我关闭了 VM 并向 VMDK(虚拟磁盘)添加了 20GB,但我似乎无法让操作系统在需要的地方使用它,即/dev/mapper/centos-root 逻辑卷

以下是输出lsblk

    root@CentOS-7:/# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0   30G  0 disk
├─sda1            8:1    0    1G  0 part /boot
└─sda2            8:2    0   29G  0 part
  ├─centos-root 253:0    0   17G  0 lvm  /
  └─centos-swap 253:1    0    2G  0 lvm  [SWAP]
sr0              11:0    1 1024M  0 rom

pgs vgs和命令的输出lvs

    root@CentOS-7:/# pvs
  PV         VG     Fmt  Attr PSize   PFree
  /dev/sda2  centos lvm2 a--  <19.00g    0
root@CentOS-7:/# vgs
  VG     #PV #LV #SN Attr   VSize   VFree
  centos   1   2   0 wz--n- <19.00g    0
root@CentOS-7:/# lvs
  LV   VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root centos -wi-ao---- <17.00g
  swap centos -wi-ao----   2.00g

如您所见,我有 10 GB 的未分配空间。我需要将其应用于逻辑卷,但到目前为止我尝试过的所有方法都失败了。我认为我没有可用的空间,但不确定。我在存储虚拟机的主机上有足够的空间,我只需要知道如何让操作系统真正使用它。

在此处输入图片描述

答案1

已修复。交换分区挡住了路。一旦我删除它我可以/dev/mapper/centos-root像这样扩展:

#Delete & Create new volume
root@CentOS-7:/# fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): d
Partition number (1,2, default 2):
Partition 2 is deleted

Command (m for help): p

Disk /dev/sda: 96.6 GB, 96636764160 bytes, 188743680 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 label type: dos
Disk identifier: 0x000b14c7

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200   125829119    61864960   8e  Linux LVM

Command (m for help): n
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p):
Using default response p
Partition number (3,4, default 3):
First sector (125829120-188743679, default 125829120):
Using default value 125829120
Last sector, +sectors or +size{K,M,G} (125829120-188743679, default 188743679):
Using default value 188743679
Partition 3 of type Linux and of size 30 GiB is set

Command (m for help): t
Partition number (1-3, default 3):
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): wq
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

然后我就跑了……

pvresize /dev/sda2
lvextend /dev/mapper/centos-root -l +100%FREE
xfs_growfs /dev/mapper/centos-root

相关内容