Configure Logical Volumes on Oracle Linux

Send lab feedback

Configure Logical Volumes on Oracle Linux


Logical Volume Management allows combining multiple individual hard drives or disk partitions into a single volume group (VG). That volume group can then be subdivided into logical volumes (LV) or used as a single large volume. Standard file systems, such as EXT4 or XFS, can be created on a logical volume.

This tutorial will work with the Oracle Linux Volume Manager utilities to create, mount and increase the capacity of logical volumes.


  • Create a logical volume
  • Increase the capacity of a logical volume


Any Oracle Linux 8 system with the following configurations:

  • a non-root user with sudo permissions
  • additional block volumes for use with LVM

Setup Lab Environment

Note: When using the free lab environment, see Oracle Linux Lab Basics for connection and other usage instructions.

  1. If not already connected, open a terminal and connect via ssh to each instance mentioned above.

    ssh oracle@<ip_address_of_instance>
  2. Verify the block volumes exist.

    sudo lsblk

    The output for the free lab environment should show the /dev/sda for the existing file system, and the available disks /dev/sdb, /dev/sdc, and /dev/sdd.

Physical Volume (PV)

  1. Create the physical volumes (PV) using the available disks.

    sudo pvcreate -v /dev/sd{b,c}

    Run the command with the -v option to get verbose information.

  2. Verify PV creation.

    sudo pvs

    Example Output:

    [oracle@ol-node01 ~]$ sudo pvs
      PV         VG        Fmt  Attr PSize  PFree 
      /dev/sda3  ocivolume lvm2 a--  45.47g     0 
      /dev/sdb             lvm2 ---  50.00g 50.00g
      /dev/sdc             lvm2 ---  50.00g 50.00g

    For more detailed PV information run pvdisplay, or use pvscan to scan all disks for physical volumes.

Volume Group (VG)

  1. Create the volume group (VG) using the newly created physical volumes.

    sudo vgcreate -v myvolg /dev/sd{b,c}
  2. Verify VG creation.

    sudo vgs

    Example Output:

    [oracle@ol-node01 ~]$ sudo vgs
      VG             #PV #LV #SN Attr   VSize   VFree  
      myvolg           2   0   0 wz--n- 99.99g  99.99g
      ocivolume        1   2   0 wz--n- 45.47g      0 

    For more detailed VG information run vgdisplay, or use vgscan to scan all disks for volume groups.

Logical Volume (LV)

  1. Create the linear logical volume (LV).

    sudo lvcreate -v -L 5G -n myvol myvolg
    • -L: Total size of the RAID array.
    • -n: Name of the RAID array.

    Example Output:

    [oracle@ol-node01 ~]$ sudo lvcreate -v -L 5G -n myvol myvolg
      Archiving volume group "myvolg" metadata (seqno 1).
      Creating logical volume myvol
      Creating volume group backup "/etc/lvm/backup/myvolg" (seqno 2).
      Activating logical volume myvolg/myvol.
      activation/volume_list configuration setting not defined: Checking only host tags for myvolg/myvol.
      Creating myvolg-myvol
      Loading table for myvolg-myvol (252:2).
      Resuming myvolg-myvol (252:2).
      Wiping known signatures on logical volume myvolg/myvol.
      Initializing 4.00 KiB of logical volume myvolg/myvol with value 0.
      Logical volume "myvol" created.
  2. Verify LV creation.

    sudo lvdisplay myvolg

    The output shows all logical volumes contained within the myvolg VG.

    Example Output:

    [oracle@ol-node01 ~]$ sudo lvdisplay myvolg
      --- Logical volume ---
      LV Path                /dev/myvolg/myvol
      LV Name                myvol
      VG Name                myvolg
      LV UUID                1gfINq-AcWq-Bhys-gafP-21RL-x39A-vR6hqE
      LV Write Access        read/write
      LV Creation host, time ol-node01, 2022-05-20 23:27:38 +0000
      LV Status              available
      # open                 0
      LV Size                5.00 GiB
      Current LE             1280
      Segments               1
      Allocation             inherit
      Read ahead sectors     auto
      - currently set to     256
      Block device           252:2

    For condensed VG information run lvs, or use lvscan to scan all disks for volume groups.

  3. Display the LV type.

    sudo lvs -o name,segtype /dev/myvolg/myvol
    • The lvs command can take the full LV path as an option to narrow the results.

    Example Output:

    [oracle@ol-node01 ~]$ sudo lvs -o name,segtype /dev/myvolg/myvol
      LV    Type  
      myvol linear

Create a File System

  1. Create an EXT4 file system on the LV.

    sudo mkfs.ext4 -F /dev/myvolg/myvol
    • -F: Forces the overwrite of an existing file system.

Mount the LV

  1. Mount the file system.

    sudo mkdir -p /myvol
    sudo mount /dev/myvolg/myvol /myvol
  2. Report the file system disk usage.

    df -h

    Example Output:

    [oracle@ol-node01 ~]$ df -h
    Filesystem                         Size  Used Avail Use% Mounted on
    /dev/mapper/myvolg-myvol           4.9G   20M  4.6G   1% /myvol
  3. Update /etc/fstab.

    echo "/dev/mapper/myvolg-myvol /myvol ext4  defaults  0 0" | sudo tee -a /etc/fstab > /dev/null
  4. Unmount the LV.

    sudo umount /myvol
  5. Remount the LV using the /etc/fstab entry and verify the file system exists.

    sudo mount -a
    df -h

Increase the Size of a Logical Volume

Using the available free space in the VG, increase the LV size to 10G.

  1. Check if the VG has free space.

    sudo vgs

    The myvolg VG has 95G space free (VFree).

  2. Increase the LV capacity.

    sudo lvextend -L 10G -r myvolg/myvol
    • -r: Resizes the file system together with the logical volume using fsadm(8).

    Example Output:

    [oracle@ol-node01 ~]$ sudo lvextend -L 10G -r myvolg/myvol
      Size of logical volume myvolg/myvol changed from 5.00 GiB (1280 extents) to 10.00 GiB (2560 extents).
      Logical volume myvolg/myvol successfully resized.
    resize2fs 1.45.6 (20-Mar-2020)
    Filesystem at /dev/mapper/myvolg-myvol is mounted on /myvol; on-line resizing required
    old_desc_blocks = 1, new_desc_blocks = 2
    The filesystem on /dev/mapper/myvolg-myvol is now 2621440 (4k) blocks long.
  3. Verify the increased space on the file system.

    df -h /myvol

    The size of the file system is now 9.8G (Size) with 9.3G available (Avail).

Backup VG Metadata

LVM metadata contains configuration details about the volume groups. Oracle Linux automatically creates metadata backups after every VG and LV configuration change.

  1. List backups and archives.

    sudo ls -l /etc/lvm/backup
    sudo ls -l /etc/lvm/archive
  2. Display the backup contents.

    sudo head -n 10 /etc/lvm/backup/myvolg

    The description states the backup was created after executing the lvextend command.

  3. Manually create a metadata backup.

    sudo vgcfgbackup myvolg

    Include the -f option along with a full path and file name (/var/tmp/myvolg-meta.bkp) to backup the metadata to a different location.

See the vgcfgbackup(8) and vgcfgrestore(8) manual pages for more information.

Grow the VG and LV

Add an additional disk or partition to the VG and resize the LV.

Add Another Disk to a VG

  1. Use the remaining available disk /dev/sdd to extend the VG.

     sudo vgextend -v myvolg /dev/sdd

    Example Output:

    [oracle@ol-node01 ~]$ sudo vgextend -v myvolg /dev/sdd
      Wiping signatures on new PV /dev/sdd.
      Set up physical volume for "/dev/sdd" with 104857600 available sectors.
      Zeroing start of device /dev/sdd.
      Writing physical volume data to disk "/dev/sdd".
      Physical volume "/dev/sdd" successfully created.
      Archiving volume group "myvolg" metadata (seqno 3).
      Adding physical volume '/dev/sdd' to volume group 'myvolg'
      Volume group "myvolg" will be extended by 1 new physical volumes
      Creating volume group backup "/etc/lvm/backup/myvolg" (seqno 4).
      Volume group "myvolg" successfully extended
  2. Verify the VG.

    sudo vgs myvolg

    Example Output:

    [oracle@ol-node01 ~]$ sudo vgs myvolg
      VG     #PV #LV #SN Attr   VSize    VFree   
      myvolg   3   1   0 wz--n- <149.99g <139.99g

    Notice the increased PV count (#PV), capacity (VSize), and free space (VFree).

Resize the LV

  1. Increase the size of the LV and the file system by 20G.

    sudo lvresize -L +20G -r myvolg/myvol
    • -r: Resizes the underlying file system together with the logical volume using fsadm(8).
    • -L: Changes or sets the logical volume size. The + adds to the actual logical volume size.
  2. Verify the increased space on the file system.

    df -h /myvol

For More Information: