Linux Red Hat Resize VM resize2fs - Couldn't find valid filesystem superblock

40,005

There are a bunch of steps you need to do, if memory serves.

Firstly, you'll need to use pvresize to expand the existing PV to the new top-of-partition.

Then you'll need to use lvresize or lvextend to resize the existing LV volume(s) into the enlarged PV.

Then you can use resize2fs to resize the file system(s) into the new enlarged volume(s).

Share:
40,005

Related videos on Youtube

zhouse28
Author by

zhouse28

Updated on September 18, 2022

Comments

  • zhouse28
    zhouse28 almost 2 years

    I'm trying to increase the size of a Linux Red Hat Virtual Machine by 10Gig. This is just on a Test Server I created that I'm trying to figure out.

    I increased the VM by 10 gig with this command [root@rh01 images]# qemu-img resize TestServer.img +10G Image resized.

    Then I followed this link https://gist.github.com/larsks/3933980 to finish

    I got all the way where the last command is resize2fs and I get this error

        [root@TestServer bmac]# resize2fs /dev/vda2
        resize2fs 1.41.12 (17-May-2010)
        resize2fs: Device or resource busy while trying to open /dev/vda2
        Couldn't find valid filesystem superblock.
    

    Here are all the steps I took:

        [root@rh01 admin]# virt-df -h /home/admin/images/TestServer.img 
        Filesystem                                Size       Used  Available  Use%
        TestServer.img:/dev/sda1                  484M        63M       396M   14%
        TestServer.img:/dev/vg_template/lv_root    40G       4.0G        34G   10%
        [root@rh01 admin]# virt-list-partitions -lh /home/admin/images/TestServer.img 
      /dev/sda1 ext4 500.0M
      /dev/sda2 pv 48.3G
        [root@rh01 admin]# cd images/
        [root@rh01 images]# qemu-img resize TestServer.img +10G
        Image resized.
        [root@rh01 images]# virt-df -h /home/admin/images/TestServer.img
        Filesystem                                Size       Used  Available  Use%
        TestServer.img:/dev/sda1                  484M        63M       396M   14%
    TestServer.img:/dev/vg_template/lv_root    40G       4.0G        34G   10%
    [root@rh01 images]# virt-list-partitions -lh /home/admin/images/TestServer.img 
    /dev/sda1 ext4 500.0M
    /dev/sda2 pv 48.3G
    
    [root@rh01 images]# ls -l TestServer.img 
    -rw-------. 1 root root 63166218240 May  1 08:55 TestServer.img
    
    [root@rh01 images]# df
    Filesystem                          1K-blocks       Used  Available Use% Mounted on
    /dev/mapper/vg_rh01-lv_root 51606140    7845612   41139088      17% /
    tmpfs                               99166276        296   99165980      1% /dev/shm
    /dev/sda1                           495844      92445     377799        20% /boot
    /dev/mapper/vg_rh01-lv_home 3305120248  494277716 2642952000  16% /home
    
    [root@rh01 images]# df -B 4k
    Filesystem            4K-blocks       Used Available Use% Mounted on
    /dev/mapper/vg_rh01-lv_root
                           12901535    1961403  10284772  17% /
    tmpfs                  24791569         74  24791495   1% /dev/shm
    /dev/sda1                123961      23112     94450  20% /boot
    /dev/mapper/vg_rh01-lv_home
                          826280062  123569429 660738000  16% /home
    
    [root@rh01 images]# df -h
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/mapper/vg_rh01-lv_root
                           50G  7.5G   40G  17% /
    tmpfs                  95G  296K   95G   1% /dev/shm
    /dev/sda1             485M   91M  369M  20% /boot
    /dev/mapper/vg_rh01-lv_home
                          3.1T  472G  2.5T  16% /home
    
    
    
    Boot VM and Login 
    [bmac@TestServer ~]$ su
    Password: 
    [root@TestServer bmac]# cd
    [root@TestServer ~]# fdisk /dev/vda
    
    WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
             switch off the mode (command 'c') and change display units to
             sectors (command 'u').
    
    Command (m for help): p
    
    Disk /dev/vda: 63.2 GB, 63166218240 bytes
    16 heads, 63 sectors/track, 122392 cylinders
    Units = cylinders of 1008 * 512 = 516096 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x000cd4ad
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/vda1   *           3        1018      512000   83  Linux
    Partition 1 does not end on cylinder boundary.
    /dev/vda2            1018      101588    50686976   8e  Linux LVM
    Partition 2 does not end on cylinder boundary.
    
    Command (m for help): d
    Partition number (1-4): 2
    
    Command (m for help): n
    Command action
       e   extended
       p   primary partition (1-4)
    p
    Partition number (1-4): 2
    First cylinder (1-122392, default 1): 1018
    Last cylinder, +cylinders or +size{K,M,G} (1018-122392, default 122392): 122392
    
    Command (m for help): p
    
    Disk /dev/vda: 63.2 GB, 63166218240 bytes
    16 heads, 63 sectors/track, 122392 cylinders
    Units = cylinders of 1008 * 512 = 516096 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x000cd4ad
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/vda1   *           3        1018      512000   83  Linux
    Partition 1 does not end on cylinder boundary.
    /dev/vda2            1018      122392    61172544   83  Linux
    
    Command (m for help): w
    The partition table has been altered!
    
    Calling ioctl() to re-read partition table.
    
    WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
    The kernel still uses the old table. The new table will be used at
    the next reboot or after you run partprobe(8) or kpartx(8)
    Syncing disks.
    
    [bmac@TestServer ~]$ su
    Password: 
    [root@TestServer bmac]# df -h /
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/mapper/vg_template-lv_root
                           40G  4.0G   34G  11% /
    
    [root@TestServer bmac]# resize2fs /dev/vda2
    resize2fs 1.41.12 (17-May-2010)
    resize2fs: Device or resource busy while trying to open /dev/vda2
    Couldn't find valid filesystem superblock.
    [root@TestServer bmac]# resize4fs /dev/vda2
    bash: resize4fs: command not found
    
        [root@TestServer bmackenzie]# resize2fs /dev/mapper/vg_template-lv_root 
        resize2fs 1.41.12 (17-May-2010)
        The filesystem is already 10622976 blocks long.  Nothing to do!
    
    [root@TestServer bmac]# df -h
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/mapper/vg_template-lv_root
                           40G  4.0G   34G  11% /
    tmpfs                 3.9G   80K  3.9G   1% /dev/shm
    /dev/vda1             485M   64M  397M  14% /boot
    

    Thanks for the info MadHatter. here are the exact steps I performed that worked for me in case anyone is looking for this

        [root@TestServer bmac]# pvresize /dev/vda2
        Physical volume "/dev/vda2" changed
        1 physical volume(s) resized / 0 physical volume(s) not resized
    
        [root@TestServer bmac]# lvextend /dev/mapper/vg_template-lv_root -L +10G
        Extending logical volume lv_root to 50.52 GiB
        Logical volume lv_root successfully resized
    
        [root@TestServer bmackenzie]# resize2fs /dev/mapper/vg_template-lv_root
        resize2fs 1.41.12 (17-May-2010)
        Filesystem at /dev/mapper/vg_template-lv_root is mounted on /; on-line resizing required
        old desc_blocks = 3, new_desc_blocks = 4
        Performing an on-line resize of /dev/mapper/vg_template-lv_root to 13244416 (4k) blocks.
        The filesystem on /dev/mapper/vg_template-lv_root is now 13244416 blocks long.
    
    • MadHatter
      MadHatter about 10 years
      Your df output makes it pretty clear there's no filesystem on /dev/vda2 (instead, it seems to be the physical storage for one or more LVM volumes). Why are you trying to resize it?
    • zhouse28
      zhouse28 about 10 years
      I have another VM that I'm running out of space on so I'm trying to figure this out on a test server before I apply the process to the actual server.
    • MadHatter
      MadHatter about 10 years
      Fine, but you still can't use resize2fs on an LVM PV.
    • zhouse28
      zhouse28 about 10 years
      So what is the final step I need to do to use the extra 10 gig of space? I see in the fdisk it shows the /dev/vda2 increased from 50686976 to 61172544.
    • MadHatter
      MadHatter about 10 years
      See my answer. By the way, in case you don't know, it's the done thing around these parts that when you're happy with an answer to your question you accept it by clicking on the "tick" outline next to it. That drives the SF reputation system both for you and the author of the accepted answer, and stops the question floating around forever like a querulous albatross. My apologies if you already knew that.
  • zhouse28
    zhouse28 about 10 years
    Are these steps performed on the main host or logged into the virtual machine?
  • MadHatter
    MadHatter about 10 years
    On the VM. As far as it's concerned, it's just suddenly acquired a slightly bigger HDD, and needs to make use of it.
  • Darcinon
    Darcinon over 8 years
    This was a great help, but it turned out my machine was using XFS instead of ext4, so I had to use xfs_growfs instead of resize2fs.This was with RHEL 7 on a virtual machine.