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.

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

  1. adison says:

    Thanks, you saved my friday and weekend

    • Hui says:

      Thanks, this blog is super helpful! It hit the nails and resolved my issue on Veteran’s Day.

      Another way to find out the type is to run blkid command.
      [root@msdlva-ctwwik01 appdev]# blkid /dev/mapper/rhel-root
      /dev/mapper/rhel-root: UUID=”xxx” TYPE=”xfs”

      [root@wik01 appdev]# mount | grep root
      /dev/mapper/rhel-root on / type xfs (rw,noatime,nodiratime,attr2,inode64,noquota)

  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. 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:)

  12. Slava says:

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

  13. jongbyte says:

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

  14. Vinodh says:

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

  15. Eitan says:

    Thanks for the post !

  16. Jose says:

    Thanks man you saved my life hahahah

  17. Reginaldo Ramos says:

    Saved my job, fantastic … thank you very much.

  18. kennedy says:

    Thanks for the post

  19. Mario says:

    Excelent!!!

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

  20. Gino says:

    Thank you man, this saved my evening! ๐Ÿ™‚

  21. Imran says:

    Hi,
    Thanks. This was a lifesaver ๐Ÿ™‚

  22. Maulana says:

    Many thank’s

    Solved my problem

  23. Tiago Rocha says:

    Perfect!!!

    Thanks!!!

  24. sandeep says:

    Thanks a lot,very helpfull

  25. Alex says:

    Perfect Thank you very much!

  26. Francesco Montani says:

    Thanks a lot! In 2018 your post continue to help someone…ME…. ๐Ÿ™‚

  27. Palash says:

    Thanks, Great Help ๐Ÿ™‚

  28. Pavel Perna says:

    Great, finally a worthy solution. You saved my day

  29. Nuno Nabo says:

    Perfect!!! You save my weekend!!! Thanks a lot!!!

  30. Chok says:

    Great ! solve my problem.

  31. Y V Ravi Kumar says:

    Saved my Evening Brother !!! Good solution

  32. Andrea says:

    Thanks…..my idol

  33. inger says:

    Thank you for this, I got some info from Amazon while trying to grow a root disk but the advice was based on their Amazon Linux AMI that used a different filesystem type and boy howdy, was _that_ a scary error message to get!

  34. Dominique says:

    Many thanks for this post !

  35. djcarlos2001 says:

    Very helpful post, many thanks.

  36. Alvaro says:

    Gracias, excelente informacion

  37. Paola says:

    Thanks so much!!!!

  38. Hard DM says:

    Thx a lot

  39. flavio nascimento says:

    he was save me

  40. Victor Nyakutya says:

    I was also stranded.
    The post did wonders for me.
    Thanks a lot

  41. Allen Bell says:

    Thank you so much! I had beem struggling with this for hours!

  42. Suryakant says:

    Hi,

    Thank you so much for your help. XFS works in a different way

  43. Bui says:

    Thanks so much!!

  44. Gireesh Tangudu says:

    Thank you very much….it saved my day

  45. Tahsin Mutlu says:

    Thank you so much. You’re save me ๐Ÿ™‚

  46. Xavier Automation says:

    Merci infiniment รงa m’a beaucoup aidรฉ !

  47. Bill Silvester says:

    Many thanks for your post – saved a lot of frustration!

Leave a Reply

Your email address will not be published.