How to resize root partition online , on xfs filesystem? [closed]
Asked Answered
M

3

13

when I am trying to extend the root partition , using below method

[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.

I am unable to do the same with above last line error.

Merited answered 2/7, 2016 at 13:38 Comment(1)
Does this answer your question? resize2fs: Bad magic number in super-block while trying to openApportion
C
51

You're working on an XFS filesystem, in this case you need to use xfs_growfs instead of resize2fs. Two commands are needed to perform this task :

# growpart /dev/sda 1

growpart is used to expand the sda1 partition to the whole sda disk.

# xfs_growfs -d /dev/sda1

xfs_growfs is used to resize and apply the changes.

# df -h

NB: You can check this script : https://gist.github.com/OmarTrigui/7d6ec92c8f2ef83ba15b80e30fb6a5be

Carmancarmarthen answered 9/2, 2017 at 1:48 Comment(3)
Best answer to extend root partition online for XFS Filesystem. +10Hacking
This should be marked the correct answer. Seriously saved me such a headache.Clintonclintonia
Command xfs_info /dev/sda1 is also usefulBlancheblanchette
M
-2
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% /

Congratulations your root partition extended online successfully.

HTH

Merited answered 2/7, 2016 at 13:38 Comment(0)
W
-4

centos7 doesn't support resize2fs with xfs, so you can use 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 
Wow answered 27/8, 2018 at 7:35 Comment(1)
this is inaccurate - Centos 7 does, in fact, support resize2fs - just not with XFS filesystems. unix.com/man-page/centos/8/resize2fsClintonclintonia

© 2022 - 2024 — McMap. All rights reserved.