Resize Lvm

Home » CentOS » Resize Lvm
CentOS 12 Comments

I have a laptop that I put CentOS 7 on and I started out with a 30gig partition.  I resized the other part of the disk to allow more space for CentOS.  I then created an unformated partition in the available space,  ran

pvcreate /dev/sda4

vgextend lvname /dev/sda4

lvextend -L 184.46G /dev/lvname/root

but when I run:

sudo resize2fs /dev/lvname/root

I get:

resize2fs: Bad magic number in super-block while trying to open /dev/lvname/root Couldn’t find valid filesystem superblock.

How do I resize the volume?

Thanks,

-wes

12 thoughts on - Resize Lvm

  • I find it easiest to do lvextend -l 100%VG /dev/lvname/rootI find it easiest to do lvextend -l 100%VG /dev/lvname/root.
    (Then, if practical, and since it’s a laptop, I’m guessing it’s not a production machine), reboot from a livecd or whatever and doing e2fsk -f
    /dev/lvmname/root

    I don’t know if it will solve your issue, but may be worth trying.


    Scott Robbins PGP keyID EB3467D6
    ( 1B48 077D 66F6 9DB0 FDC2 A409 FA54 EB34 67D6 )
    gpg –keyserver pgp.mit.edu –recv-keys EB3467D6

  • oops, left out the rest…

    since you said C7, its quite likely its XFS not extXfs … if thats the case, then use:

    xfs_growfs /dev/lvname/root

  • sudo resize2fs /dev/lvname/root

    I get:

    resize2fs: Bad magic number in super-block while trying to open
    /dev/lvname/root Couldn’t find valid filesystem superblock.

    what file system type is this /dev/lvname/root ?

    I tried to find the type from blkid /dev/sda4 but that didn’t give me the info so I tried

    file -s /dev/dm-0

    and it says XFS

    So would I use xfs_growfs?

     


    john r pierce, recycling bits in santa cruz

  • bingo! xfs_growfs can be used with the file system online, I’m pretty sure resize2fs requires the file system to be offline (unmounted).

  • —– Original Message —–
    | | > I have a laptop that I put CentOS 7 on and I started out with a 30gig
    | > partition.  I resized the other part of the disk to allow more space for
    | > CentOS.  I then created an unformated partition in the available space,
    | >   ran
    | >
    | >
    | > pvcreate /dev/sda4
    | >
    | >
    | >
    | > vgextend lvname /dev/sda4
    | >
    | >
    | >
    | > lvextend -L 184.46G /dev/lvname/root
    |
    |
    | I find it easiest to do lvextend -l 100%VG /dev/lvname/rootI find it
    | easiest to do lvextend -l 100%VG /dev/lvname/root.
    | (Then, if practical, and since it’s a laptop, I’m guessing it’s not a
    | production machine), reboot from a livecd or whatever and doing e2fsk -f
    | /dev/lvmname/root
    |
    | I don’t know if it will solve your issue, but may be worth trying.
    |
    | >
    | >
    | > but when I run:
    | >
    | >
    | >
    | > sudo resize2fs /dev/lvname/root
    | >
    | >
    | > I get:
    | >
    | >
    | >
    | > resize2fs: Bad magic number in super-block while trying to open
    | > /dev/lvname/root
    | > Couldn’t find valid filesystem superblock.
    | >
    |
    | —
    | Scott Robbins
    | PGP keyID EB3467D6
    | ( 1B48 077D 66F6 9DB0 FDC2 A409 FA54 EB34 67D6 )
    | gpg –keyserver pgp.mit.edu –recv-keys EB3467D6

    if you use pass the ‘-r’ option to lvextend it will resize the volume for you based on the filesystem that is on the volume. no need to grow it manually afterward.


    James A. Peltier IT Services – Research Computing Group Simon Fraser University – Burnaby Campus Phone : 604-365-6432
    Fax : 778-782-3045
    E-Mail : jpeltier@sfu.ca Website : http://www.sfu.ca/itservices Twitter : @sfu_rcg Powering Engagement Through Technology

  • sudo resize2fs /dev/lvname/root

    I get:

    resize2fs: Bad magic number in super-block while trying to open
    /dev/lvname/root Couldn’t find valid filesystem superblock.

    what file system type is this /dev/lvname/root ?

    oops, left out the rest…

    since you said C7, its quite likely its XFS not extXfs … if thats the case, then use:

    xfs_growfs /dev/lvname/root

    Thanks for the tip.  I looked at man xfs_growfs and found -d option and so I used this and it worked:

    sudo xfs_growfs / -d


    john r pierce, recycling bits in santa cruz

  • Sorry, I missed that it would most likely be xfs. resize2fs doesn’t necessarily require it to be offline, but it does frequently (though not always, IIRC), suggest running e2fsk first which should definitely be done while it’s unmounted.

  • partition. I resized the other part of the disk to allow more space for CentOS. I then created an unformated partition in the available space, ran

    I found this:

    # lvextend -l +100%FREE /dev/myvg/testlv

    doing a search. What’s the difference between 100%VG and 100%FREE?

    Thanks,

    -wes

  • Online expansion of a filesystem is allowed by resize2fs. It is only for shrinking that being offline and running fsck is required.

    xfs does not allow shrinking at all.

  • For the special case of “100%” there is no difference. For values less than 100% with a non-empty VG, the two are quite different, e.g., (50% of VG) != (50% of the free space in VG).

  • Thanks. This is the first time I’m worked with the lvm commands. I
    thought VG was a typo for GB, but I see in the help commands for lvm:
    lvdisplay and vgdisplay – vg is volume group.

    -wes