resize centos分区

下了一个centos cloud image准备扩容。首先使用qemu-img resize2fs $centos_image +100G。在虚拟机中挂在centos image,使用parted改变分区大小,最后一步是使用resize2fs来更新文件系统超级块。但是却报错:

resize2fs /dev/vdb1
resize2fs 1.46.5 (30-Dec-2021)
resize2fs: Bad magic number in super-block while trying to open /dev/vdb1
Couldn't find valid filesystem superblock.

找了一下解决方案,发现是由于centos分区是xfs不是ext4所以应该使用xfs_growfs.

xfs_growfs /dev/vdb1
meta-data=/dev/vdb1              isize=256    agcount=4, agsize=524224 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0, sparse=0, rmapbt=0
         =                       reflink=0    bigtime=0 inobtcount=0
data     =                       bsize=4096   blocks=2096896, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=0
log      =internal log           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 2096896 to 26366931

成功。

posted @ 2024-04-02 14:50  半山随笔  阅读(9)  评论(0编辑  收藏  举报