如何在线调整xfs文件系统上的根分区大小



当我尝试使用以下方法扩展根分区时

[root@oel7 ~]# resize2fs /dev/root_vg/root
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block while trying to open /dev/root_vg/root
Couldn't find valid filesystem superblock.

我无法对上面最后一行的错误做同样的事情。

您正在处理XFS文件系统,在这种情况下,您需要使用XFS_growfs而不是resize2fs。执行此任务需要两个命令:

# growpart /dev/sda 1

growtpart用于将sda1分区扩展到整个sda磁盘。

# xfs_growfs -d /dev/sda1

xfs_growfs用于调整大小和应用更改。

# df -h

注意:你可以检查这个脚本:https://gist.github.com/OmarTrigui/7d6ec92c8f2ef83ba15b80e30fb6a5be

Environment :
    [root@oel7 ~]# uname -a
    Linux oel7.localdomain 3.8.13-55.1.6.el7uek.x86_64 #2 SMP Wed Feb 11 14:18:22 PST 2015 x86_64 x86_64 x86_64 GNU/Linux
Steps :
    1)  [root@oel7 ~]# df -h
    Filesystem                         Size  Used Avail Use% Mounted on
    /dev/mapper/root_vg-root           5.0G  4.5G  548M  90% /
    2)   
PV /dev/sda2   VG root_vg     lvm2 [6.00 GiB / 0    free]
    as here it shows that there is no space left on root_vg volume group, so first i need to extend VG 
    3)  [root@oel7 ~]# vgextend root_vg /dev/sdb5
      Volume group "root_vg" successfully extended
    4)  [root@oel7 ~]# pvscan
        PV /dev/sda2   VG root_vg     lvm2 [6.00 GiB / 0    free]
        PV /dev/sdb5   VG root_vg     lvm2 [2.00 GiB / 2.00 GiB free]
    5)  Now extend the logical volume 
    [root@oel7 ~]# lvextend -L +1G /dev/root_vg/root
      Size of logical volume root_vg/root changed from 5.00 GiB (1280 extents) to 6.00 GiB (1536 extents).
      Logical volume root successfully resized
    6)  [root@oel7 ~]# resize2fs /dev/root_vg/root
    resize2fs 1.42.9 (28-Dec-2013)
    resize2fs: Bad magic number in super-block while trying to open /dev/root_vg/root
    Couldn't find valid filesystem superblock.
    as root partition is not a ext* partiton so , you resize2fs will not work for you.
    7)  to check the filesystem type of a partition 
    [root@oel7 ~]# df -Th
    Filesystem                        Type      Size  Used Avail Use% Mounted on
    /dev/mapper/root_vg-root          xfs       6.0G  4.5G  1.6G  75% /
    devtmpfs                          devtmpfs  481M     0  481M   0% /dev
    tmpfs                             tmpfs     491M   80K  491M   1% /dev/shm
    tmpfs                             tmpfs     491M  7.1M  484M   2% /run
    tmpfs                             tmpfs     491M     0  491M   0% /sys/fs/cgroup
    /dev/mapper/data_vg-home          xfs       3.5G  2.9G  620M  83% /home
    /dev/sda1                         xfs       497M  132M  365M  27% /boot
    /dev/mapper/data_vg01-data_lv001  ext3      4.0G  2.4G  1.5G  62% /sybase
    /dev/mapper/data_vg02-backup_lv01 ext3      4.0G  806M  3.0G  22% /backup
    above command shows that root is an xfs filesystem , so we are sure that we need to use xfs_growfs command to resize the partition.
    8)  [root@oel7 ~]# xfs_growfs /dev/root_vg/root
    meta-data=/dev/mapper/root_vg-root isize=256    agcount=4, agsize=327680 blks
             =                       sectsz=512   attr=2, projid32bit=1
             =                       crc=0        finobt=0
    data     =                       bsize=4096   blocks=1310720, 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 blocks changed from 1310720 to 1572864
    [root@oel7 ~]# df -Th
    Filesystem                        Type      Size  Used Avail Use% Mounted on
    /dev/mapper/root_vg-root          xfs       6.0G  4.5G  1.6G  75% /

祝贺您的根分区成功联机扩展。

HTH

centos7不支持带有xfs的resize2fs,因此可以使用xfs_growfs

楼下注解:只是不支持xfs格式

 234  fdisk /dev/sda
  235  reboot
  236  fdisk /dev/sda
  237  pvcreate /dev/sda3
  238  reboot
  239  pvcreate /dev/sda3
  240  vgdisplay 
  241  vgextend centos /dev/sda3
  242  vgdisplay 
  243  lvextend -L +32768 /dev/mapper/centos-root 
  244  resize2fs /dev/mapper/centos-root 
  245  xfs_growfs /dev/mapper/centos-root 
  246  df -h
  247  vgdisplay 
  248  lvextend -L +32768 /dev/mapper/centos-root 
  249  xfs_growfs /dev/mapper/centos-root 

相关内容

  • 没有找到相关文章