5.13.1 Adding a New LVM Disk to a User Domain

This procedure describes how to add a new LVM disk to a user domain to increase the amount of usable LVM disk space in a user domain. This procedure is done so that the size of a file system or swap LVM partition can be increased. This procedure is performed while the system remains online.

Note:

This procedure requires steps be run in the management domain (Domain-0), and in the user domain.

Run all steps in this procedure as the root user.

  1. In the management domain, verify the free disk space in /EXAVMIMAGES using the following command:
    # df -h /EXAVMIMAGES
    

    The following is an example of the output from the command:

    Filesystem            Size  Used Avail Use% Mounted on
     /dev/sda3            721G  111G  611G  16% /EXAVMIMAGES
    
  2. In the management domain, select a name for the new disk image, and verify that the name is not already used in the user domain.
    # ls -l /EXAVMIMAGES/GuestImages/DomainName/new_disk_image_name
    
    ls: /EXAVMIMAGES/GuestImages/DomainName/new_disk_image_name: No such file or \
    directory
    

    In the preceding command, DomainName is the name of the domain, and new_disk_image_name is the new disk image name.

  3. In the management domain, create a new disk image.
    # qemu-img create /EXAVMIMAGES/GuestImages/DomainName/new_disk_image_name size
    

    In the following example of the command, the new disk image name is pv2_vgexadb.img, and the image size is 10 GB.

    # qemu-img create /EXAVMIMAGES/GuestImages/DomainName/pv2_vgexadb.img 10G
    
  4. In the user domain, determine an available disk name. In the following example, disk names xvda through xvdd are used, and disk name xvde is unused.
    # lsblk -id
    NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
    xvda 202:0    0  13G  0 disk 
    xvdb 202:16   0  20G  0 disk /u01/app/12.1.0.2/grid
    xvdc 202:32   0  20G  0 disk /u01/app/oracle/product/12.1.0.2/dbhome_1
    xvdd 202:48   0  41G  0 disk
    
  5. In the management domain, attach the new disk image to the user domain in read/write mode. In the following example, the new disk image is presented in the user domain as device /dev/xvde.
    # xm block-attach DomainName     \
    file:/EXAVMIMAGES/GuestImages/DomainName/new_disk_image_name /dev/xvde w
    
  6. In the user domain, verify the disk device is available. In the following example, disk name xvde is available in the user domain.
    # lsblk -id
    NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
    xvda 202:0    0  13G  0 disk 
    xvdb 202:16   0  20G  0 disk /u01/app/12.1.0.2/grid
    xvdc 202:32   0  20G  0 disk /u01/app/oracle/product/12.1.0.2/dbhome_1
    xvdd 202:48   0  41G  0 disk 
    xvde 202:64   0  10G  0 disk
    
  7. In the user domain, partition the new disk device. In the following example, disk device /dev/xvde is partitioned.
    # parted /dev/xvde mklabel gpt
    # parted -s /dev/xvde mkpart primary 0 100%
    # parted -s /dev/xvde set 1 lvm on
    

    The parted mkpart command may report the following message. This message can be ignored:

    Warning: The resulting partition is not properly aligned for best performance.
    
  8. In the user domain, create an LVM physical volume on the new disk partition. In the following example, an LVM physical volume is created on disk partition /dev/xvde1.
    # pvcreate /dev/xvde1
    
  9. In the user domain, extend the volume group and verify the additional space in the volume group. In the following example, disk name xvde is now available in the user domain.
    # vgextend VGExaDb /dev/xvde1
    # vgdisplay -s
    
  10. In the management domain, make a backup of the user domain configuration file vm.cfg.
    # cp /EXAVMIMAGES/GuestImages/DomainName/vm.cfg   \
         /EXAVMIMAGES/GuestImages/DomainName/vm.cfg.backup
    
  11. In the management domain, obtain the UUID of the user domain using the following command:
    # grep ^uuid /EXAVMIMAGES/GuestImages/DomainName/vm.cfg
    

    In the following example, the user domain UUID is 49ffddce4efe43f5910d0c61c87bba58.

    # grep ^uuid /EXAVMIMAGES/GuestImages/dm01db01vm01/vm.cfg
    uuid = '49ffddce4efe43f5910d0c61c87bba58'
    
  12. In the management domain, generate a UUID for the new disk image using the following command:
    # uuidgen | tr -d '-'
    

    In the following example, the new disk UUID is 0d56da6a5013428c97e73266f81c3404.

    # uuidgen | tr -d '-'
    0d56da6a5013428c97e73266f81c3404
    
  13. In the management domain, create a symbolic link from /OVS/Repositories to the new disk image using the following command:
    # ln -s /EXAVMIMAGES/GuestImages/DomainName/newDiskImage.img    \
     /OVS/Repositories/user_domain_uuid/VirtualDisks/new_disk_uuid.img
    

    In the following example, a symbolic link is created to the new disk image file pv2_vgexadb.img for user domain dm01db01vm01. The UUID for user domain dm01db01vm01 is 49ffddce4efe43f5910d0c61c87bba58. The UUID for the new disk image is 0d56da6a5013428c97e73266f81c3404.

    # ln -s /EXAVMIMAGES/GuestImages/dm01db01vm01/pv2_vgexadb.img \
    /OVS/Repositories/49ffddce4efe43f5910d0c61c87bba58/VirtualDisks/   \
    0d56da6a5013428c97e73266f81c3404.img
    
  14. In the management domain, append an entry for the new disk to the disk parameter in the user domain configuration file vm.cfg. This makes the new disk image attach automatically to the user domain during the next startup. The new entry matches the following format:
    'file:/OVS/Repositories/user_domain_uuid/VirtualDisks/new_disk_uuid.img,disk_device,w'
    

    The following is an example of an original disk parameter entry in the vm.cfg file:

    disk=['file:/OVS/Repositories/49ffddce4efe43f5910d0c61c87bba58/VirtualDisks/  \
    76197586bc914d3d9fa9d4f092c95be2.img,xvda,w',                                 \
    'file:/OVS/Repositories/49ffddce4efe43f591 0d0c61c87bba58/VirtualDisks/       \
    78470933af6b4253b9ce27814ceddbbd.img,xvdb,w',                                 \
    'file:/OVS/Repositories/49ffddce4efe43f5910d0c61c87bba58/VirtualDisks/        \
    20d5528f5f9e4fd8a96f151a13d2006b.img,xvdc,w',                                 \
    'file:/OVS/Repositories/49ffddce4efe43f5910d0c61c87bba58/VirtualDisks/        \
    058af368db2c4f27971bbe1f19286681.img,xvdd,w']
    

    The following example shows an entry appended to the disk parameter for a new disk image that is accessible within the user domain as disk device /dev/xvde:.

    disk=['file:/OVS/Repositories/49ffddce4efe43f5910d0c61c87bba58/VirtualDisks/  \
    76197586bc914d3d9fa9d4f092c95be2.img,xvda,w',                                 \
    'file:/OVS/Repositories/49ffddce4efe43f591 0d0c61c87bba58/VirtualDisks/       \
    78470933af6b4253b9ce27814ceddbbd.img,xvdb,w',                                 \
    'file:/OVS/Repositories/49ffddce4efe43f5910d0c61c87bba58/VirtualDisks/        \
    20d5528f5f9e4fd8a96f151a13d2006b.img,xvdc,w',                                 \
    'file:/OVS/Repositories/49ffddce4efe43f5910d0c61c87bba58/VirtualDisks/        \
    058af368db2c4f27971bbe1f19286681.img,xvdd,w',                                 \
    'file:/OVS/Repositories/49ffddce4efe43f5910d0c61c87bba58/VirtualDisks/        \
    0d56da6a5013428c97e73266f81c3404.img,xvde,w']