linux - resize a volume

28
2014-05
  • paulcap1

    I would like to increase lv_home to 20G and increase lv_root to 120G. In VMware I extended the harddrive to 200G. You can see that below in .host:/

    Filesystem            Size  Used Avail Use% Mounted on
    /dev/mapper/VolGroup-lv_root
                           48G   31G   15G  68% /
    tmpfs                 3.1G  100K  3.1G   1% /dev/shm
    /dev/sda1             485M   81M  379M  18% /boot
    /dev/mapper/VolGroup-lv_home
                          4.6G  198M  4.2G   5% /home
    .host:/               239G  110G  130G  46% /mnt/hgfs
    

    I tried to run

    resize2fs /dev/mapper/VolGroup-lv_home 20G
    

    But it didn't work

    I tried to run

    lvextend -L 120G /dev/mapper/VolGroup-lv_root
    

    But it didn't work

    any ideas of how to add the space from .host over to lv_home?

  • Answers
  • davidgo

    From what I can see from your LVS command, your LVM partition is only 54.1 gigs, all of which is allocated.

    Am I correct in understanding that this is actually a VM, and you expanded the size of the physical disk on the VM to 200 GIGS ? If that is the case you need to first grow the PV, then the VG, then the LVs. (PV=Physical Volume, VG=Volume Group, LV=Logical Volume)

    I've not tried these commands (so back up, your data is at risk !!!), but try the following -

    1. Create a new partition with the free space (for example, use FDISK and create sda2 - if that does not work, please please show me the result of "fdisk -l /dev/sda")
    2. Assuming the new partition is sda3 [ i'm guessing here, you might have a swap ] do the following

    3. Create a new Physical Volume using sda3

    pvcreate /dev/sda3  
    
    1. Add the new partition to your volume group
    vgextend Volgroup /dev/sda3
    
    1. Expand your partition
    lvextend -L 120G /dev/mapper/VolGroup-lv_root
    
    1. Resize the partition
    resize2fs /dev/mapper/VolGroup-lv_root
    

    Note that these commands are untested and will probably need a bit of tweeking.

    Also, an alternative to the pvcreate and lvextend command would be to resize /dev/sda1 (if thats an option with Fdisk) and then grow the physical volume.


  • Related Question

    linux - List all physical volumes associated to a volume group
  • Beaming Mel-Bin

    Maybe I'm missing something obvious but I do not see it listed in vgdisplay.


  • Related Answers
  • Scott

    You can try this format:

    # pvdisplay -C --separator '  |  ' -o pv_name,vg_name
    

    You get something like what I think you're looking for:

      PV  |  VG
      /dev/sda2  |  vg_c6srv3
      /dev/sdb2  |  vg_c6srv3
      /dev/sdc2  |  vg_c6srv3
      /dev/sdd1  |  vg_ora112
      /dev/sdd2  |  
      /dev/sdd3  |  vg_ora112
      /dev/sdd5  |  vg_ora101
      /dev/sde1  |  vg_ora112
      /dev/sde2  |  vg_ora112
      /dev/sde3  |  
      /dev/sde4  |  vg_ora101
      /dev/sdf1  |  vg_ora112
      /dev/sdf2  |  
      /dev/sdf3  |  vg_ora112
      /dev/sdf5  |  vg_ora101
    

    Hope that helps.

  • Ignacio Vazquez-Abrams

    pvdisplay shows the VG each PV belongs to.

  • Craig
    vgdisplay -v <volume_group_name> 2> /dev/null | awk '/PV Name/ {print $3}'