Last active
January 30, 2017 16:38
-
-
Save goffinet/e619dbc758d38abd79d98a405ca97ab0 to your computer and use it in GitHub Desktop.
kvm libvirt add storage
This file contains hidden or 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 | |
| # Variables | |
| guest=$1 | |
| disk=/var/lib/libvirt/images/$2.img | |
| # Create 4G Spare Disk with dd | |
| dd if=/dev/zero of=$disk bs=1M seek=4096 count=0 | |
| # Or create a qcow2 disk | |
| qemu-img create -f qcow2 -o preallocation=metadata $disk 4G | |
| # Attach the disk on live guest with persistence | |
| virsh attach-disk $guest $disk vdb --cache none --live --persistent | |
| # Detach the disk | |
| virsh detach-disk $guest $disk --persistent --live |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment