Created
March 1, 2019 12:14
-
-
Save ljjjustin/3cf6dd1c8789000d8d85eade6a68362b to your computer and use it in GitHub Desktop.
add vdb to vm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
pushd /var/lib/libvirt/images &> /dev/null | |
for vm in $(virsh list --all | grep win2008 | awk '{print $2}') | |
do | |
disk_path="${vm}-vdb.qcow2" | |
if [ ! -e ${disk_path} ]; then | |
qemu-img create -f qcow2 ${disk_path} 200G | |
fi | |
if virsh domblklist ${vm} | grep -w vdb; then | |
continue | |
fi | |
virsh attach-disk ${vm} --driver qemu --subdriver qcow2 \ | |
--source /var/lib/libvirt/images/${disk_path} --target vdb --persistent | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment