libvirtd by default has a storage pool called default, we can create additional storage pools from a simple xml file
$ cat store.xml <pool type="logical"> <name>store</name> <source> <device path="/dev/sda1"/> </source> <target> <path>/dev/store</path> </target> </pool>
Once the xml file is created , lets define it
$ virsh pool-define store.xml Pool store defined from store.xml $ virsh pool-start store Pool store started virsh pool-list Name State Autostart ------------------------------------------- cipher active yes default active no store active no #enabling auto start pool on server reboot $ virsh pool-autostart store Pool store marked as autostarted $ virsh pool-autostart default Pool default marked as autostarted $virsh pool-list Name State Autostart ------------------------------------------- cipher active yes default active yes store active yes
Instead of creating lvm from lvcreate we can create this from virsh command line
$ virsh vol-create-as store linux2 25G Vol linux2 created
lets check the volume list on the kvm node.
$virsh vol-list store Name Path ------------------------------------------------------------------------------ linux1 /dev/store/linux1 linux2 /dev/store/linux2
Checking the lvm information from lvdisplay command
$lvdisplay /dev/store/linux2 --- Logical volume --- LV Path /dev/store/linux2 LV Name linux2 VG Name store LV UUID ARLbM6-ZvlC-q4ZZ-jckp-JW5X-grKP-GOlT1N LV Write Access read/write LV Creation host, time server.sand.box, 2018-03-30 18:12:28 +0530 LV Status available # open 0 LV Size 25.00 GiB Current LE 6400 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:1 $lvscan ACTIVE '/dev/store/linux1' [25.00 GiB] inherit ACTIVE '/dev/store/linux2' [25.00 GiB] inherit $lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert linux1 store -wi-ao---- 25.00g linux2 store -wi-a----- 25.00g
Installing os on the newly created lvm /dev/store/linux2
$ virt-install \ --name linux2 \ --ram 512 \ --disk path=/dev/store/linux2 \ --vcpus 2 \ --os-type linux \ --os-variant rhel7 \ --network network=default \ --graphics none \ --console pty,target_type=serial \ --location '/home/cipher/CentOS-7-x86_64-Minimal-1708.iso' \ --extra-args 'console=ttyS0,115200n8 serial'
Installation with kickstart
virt-install \ --name linux2 \ --ram 512 \ --disk path=/dev/store/linux2 \ --vcpus 2 \ --os-type linux \ --os-variant rhel7 \ --network network=default \ --graphics none \ --console pty,target_type=serial \ --location '/home/cipher/CentOS-7-x86_64-Minimal-1708.iso' \ --initrd-inject '/var/www/html/pub/ks.cfg' \ --extra-args 'console=ttyS0,115200n8 serial' \ --extra-args 'ks=file:/ks.cfg' \ --accelerate
sudo virt-install --name=windows1 --ram=1024 --cpu=host --vcpus=2 --os-type=windows --os-variant=win7 --disk /dev/mapper/store-windows1,bus=virtio --disk /media/data/windows7.iso,device=cdrom,bus=ide --disk /usr/share/virtio-win/virtio-win.iso,device=cdrom,bus=ide --network network=default --graphics vnc,listen=0.0.0.0 --accelerate WARNING Unable to connect to graphical console: virt-viewer not installed. Please install the 'virt-viewer' package. WARNING No console to launch for the guest, defaulting to --wait -1 Starting install... Domain installation still in progress. Waiting for installation to complete. Domain has shutdown. Continuing. Domain creation completed. Restarting guest.