Home » Operating Systems » Linux » CentOS, Linux, RedHat » Linux: Extending Partition in LVM

Linux: Extending Partition in LVM

  • Start off by running the df -h command to list all the partitions on the system
  • [root@oraprod ~]# df -h
    Filesystem            			Size  Used Avail Use% Mounted on
    /dev/mapper/ORAPROD_VG00-LogVol00	992M  395M  546M  42% /
    /dev/mapper/ORAPROD_VG00-LogVol05	992M   37M  904M   4% /opt
    /dev/mapper/ORAPROD_VG00-LogVol01	2.0G   68M  1.8G   4% /tmp
    /dev/mapper/ORAPROD_VG00-LogVol06	2.0G  324M  1.6G  18% /home
    /dev/mapper/ORAPROD_VG00-LogVol04	2.0G  172M  1.7G  10% /var
    /dev/mapper/ORAPROD_VG00-LogVol03	3.0G  2.3G  563M  81% /usr
    /dev/mapper/ORAPROD_VG00-LogVol07	9.7G  8.9G  329M  97% /u01
    /dev/mapper/ORAPROD_VG01-LogVol08	20G   16G  3.0G  85% /backup
    /dev/mapper/ORAPROD_VG02-LogVol00	9.9G  151M  9.2G   2% /ggs
    /dev/sda1              			99M   17M   78M  18% /boot
    tmpfs                  			10G  4.9G  5.2G  49% /dev/shm
    [root@oraprod ~]#
    
  • In our case, we need to extend the /u01 partition. Currently the size for this partition is of 10GB and we need to extend it to 11GB
  • Verify that you have sufficient free space on the volume group to be used for this extension
  • [root@oraprod ~]# vgdisplay ORAPROD_VG00
      --- Volume group ---
      VG Name               ORAPROD_VG00
      System ID
      Format                lvm2
      Metadata Areas        1
      Metadata Sequence No  12
      VG Access             read/write
      VG Status             resizable
      MAX LV                0
      Cur LV                8
      Open LV               8
      Max PV                0
      Cur PV                1
      Act PV                1
      VG Size               39.88 GB
      PE Size               32.00 MB
      Total PE              1276
      Alloc PE / Size       1184 / 37.00 GB
      Free  PE / Size       92 / 2.88 GB
      VG UUID               EcusxF-Kr0e-3vvA-hV4e-77XO-2HRJ-1wNasI
    
    [root@oraprod ~]#
  • We still have 2.88GB of free space so we can go ahead and extend the /u01 partition.
  • Confirm the partition size for the /u01 partition
  • [root@oraprod ~]# lvdisplay /dev/ORAPROD_VG00/LogVol07
      --- Logical volume ---
      LV Name                /dev/ORAPROD_VG00/LogVol07
      VG Name                ORAPROD_VG00
      LV UUID                gPXtBa-r9V1-qHYg-Zi2R-bPA3-o381-vQIrzV
      LV Write Access        read/write
      LV Status              available
      # open                 1
      LV Size                10.00 GB
      Current LE             320
      Segments               2
      Allocation             inherit
      Read ahead sectors     auto
      - currently set to     256
      Block device           253:6
    
    [root@oraprod ~]#
  • Extend partition
  • [root@oraprod ~]# lvresize -L +1GB /dev/ORAPROD_VG00/LogVol07
      Extending logical volume LogVol07 to 11.00 GB
      Logical volume LogVol07 successfully resized
    [root@oraprod ~]#
  • Extend file system
  • [root@oraprod ~]# resize2fs -p /dev/ORAPROD_VG00/LogVol07
    resize2fs 1.39 (29-May-2006)
    Filesystem at /dev/ORAPROD_VG00/LogVol07 is mounted on /u01; on-line resizing required
    Performing an on-line resize of /dev/ORAPROD_VG00/LogVol07 to 2883584 (4k) blocks.
    The filesystem on /dev/ORAPROD_VG00/LogVol07 is now 2883584 blocks long.
    
    [root@oraprod ~]#
  • Verify that the extend was successful
  • [root@oraprod ~]# lvdisplay /dev/ORAPROD_VG00/LogVol07
      --- Logical volume ---
      LV Name                /dev/ORAPROD_VG00/LogVol07
      VG Name                ORAPROD_VG00
      LV UUID                gPXtBa-r9V1-qHYg-Zi2R-bPA3-o381-vQIrzV
      LV Write Access        read/write
      LV Status              available
      # open                 1
      LV Size                11.00 GB
      Current LE             352
      Segments               2
      Allocation             inherit
      Read ahead sectors     auto
      - currently set to     256
      Block device           253:6
    
    [root@oraprod ~]#

    Leave a Reply