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.

About Juergen Caris

I am 54yo, MSc(Dist) and BSc in Computer Science, German and working as a Senior Server Engineer for the NHS Lothian. I am responsible for the patient management system, called TrakCare. I am a UNIX/Linux guy, working in this sector for more than 20 years now. I am also interested in robotics, microprocessors, system monitoring, Home automation and programming.
This entry was posted in Beginner, Linux. Bookmark the permalink.

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

  1. adison says:

    Thanks, you saved my friday and weekend

  2. Robert Plant says:

    Many thanks Juergen! I was stumbling at resize2fs and quickly found your post allowing me to complete my partition resizing.

    Many kudo!
    Robert

  3. deepthi says:

    Thanks a lot,very helpfull

  4. deo says:

    Thank you!

  5. kamal Chikh echioukh says:

    Many thanks, very helpfull… it saves me time…

  6. Denzi Junaidi says:

    Thanks for your tutorial..

  7. ifaii says:

    thanks, so good!

  8. Dave Fouts says:

    Looked everywhere.. thanks for that info.. did not see xfs_growfs anywhere.

  9. bernie says:

    Thanks.
    Exactly what I was looking for…

  10. Chris says:

    phew thanks for posting this!

  11. Mahdi Ansari says:

    thanks for that info

  12. sergei says:

    Thank you for your solution! I was in panic because I didn’t understand what is wrong (I’m new in system administration). Thank you very much for this post:)

  13. Slava says:

    Thanks, it worked! Was trying to resolve the issue for hours…

  14. jongbyte says:

    you saved my day thank you so much i was stuck here until i found out of xfs.thanks again cheers!

  15. Vinodh says:

    Thanks a lot for sharing, worked for my CentOS7 VM image.

  16. Eitan says:

    Thanks for the post !

  17. Jose says:

    Thanks man you saved my life hahahah

  18. Reginaldo Ramos says:

    Saved my job, fantastic … thank you very much.

  19. kennedy says:

    Thanks for the post

  20. Mario says:

    Excelent!!!

    Thanks I take the same problem and solved thanks to you.

  21. Gino says:

    Thank you man, this saved my evening! :)

  22. Imran says:

    Hi,
    Thanks. This was a lifesaver :)

  23. Maulana says:

    Many thank’s

    Solved my problem

  24. Tiago Rocha says:

    Perfect!!!

    Thanks!!!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>