How to resize root partition online , on xfs filesystem?

pathak.pk picture pathak.pk · Jul 2, 2016 · Viewed 30.6k times · Source

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.

Answer

Omar_0x80 picture Omar_0x80 · Feb 9, 2017

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