Skip to content
Snippets Groups Projects
Commit 91e1d945 authored by Florent Gluck's avatar Florent Gluck
Browse files

Added vm_run script to easily run a VM on a disk image

Updated template_creator: template dir wasn't removed after archive was created
Updated README.md with vm_run
parent f9df064e
Branches
No related tags found
No related merge requests found
......@@ -460,7 +460,7 @@ This command:
To create VMs, at least one template is required. However, none is provided in the base install.
The script `template_creator` located at `/usr/local/nexus-server/bin/template_creator` can be used to create new templates from ISO images. Here is `template_creator`'s usage:
The `template_creator` script, located in `/usr/local/nexus-server/bin/`, can be used to create new templates from ISO images:
```
template_creator - a tool to create a VM template from an ISO image.
After the OS installation is completed, a tar archive is created in
......@@ -494,7 +494,7 @@ Feel free to repeat the operation above with as many templates as you like.
### Update a template
The script `update_disk` located at `/usr/local/nexus-server/bin/update_disk` can be used to update the disk image of a template. Here is `update_disk`'s usage:
The `update_disk` script, located in `/usr/local/nexus-server/bin/`, can be used to update a template's disk image:
```
update_disk - a tool to update a template's disk image.
Beware this tool must ONLY be used on templates that are not
......@@ -504,7 +504,18 @@ Usage: update_disk disk
disk the disk image to update which must be a .qcow file
```
As mentioned above, make absolutely sure that the **template's disk to update IS NOT used by any VMs**, otherwise their disks will be corrupted!
As mentioned in the script's help, make absolutely sure that the **template's disk to update IS NOT used by any VMs**, otherwise their disks will be corrupted!
### vm_run script
The `vm_run` script, located in `/usr/local/nexus-server/bin/`, is a convenience script that runs a VM on the specified image file:
```
vm_run - launch a QEMU VM on the specified disk image.
The VM uses 4 CPUs and 4G of RAM.
Usage: vm_run disk
disk the disk image to use (typically a .qcow file)
```
### Control nexus-server with systemd
......
......@@ -37,7 +37,9 @@ EOL
function archive_template {
dir=$1
arch=$dir.tar
echo "Creating archive $arch..."
tar fc $arch $dir && rm -rf $dir && echo "Template archive $arch created." || { rm -rf $dir ; exit 1 ; }
rm -rf $dir
}
if [ $# -ne 4 ]; then
......@@ -81,3 +83,5 @@ create_disk $id
run_qemu $id $CPU $RAM $DISK $iso_image
create_template_file $id "$name" "$owner" "$vis"
archive_template $id
echo "Template created successfully."
#!/bin/bash
CPUS=4
RAM=4G
function echoerr {
echo "$@" >&2
}
if [ $# -ne 1 ]; then
appname=`basename $0`
echoerr "$appname - launch a QEMU VM on the specified disk image."
echoerr "The VM uses $CPUS CPUs and $RAM of RAM."
echoerr ""
echoerr "Usage: $appname disk"
echoerr "disk the disk image to use (typically a .qcow file)"
exit 1
fi
qemu-system-x86_64 -enable-kvm -cpu host -smp cpus=$CPUS -m $RAM -drive file=$1,index=0,media=disk,format=qcow2,if=virtio -vga virtio -device virtio-serial-pci -nic user,model=virtio-net-pci
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment