Thu, March 29, 2018 ยท 2 min read

LVM disk management on fedora 26

LVM disk management on fedora 26

With standard partition layout we can have maximum 4 primary partitions (considering MBR). With LVM we can create number of partitions. A partition has to be initialized and volume group has to be created for making LVM partitions on top of it.

Initialize a physical volume

$ pvcreate /dev/sda1
WARNING: ext4 signature detected on /dev/sda1 at offset 1080. Wipe it? [y/n]: y
  Wiping ext4 signature on /dev/sda1.
  Physical volume "/dev/sda1" successfully created.

Create a volume group

$ vgcreate store /dev/sda1

Display LVM status

$ pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda1
  VG Name               store
  PV Size               596.17 GiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              152619
  Free PE               152619
  Allocated PE          0

$ vgdisplay
  --- Volume group ---
  VG Name               store
  Format                lvm2
  VG Size               596.17 GiB
  PE Size               4.00 MiB
  Total PE              152619
  Alloc PE / Size       0 / 0
  Free  PE / Size       152619 / 596.17 GiB

Creating a KVM storage pool from LVM

Create an XML file for the pool:

<pool type="logical">
  <name>store</name>
  <source>
    <device path="/dev/sda1"/>
  </source>
  <target>
    <path>/dev/store</path>
  </target>
</pool>

Define and start the pool:

$ virsh pool-define store.xml
Pool store defined from store.xml

$ virsh pool-start store
Pool store started

$ virsh pool-autostart store
Pool store marked as autostarted

$ virsh pool-list
 Name                 State      Autostart
-------------------------------------------
 cipher               active     yes
 default              active     yes
 store                active     yes

Creating a VM with virt-install using LVM

$ virt-install --name linux1 --ram 1024 --disk path=/dev/store/linux1 --vcpus 2 --os-type linux --os-variant rhel7 --graphics none --console pty,target_type=serial --location '/home/cipher/CentOS-7-x86_64-Minimal-1708.iso' --extra-args 'console=ttyS0,115200n8 serial'