如何减小分区大小+lvm

如何减小分区大小+lvm

在 /var 上,我们在 Linux Red Hat 服务器上有 101G

grep var /etc/fstab
/dev/mapper/vg10-00_var /var                    xfs     defaults        0 0

我们想把它减少到30G

 df -h /var
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/vg10-oo_var  101G  3.6G   98G   4% /var

所以我们这样做:

 lvreduce -L -70G /dev/mapper/vg10-00_var
 WARNING: Reducing active and open logical volume to 30.87 GiB
 THIS MAY DESTROY YOUR DATA (filesystem etc.)
 Do you really want to reduce lv_var? [y/n]: y
 Size of logical volume vg10/oo_var changed from 100.87 GiB (25822 extents) 
 to 30.87 GiB (7902 extents).
 Logical volume lv_var successfully resized.

但 xfs_grow 抱怨 - 数据大小 8091648 太小

xfs_growfs /dev/mapper/vg10-00_var
meta-data=/dev/mapper/vg10-00_var isize=256    agcount=26, agsize=1039872 blks
     =                       sectsz=512   attr=2, projid32bit=1
     =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=26441728, imaxpct=25
      =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
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 size 8091648 too small, old size is 26441728

为什么?

答案1

我在这里看到两件事错误:

  • 您需要缩小文件系统减小其逻辑卷的大小。正如尽责地警告您的那样,如果不这样做,将会破坏文件系统的大部分内容(在您的情况下/var) 。lvreduce
  • XFS 文件系统无法收缩。

现在您应该擦除该/var分区并从备份中重新创建它,因为它的内容无论如何都已被删除。

相关内容