add virsh.sh aliases; update README
This commit is contained in:
parent
092b66f765
commit
17d0b270c7
2 changed files with 47 additions and 0 deletions
20
README.md
20
README.md
|
@ -28,6 +28,26 @@ ssh deb12-1
|
|||
|
||||
## KVM
|
||||
|
||||
|
||||
### etc-profile.d-virsh.sh
|
||||
|
||||
Useful Bash aliases (actually they are functions) for managing KVM containers.
|
||||
|
||||
For these aliases to be system-wide for Bash users, put them in:
|
||||
`/etc/profile.d/virsh.sh`
|
||||
|
||||
For a user only, they can be copied into ~/.bashrc
|
||||
|
||||
|
||||
vlist List machines and their status
|
||||
vstart <machine> Start <machine>
|
||||
vsave <machine> Save (suspend) <machine>
|
||||
vtop <machine> Stop (gracefully shutdown) <machine>
|
||||
vkill <machine> Kill (force shutdown) <machine>
|
||||
vconsole <machine> Open console on <machine>
|
||||
vrm <machine> Completely remove (destroy) <machine>
|
||||
|
||||
|
||||
### kvm-setup
|
||||
|
||||
Bash script to assist with setting up a Linux virtual machine under KVM/QEMU from an ISO image file.
|
||||
|
|
27
kvm/etc-profile.d-virsh.sh
Normal file
27
kvm/etc-profile.d-virsh.sh
Normal file
|
@ -0,0 +1,27 @@
|
|||
# Aliases for virsh
|
||||
vlist() {
|
||||
/usr/bin/virsh --connect qemu:///system list --all
|
||||
}
|
||||
vstart() {
|
||||
/usr/bin/virsh --connect qemu:///system start $1
|
||||
}
|
||||
vsave() {
|
||||
/usr/bin/virsh --connect qemu:///system managedsave $1 --running
|
||||
}
|
||||
vstop() {
|
||||
/usr/bin/virsh --connect qemu:///system shutdown $1
|
||||
}
|
||||
vkill() {
|
||||
/usr/bin/virsh --connect qemu:///system destroy $1
|
||||
}
|
||||
vconsole() {
|
||||
/usr/bin/virsh --connect qemu:///system console $1
|
||||
}
|
||||
vrm() {
|
||||
echo "This will completely remove $1 and its associated storage."
|
||||
read -r -p "Are you sure? (y/N) " ans
|
||||
echo
|
||||
if [[ "$ans" =~ ^[Yy]$ ]]; then
|
||||
/usr/bin/virsh --connect qemu:///system undefine --nvram --remove-all-storage $1
|
||||
fi
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue