resize2fs: Bad magic number in super-block while trying to open ….

… or how to resize a file system on CentOS 7. Due to moving my home partition to a new disk I gained some space back from the logical volume home. After deleting it I thought that it would be a good idea to add those additional 10GB to the my root disk.
I started with:

[root@jcdesk Desktop]# lvdisplay
--- Logical volume ---
  LV Path                /dev/centos/root
  LV Name                root
  VG Name                centos
  LV UUID                jxyjgx-veql-Hzxk-1ynz-b6i2-BQoe-xGhrCb
  LV Write Access        read/write
  LV Creation host, time jc-desk.luht.scot.nhs.uk, 2015-06-11 ....
  LV Status              available
  # open                 1
  LV Size                105.00 GiB
  Current LE             26879
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

The size of the root volume was 105GiB. The additional space should be 10GiB.

[root@jcdesk Desktop]# lvextend -l +100%FREE /dev/centos/root
  Size of logical volume centos/root changed from 105.00 GiB
(26879 extents) to 115.00 GiB (29440 extents).
  Logical volume root successfully resized

That added all the free space in the volume group to my root volume.

[root@jcdesk ~]# lvdisplay /dev/centos/root
  --- Logical volume ---
  LV Path                /dev/centos/root
  LV Name                root
  VG Name                centos
  LV UUID                jxyjgx-veql-Hzxk-1ynz-b6i2-BQoe-xGhrCb
  LV Write Access        read/write
  LV Creation host, time jc-desk.luht.scot.nhs.uk, 2015-06-11 ...
  LV Status              available
  # open                 1
  LV Size                115.00 GiB
  Current LE             29440
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

Strike !!! So far so good. Now lets resize the file system.

[root@jcdesk Desktop]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root  105G  7.0G   98G   7% /

I tried to resize the file system to the new size.

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

Oops !!!!! 8-o
I took me a while to find out that LVM is using xfs as their file system.

[root@jcdesk ~]# mount | grep centos-root
/dev/mapper/centos-root on / type xfs (rw,relatime,...

Xfs comes with its own command set.

[root@jcdesk ~]# xfs [tab][tab]
xfs_admin      xfs_copy       xfsdump        xfs_freeze
xfs_growfs     xfsinvutil     xfs_logprint   xfs_metadump
xfs_ncheck     xfs_repair     xfs_rtcp     xfs_bmap
xfs_db         xfs_estimate   xfs_fsr      xfs_info
xfs_io         xfs_mdrestore  xfs_mkfile     xfs_quota
xfsrestore

So instead of using the resize2fs command I had to use the xfs_growfs command.

[root@jcdesk ~]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=256 agcount=4, agsize=
6881024 blks
         =              sectsz=512   attr=2, projid32bit=1
         =              crc=0        finobt=0
data     =              bsize=4096   blocks=27524096, imaxpct=25
         =              sunit=0      swidth=0 blks
naming   =version 2     bsize=4096   ascii-ci=0 ftype=0
log      =internal      bsize=4096   blocks=13439, version=2
         =              sectsz=512   sunit=0 blks, lazy-count=1
realtime =none          extsz=4096   blocks=0, rtextents=0
data blocks changed from 27524096 to 30146560

A final check:

[root@jcdesk ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root  115G  7.0G  108G   7% /

….. done.

You may also like...