Skip to content
/ sausiq Public

Scripts and config templates for running an Ubuntu Server Cloud image in a qemu virtual machine, for your testing and development pleasure.

License

Notifications You must be signed in to change notification settings

adrinux/sausiq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SAUSIQ

Semi Automated Ubuntu Server In Qemu

A couple of shell scripts and a couple of cloud init config files to get an Ubuntu Server Cloud virtual machine running in Qemu. Uses the Ubuntu Server cloud image.

Currently the 22.04 'Jammy Jellyfish' image is hard coded but can be edited in setup.sh to a different version.

I use this for testing my Ansible roles before running them against actual cloud based virtual servers.

Notes

This has only been tested on manjaro linux.

Depends on the default network bridge created by the manjaro libvirt package, and uses the cloud-localds command (provided by the cloud-image-utils package on manjaro). Your own distro may vary.

Networking

Relies on virb0 bridge provided by Virtual Machine Manager/libvirt so ensure those packages are installed.

Then start the libvert daemon:

sudo systemctl enable libvirtd.service
sudo systemctl start libvirtd.service

Should then be visible:

sudo virsh net-list --all

 Name      State    Autostart   Persistent
--------------------------------------------
 default   active   yes         yes

Default virbr0 (from install of libvirt) does NAT on the 192.168.122.0/24 network used by qemu.

These scripts set a fixed IP in that qemu subnet.

So:

192.168.122.20/24

gives IP of:

192.168.122.20

The default user is 'root' with password 'linux', set in cloud_init.cfg

The VM is reachable from your host with: ssh root@192.168.122.20 and password 'linux'

But not from elsewhere on network.

File layout and base image

Actual VM uses the base cloud image as a backing file - changes are not saved to the original base image, multiple VMs can use same image (saves disk space \o/).

setup.sh will download the base cloud image if it is not present.

Usage

  1. Start by copying the server-template folder to a new 'server-name' folder
  2. Set desired ip in server-name/network_init.cfg
  3. Change Hostname in server-name/cloud_init.cfg
  4. Add your ssh public key in server-name/cloud_init.cfg
  5. (optional) Change password in server-name/cloud_init.cfg
  6. (optional) Adjust memory and -smp details in server-name/run.sh (defaults to 2 Gigabytes of RAM and 2 CPU cores
  7. (optional) Increment tap interface number if you want to run more than one vm concurrently (default is tap0)
  8. 'cd server-name'
  9. Run ./setup.sh - will download the circa 526mb cloud image if not present, be patient!
  10. Run ./run.sh

If you kept the default fixed ip, username and have added your ssh public key you can log into your new VM with ssh root@192.168.122.20.

Allow enough time for cloud_init to install the qemu-guest-agent package then log in and shutdown.

Then edit run.sh and:

  1. Change -monitor from 'stdio' to 'none' (if you plan on running more than one vm concurrently).
  2. (optional) Uncomment -nographic for a headless vm.

On next run you'll need to shut down via SSH (obviously).

About

Scripts and config templates for running an Ubuntu Server Cloud image in a qemu virtual machine, for your testing and development pleasure.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages