User Tools

Site Tools


Sidebar

software:rhel:virt-install_deploy

What?

My notes on deploying RHEL in kvm guests using virt-install.

backing with thin provisioned LVM

# create a thin provisioned LVM VG "pool"

# install apache and configure it to export the RHEL media.  Will be used as repo.
# also a directory "ks" will contain the kickstart file used for deployment.

# create a second bridge, virbr1

# create a single bash script.  When run, this will install the guest.
cat >donew_rhel6u5a<<EOT
#!/bin/bash

set -x
HOSTNAME=rhel6u5a
# DISTRO=rhel-6.0
DISTRO=rhel-6.5
DISTROMAJOR=rhel-6
IPADDR=192.168.4.32

lvs | grep tvm_$HOSTNAME >/dev/null || lvcreate -T store/pool -V 16G -n tvm_$HOSTNAME 
virsh destroy   $HOSTNAME       2>/dev/null
virsh undefine  $HOSTNAME       2>/dev/null

cp $DISTROMAJOR.template ks/$HOSTNAME
sed -i "s,DISTRO,$DISTRO,g"             ks/$HOSTNAME
sed -i "s,IPADDR,$IPADDR,g"             ks/$HOSTNAME
sed -i "s,HOSTNAME,$HOSTNAME,g"         ks/$HOSTNAME

virt-install -n $HOSTNAME -r 1024 --vcpus 2 --cpu host --disk path=/dev/store/tvm_$HOSTNAME \
        --location /mnt/store/deploy/repos/$DISTRO/ \
        -w bridge=virbr0 --os-variant rhel6 --graphics none \
        -w bridge=virbr1 \
        -w bridge=virbr1 \
        -w bridge=virbr2 \
        -w bridge=virbr2 \
        --extra-args "ip=$IPADDR netmask=255.255.255.0 ks=http://192.168.4.1/ks/$HOSTNAME repo=http://192.168.4.1/repos/$DISTRO ksdevice=eth0 console=tty0 console=ttyS0,19200n8"

EOT

backing qcow2 file

# create a single bash script.  When run, this will install the guest.
cat >donew_rhel6u5b<<EOT
#!/bin/bash

set -x
HOSTNAME=rhel6u5b
# DISTRO=rhel-5.5
# DISTRO=rhel-5.6
# DISTRO=rhel-6.0
DISTRO=rhel-6.5
DISTROMAJOR=rhel-6
IPADDR=192.168.4.33

virsh destroy   $HOSTNAME       2>/dev/null
virsh undefine  $HOSTNAME       2>/dev/null
rm -f /mnt/store/deploy/images/tvm_$HOSTNAME
qemu-img create -f qcow2 -o preallocation=metadata,compat=1.1 /mnt/store/deploy/images/tvm_$HOSTNAME 18G

cp $DISTROMAJOR.template ks/$HOSTNAME
sed -i "s,DISTRO,$DISTRO,g"             ks/$HOSTNAME
sed -i "s,IPADDR,$IPADDR,g"             ks/$HOSTNAME
sed -i "s,HOSTNAME,$HOSTNAME,g"         ks/$HOSTNAME

virt-install -n $HOSTNAME -r 1024 --vcpus 2 --cpu host \
        --disk path=/mnt/store/deploy/images/tvm_$HOSTNAME,bus=virtio \
        --location /mnt/store/deploy/repos/$DISTRO/ \
        -w bridge=virbr0 --os-variant rhel6 --graphics none \
        -w bridge=virbr1 \
        -w bridge=virbr1 \
        -w bridge=virbr2 \
        -w bridge=virbr2 \
        --extra-args "ip=$IPADDR netmask=255.255.255.0 ks=http://192.168.4.1/ks/$HOSTNAME repo=http://192.168.4.1/repos/$DISTRO ksdevice=eth0 console=tty0 console=ttyS0,19200n8"
EOT
software/rhel/virt-install_deploy.txt ยท Last modified: 2021/03/23 12:22 (external edit)