Giter Site home page Giter Site logo

daweiyuanzhang / genvm Goto Github PK

View Code? Open in Web Editor NEW

This project forked from genvm/genvm

0.0 0.0 0.0 128 KB

"genvm" Is a powerfull script bash to generate a minimal and complete Debian and Ubuntu virtual machines for KVM/QEMU (so usable in ProxMox, libvirtd, ...), VirtualBox and/or VMWare.

Home Page: http://www.genvm.eu

License: GNU General Public License v3.0

Shell 98.90% Dockerfile 1.10%

genvm's Introduction

GenVM

GenVM Is a powerful script designed to generate minimum and complete Debian virtual machines for KVM/QEMU (so usable in ProxMox, libvirtd, ...), VirtualBox and VMWare.

GenVM is distributed under the GPL3.

Sources and documentation are available from GitHub (http://github.com/genvm).

Tested distributions

GenVM was tested on Debian from Wheezy to bookworm and Ubuntu. Its work from docker on all linux.

Generated VM

Distrib. Name Rev Arch
debian wheezy 7.X i386
debian wheezy 7.X amd64
debian jessie 8.X i386
debian jessie 8.X amd64
debian stretch 9.X i386
debian stretch 9.X amd64
debian buster 10.X amd64
debian Bullseye 11.X amd64
debian Bookworm 12.X amd64

Installation

No special installation needed, only download the latest version of GenVM, adjust permissions and launch it via sudo or su.

Another solution consist to use a dockerised version

From sources

$ git clone https://github.com/genvm/genvm.git
Cloning into 'genvm'...
remote: Counting objects: 125, done.
remote: Compressing objects: 100% (45/45), done.
remote: Total 125 (delta 39), reused 123 (delta 39), pack-reused 0
Receiving objects: 100% (125/125), 44.15 KiB | 0 bytes/s, done.
Resolving deltas: 100% (39/39), done.
Checking connectivity... done.
$ cd genvm
$ ls
genvm

From archive

Last version (dev)

$ wget -q https://github.com/genvm/genvm/archive/master.zip
$ unzip master.zip
Archive:  master.zip
1d5aa137931b15e6307a0fedb0c30f118c79a959
  creating: genvm-master/
  inflating: genvm-master/genvm      

Stable version

You can find stable versions from GitHub on this page : https://github.com/genvm/genvm/releases

Download the latest version and extract it.

From docker

Create your own image

$ git clone https://github.com/genvm/genvm.git
$ cd genvm
$ docker build -t genvm --no-cache=true .

Use official image

$ docker pull genvm/genvm

But, in fact, no installation needed.

Examples

Note than using -v in examples is better to see whats happen.

Simple Debian

$ su -c "./genvm -l examples/bullseye/pkg.lst -t examples/bullseye simple.debian.bullseye.vmdk"
Password:
Set password to root > 
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
$ ls -lh simple.debian.bullseye.vmdk
-rw-r--r-- 1 root users 875M Jul 27 17:33 simple.debian.bullseye.vmdk

Simple Debian with docker

If you are using your own image :

$ docker run -it --rm --privileged --cap-add=ALL -v ./somewhere:/srv -v /dev:/dev -v/lib/modules:/lib/modules:ro genvm
root@2e8c0ba4488f:/srv# genvm -l /opt/genvm/examples/bullseye/pkg.lst -t /opt/genvm/examples/bullseye debian.bullseye.vmdk

Retrive generated image in ./somewhere.

If you're using official image replace genvm by genvm/genvm when you specify image name.

GenVM use nbd modules, access to loopdevices and create partitions, reload it, etc. that's why it need large privileges.

You can use genvm directly from docker invocation :

$ docker run -h genvm --name genvm -it --rm --privileged \
	--cap-add=ALL -v ./data/:/srv/ -v/dev:/dev -v/lib/modules:/lib/modules:ro genvm/genvm \
	genvm -f qcow2 \
		-n simple \
		-l /opt/genvm/examples/bullseye/pkg.lst \
		-l /opt/genvm/examples/bookworm/pkg.lst \
		-S http://ftp.lip6.fr/pub/linux/distributions/debian \
		-p toor \
		-t /opt/genvm/examples/bullseye \
		-V bookworm \
		-v \
		-P /:4G \
		-P sw \
		-s 5G \
		-F \
		simple.bookworm.qcow2

In this example, we use the fact that bookworm install is the same as bullseye but with an additionnal package (systemd-resolved), so we use evrything from /opt/genvm/examples/bullseye and add list of packages from /opt/genvm/examples/bookworm/pkg.lst. Another way to do that can be use of -A option (-A systemd-resolved) insted of creating a file and use it by -l /opt/genvm/examples/bookworm/pkg.lst.

-V bookworm fix the version deployed.

The partition schema is modified too (image size is 5G with a swap partition).

Another example

The example bullseye.evo propose a version with some utils configurations like timesyncd, locales, grub, disks with partitions, etc.

$ docker run -h genvm --name genvm -it --rm --privileged \
	--cap-add=ALL -v .:/srv -v/dev:/dev -v/lib/modules:/lib/modules:ro \
	genvm/genvm genvm -f qcow2 \
		-n first \
		-l examples/bullseye.evo/pkg.lst \
		-p toor \
		-t examples/bullseye.evo \
		-P examples/bullseye.evo/partitions.lst \
		-s 15G \
		-v \
		first.debian.bullseye.qcow2

Then you can execute VM from host :

$ qemu-system-x86_64 -m 2G -net nic -net user,hostfwd=tcp::2222-:22 first.debian.bullseye.qcow2

And connect it by :

$ ssh -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" -p 2222 root@localhost

Run a VM

Run a VM easily with qemu

$ qemu-system-x86_64 --enable-kvm -m 2G -net nic -net user,hostfwd=tcp::2222-:22 simple.debian.bullseye.vmdk 

genvm's People

Contributors

ypnose avatar vincent-ferotin avatar bosonnoir avatar fhuhu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.