xfs_growfs:尝试增大 ol-root 时,不是已安装的 xfs 文件系统

xfs_growfs:尝试增大 ol-root 时,不是已安装的 xfs 文件系统

我有 25 多个运行 OL7.5 的虚拟机。随着它们的增长/用途的改变,我有时需要为它们添加更多硬盘。

我之前曾多次为 ol-root 和 ol-swap 添加空间,总结如下:

fdisk to create partition
partprobe -s
pvcreate /dev/sdb1
vgextend ol /dev/sdb1
pvscan
lvextend /dev/mapper/ol-root /dev/sdb1

但在某些虚拟机上,我无法再将该 ol-root 空间添加到文件系统:

xfs_growfs /dev/mapper/ol-root
Error:   xfs_growfs: /dev/mapper/ol-root is not a mounted XFS filesystem

我之前在同一个虚拟机上做过很多次,都没有问题。在这个虚拟机上,我从头开始构建,并添加了 sda3 和 sda4。

在这个特定的盒子上,我需要将 11g 升级到 18c。我需要 10G ol-swap 和更多 HDD 来安装 18c 数据库。

$ lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sr0          11:0    1 1024M  0 rom
sda           8:0    0   55G  0 disk
├─sda4        8:4    0   10G  0 part
│ └─ol-root 252:0    0   46G  0 lvm  /
├─sda2        8:2    0   15G  0 part
│ ├─ol-swap 252:1    0    8G  0 lvm  [SWAP]
│ └─ol-root 252:0    0   46G  0 lvm  /
├─sda3        8:3    0   29G  0 part
│ ├─ol-swap 252:1    0    8G  0 lvm  [SWAP]
│ └─ol-root 252:0    0   46G  0 lvm  /
└─sda1        8:1    0    1G  0 part /boot


$ df -Th /dev/mapper/ol-root
Filesystem          Type  Size  Used Avail Use% Mounted on
/dev/mapper/ol-root xfs    46G   45G  1.5G  97% /

请问有什么建议吗?

非常感谢

达伦

ps 我试图扩展的盒子是上述虚拟机的克隆。在多次尝试扩展文件系统后,我关闭了该盒子。即使我没有添加 sdb 分区,源盒子也存在与 xfs_growfs 相同的问题。当没有空间可分配时,xfs_growfs 应该返回一个非常不同的错误。

答案1

您需要针对挂载点而不是 LVM 映射器来执行 xfs_growfs 命令。这似乎是一个新“功能”,因为我们以前能够在映射器上使用 xfs_growfs。

但是手册页具体提到了挂载点:

xfs_growfs(8) 系统管理员手册 xfs_growfs(8)

名称 xfs_growfs、xfs_info - 扩展 XFS 文件系统

摘要 xfs_growfs [ -dilnrx ] [ -D 大小 ] [ -e rtextsize ] [ -L 大小 ] [ -m maxpct ] [ -t mtab ] [ -R 大小 ]挂载点

答案2

好的,执行 -L 和 xxfs_growfs 已成功。VM 有 ol-root 6GB 可用空间

实际虚拟机的代码,分步说明:在 vSphere 中为新 HDD 添加 16GB

# fdisk -l

Disk /dev/sda: 59.1 GB, 59055800320 bytes, 115343360 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: 0x000cbfb1

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200    33554431    15727616   8e  Linux LVM
/dev/sda3        33554432    94371839    30408704   8e  Linux LVM
/dev/sda4        94371840   115343359    10485760   8e  Linux LVM

Disk /dev/sdb: 17.2 GB, 17179869184 bytes, 33554432 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/ol-root: 49.4 GB, 49379540992 bytes, 96444416 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/ol-swap: 8589 MB, 8589934592 bytes, 16777216 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

# ls /sys/class/scsi_device
1:0:0:0  2:0:0:0  2:0:1:0
# echo 1 > /sys/class/scsi_device/1\:0\:0\:0/device/rescan
# echo 1 > /sys/class/scsi_device/2\:0\:0\:0/device/rescan
# echo 1 > /sys/class/scsi_device/2\:0\:1\:0/device/rescan

fdisk /dev/sdb,n,p,1,t,1,8e,w

# fdisk -l

Disk /dev/sda: 59.1 GB, 59055800320 bytes, 115343360 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: 0x000cbfb1

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200    33554431    15727616   8e  Linux LVM
/dev/sda3        33554432    94371839    30408704   8e  Linux LVM
/dev/sda4        94371840   115343359    10485760   8e  Linux LVM

Disk /dev/sdb: 17.2 GB, 17179869184 bytes, 33554432 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: 0x86979f60

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048    33554431    16776192   8e  Linux LVM

Disk /dev/mapper/ol-root: 49.4 GB, 49379540992 bytes, 96444416 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/ol-swap: 8589 MB, 8589934592 bytes, 16777216 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

零件探测

# partprobe -s
/dev/sda: msdos partitions 1 2 3 4
/dev/sdb: msdos partitions 1

建立

# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created.

扩展

# vgextend ol /dev/sdb1
  Volume group "ol" successfully extended

扫描

# pvscan
  PV /dev/sda2   VG ol              lvm2 [<15.00 GiB / 0    free]
  PV /dev/sda3   VG ol              lvm2 [<29.00 GiB / 0    free]
  PV /dev/sda4   VG ol              lvm2 [<10.00 GiB / 0    free]
  PV /dev/sdb1   VG ol              lvm2 [<16.00 GiB / <16.00 GiB free]
  Total: 4 [69.98 GiB] / in use: 4 [69.98 GiB] / in no VG: 0 [0   ]

lvextend

# lvextend -L+16380M /dev/mapper/ol-root /dev/sdb1
  Size of logical volume ol/root changed from <45.99 GiB (11773 extents) to 61.98 GiB (15868 extents).
  Logical volume ol/root successfully resized.

xfs_growfs

# xfs_growfs /
meta-data=/dev/mapper/ol-root    isize=256    agcount=14, agsize=877824 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0 spinodes=0 rmapbt=0
         =                       reflink=0
data     =                       bsize=4096   blocks=12055552, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
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 from 12055552 to 16248832
# df -h
Filesystem           Size  Used Avail Use% Mounted on
devtmpfs             4.8G     0  4.8G   0% /dev
tmpfs                4.8G     0  4.8G   0% /dev/shm
tmpfs                4.8G  9.4M  4.8G   1% /run
tmpfs                4.8G     0  4.8G   0% /sys/fs/cgroup
/dev/mapper/ol-root   62G   42G   21G  68% /
/dev/sda1           1014M  419M  596M  42% /boot
tmpfs                973M   12K  973M   1% /run/user/42
tmpfs                973M     0  973M   0% /run/user/0

我遵循了这一点: https://ma.ttias.be/increase-expand-xfs-filesystem-in-red-hat-rhel-7-cento7/

为什么以前可以起作用,但现在却不行了?

相关内容