Debian 8 Jessie
Sponsored Link

Create Virtual Machine#12015/05/07

 
Install GuestOS and create Virtual Machine. This example shows to install Debian 8.
[1] Create a Virtual Machine on text mode via network, it's OK on Console or remote connection with Putty and so on.
# create a storage pool

root@dlp:~#
mkdir -p /var/kvm/images

root@dlp:~#
virt-install \
--name template \
--ram 4096 \
--disk path=/var/kvm/images/template.img,size=30 \
--vcpus 2 \
--os-type linux \
--os-variant debianwheezy \
--network bridge=br0 \
--graphics none \
--console pty,target_type=serial \
--location 'http://ftp.jaist.ac.jp/pub/Linux/debian/dists/jessie/main/installer-amd64/' \
--extra-args 'console=ttyS0,115200n8 serial'
Starting install...
# installation starts


# on initial boot after installing, push "e" key on the screen like follows

 +----------------------------------------------------------------------------+
 |*Debian GNU/Linux                                                           |
 | Advanced options for Debian GNU/Linux                                      |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 +----------------------------------------------------------------------------+

      Use the ^ and v keys to select which entry is highlighted.
      Press enter to boot the selected OS, `e' to edit the commands
      before booting or `c' for a command-line.

# add virtual console like followsand push "Ctrl + x" key to proceed

 +---------------------------------------------------------------------------------------+
 |          search --no-floppy --fs-uuid --set=root  82c9915f-4b67-46cc-ac63-c6dd4d7662d1|
 |                                                                                       |
 |        else                                                                           |
 |          search --no-floppy --fs-uuid --set=root 82c9915f-4b67-46cc-ac63-c6dd4d7662d1 |
 |                                                                                       |
 |        fi                                                                             |
 |        echo        'Loading Linux 3.16.0-4-amd64 ...'                                 |
 |        linux        /vmlinuz-3.16.0-4-amd64 root=/dev/mapper/debian--vg-root ro quiet\|
 |                     console=ttyS0,115200n8                                            |
 |        echo        'Loading initial ramdisk ...'                                      |
 |        initrd        /initrd.img-3.16.0-4-amd64                                       |
 |                                                                                       |
 +---------------------------------------------------------------------------------------+

      Minimum Emacs-like screen editing is supported. TAB lists
      completions. Press Ctrl-x or F10 to boot, Ctrl-c or F2 for
      a command-line or ESC to discard edits and return to the GRUB menu.
  Booting a command list

# after login with root account, enable the service like follows

root@debian:~#
systemctl enable getty@ttyS0

Created symlink from /etc/systemd/system/getty.target.wants/getty@ttyS0.service to /lib/systemd/system/getty@.service.
# it's OK, finish installation

 
For options, make sure 'man virt-install', there are many options
--name
specify the name of Virtual Machine
--ram
specify the amount of memories of Virtual Machine
--disk path=xxx ,size=xxx
'path=' ⇒ specify the location of disks of Virtual Machine
'size=' ⇒ specify the amount of disks of Virtual Machine
--vcpus
specify the virtual CPUs
--os-type
specify the type of GuestOS
--os-variant
specify the kind of GuestOS
--network
specify network types of Virtual Machine
--graphics
specify the kind of graphics. if set 'none', it means nographics.
--console
specify the console type
--location
specify the location of installation where from
--extra-args
specify parameters that is set in kernel

[2] Move to GuestOS to HostOS with Ctrl + ] key.
Move to HostOS to GuestOS with a command 'virsh console (name of virtual machine)'.
jessie@debian:~$
# push Ctrl + ]

root@dlp:~#
# Host's console
root@dlp:~#
virsh console template
 
# move to Guest

Connected to domain template
Escape character is ^]
# Enter key
jessie@debian:~$
# Guest's console
[3] Because after installing GuestOS, it is minimum settings, so it's useful to save it as a template in order to create new virtual machines later.
# Host's console

root@dlp:~#
virt-clone --original template --name debian8 --file /var/kvm/images/debian8.img

Allocating 'debian8.img'                     |  30 GB     01:02

Clone 'template' created successfully.
root@dlp:~#
ll /var/kvm/images/debian8.img

-rw------- 1 root root 32212287488 May 7 20:45 /var/kvm/images/debian8.img
root@dlp:~#
ll /etc/libvirt/qemu/debian8.xml

-rw------- 1 root root 2640 May 7 20:44 /etc/libvirt/qemu/debian8.xml
Matched Content