lost and found ( for me ? )

Linux Mint 14 : install Ubuntu 12.10 Server within KVM via CLI ( no GUI )

Here’s an explanation of how to install Ubuntu VMs with CLI by using virt-install.

KVM host
mint14-1 hattori # lsb_release -a
No LSB modules are available.
Distributor ID: LinuxMint
Description: Linux Mint 14 Nadia
Release: 14
Codename: nadia
mint14-1 hattori # uname -ri
3.5.0-19-generic x86_64
mint14-1 hattori # kvm --version
QEMU emulator version 1.2.0 (qemu-kvm-1.2.0+noroms-0ubuntu2, Debian), Copyright (c) 2003-2008 Fabrice Bellard
mint14-1 hattori # virt-install --version
0.600.2


[ logs including trial and error ]

at first , create a virtual disk for the VM.
# qemu-img create -f qcow2 /var/disk1/libvirt_images/ubuntu1210-01.qcow2 10G
Formatting '/var/disk1/libvirt_images/ubuntu1210-01.qcow2', fmt=qcow2 size=10737418240 encryption=off cluster_size=65536 lazy_refcounts=off


then install the VM over virt-install.
nnn , error
mint14-1 ~ # virt-install --connect qemu:///system --name ubuntu1210-vm01 --ram 512 --disk=/var/disk1/libvirt_images/ubuntu1210-01.qcow2,format=qcow2 -c /home/hattori/ubuntu-12.10-server-amd64.iso --os-type linux --virt-type kvm --arch x86_64 --nographics --vcpus=1 --os-variant ubuntuquantal -w bridge=virbr0 --hvm --extra-args='console=tty0 console=ttyS0,115200n8' --keymap=ja
ERROR    --extra-args only work if specified with --location.


it seems that we use “--extra-args” options when specifying “--location”.

install apache2 to have “virt-isntall” load the iso file over HTTP.
# apt-get install apache2

mint14-1 hattori # mv ubuntu-12.10-server-amd64.iso /var/www/
mint14-1 hattori # ls /var/www/*.iso
/var/www/ubuntu-12.10-server-amd64.iso


still error
mint14-1 ~ # virt-install --connect qemu:///system --name ubuntu1210-vm01 --ram 512 --disk=/var/disk1/libvirt_images/ubuntu1210-01.qcow2,format=qcow2 --location http://127.0.0.1/ubuntu-12.10-server-amd64.iso --os-type linux --virt-type kvm --arch x86_64 --nographics --vcpus=1 --os-variant ubuntuquantal -w bridge=virbr0 --hvm --extra-args='console=tty0 console=ttyS0,115200n8' --keymap=ja
ERROR    Error validating install location: Could not find an installable distribution at 'http://127.0.0.1/ubuntu-12.10-server-amd64.iso'
The location must be the root directory of an install tree.


it seems that I need to specify the ISO mount point instead of the ISO file.

mount the iso file.
mint14-1 hattori # mkdir /var/www/iso_mnt

mint14-1 hattori # mount -t iso9660 /var/www/ubuntu-12.10-server-amd64.iso /var/www/iso_mnt
mount: warning: /var/www/iso_mnt seems to be mounted read-only.

mint14-1 hattori # ls /var/www/iso_mnt/
EFI                 boot   doc      isolinux    pics  preseed
README.diskdefines  dists  install  md5sum.txt  pool  ubuntu


try again. okay , the installation has started.
mint14-1 ~ # virt-install --connect qemu:///system --name ubuntu1210-vm01 --ram 512 --disk=/var/disk1/libvirt_images/ubuntu1210-01.qcow2,format=qcow2 --location http://127.0.0.1/iso_mnt/ --os-type linux --virt-type kvm --arch x86_64 --nographics --vcpus=1 --os-variant ubuntuquantal -w bridge=virbr0 --hvm --extra-args='console=tty0 console=ttyS0,115200n8' --keymap=ja

Starting install...
Retrieving file version.info...                                     |  116 B     00:00 ...
Retrieving file linux...                                            | 9.8 MB     00:00 ...
Retrieving file initrd.gz...                                        |  36 MB     00:00 ...
Creating domain...                                                  |    0 B     00:00     
Connected to domain ubuntu1210-vm01
Escape character is ^]
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu

<snip>


 ┌───────────────────────┤ [!!] Select a language ├────────────────────────┐
 │                                                                         │
 │ Choose the language to be used for the installation process. The        │
 │ selected language will also be the default language for the installed   │
 │ system.                                                                 │
 │                                                                         │
 │ Language:                                                               │
 │                                                                         │
 │                               C                                         │
 │                               English                                   │
 │                                                                         │
 │     <Go Back>                                                           │
 │                                                                         │
 └─────────────────────────────────────────────────────────────────────────┘




<Tab> moves; <Space> selects; <Enter> activates buttons



installing


 ┌───────────────────────┤ [!!] Select a language ├────────────────────────┐
 │                                                                         │
 │ Choose the language to be used for the installation process. The        │
 │ selected language will also be the default language for the installed   │
 │ system.                                                                 │
 │                                                                         │
 │ Language:                                                               │
 │                                                                         │
 │                               C                                         │
 │                               English                                   │
 │                                                                         │
 │     <Go Back>                                                           │
 │                                                                         │
 └─────────────────────────────────────────────────────────────────────────┘




<Tab> moves; <Space> selects; <Enter> activates buttons



after finishing the installation , I can access to the VM over virsh serial console.
virsh # list --all
Id    Name                           State
----------------------------------------------------
2     ubuntu1210-vm01                running

virsh # console 2
Connected to domain ubuntu1210-vm01
Escape character is ^]

Ubuntu 12.10 ubuntu-vm1 ttyS0

ubuntu-vm1 login:



virsh # dumpxml ubuntu1210-vm01
<domain type='kvm'>
 <name>ubuntu1210-vm01</name>
 <uuid>a4320fba-e06b-db0a-43e0-f662d5fd1050</uuid>
 <memory unit='KiB'>524288</memory>
 <currentMemory unit='KiB'>524288</currentMemory>
 <vcpu placement='static'>1</vcpu>
 <os>
   <type arch='x86_64' machine='pc-1.2'>hvm</type>
   <boot dev='hd'/>
 </os>
 <features>
   <acpi/>
   <apic/>
   <pae/>
 </features>
 <clock offset='utc'/>
 <on_poweroff>destroy</on_poweroff>
 <on_reboot>restart</on_reboot>
 <on_crash>restart</on_crash>
 <devices>
   <emulator>/usr/bin/kvm</emulator>
   <disk type='file' device='disk'>
     <driver name='qemu' type='qcow2'/>
     <source file='/var/disk1/libvirt_images/ubuntu1210-01.qcow2'/>
     <target dev='vda' bus='virtio'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
   </disk>
   <controller type='usb' index='0'>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
   </controller>
   <interface type='bridge'>
     <mac address='52:54:00:ac:a8:cb'/>
     <source bridge='virbr0'/>
     <model type='virtio'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
   </interface>
   <serial type='pty'>
     <target port='0'/>
   </serial>
   <console type='pty'>
     <target type='serial' port='0'/>
   </console>
   <memballoon model='virtio'>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
   </memballoon>
 </devices>
</domain>

virsh #



unmount the ISO point
mint14-1 hattori # umount /var/www/iso_mnt


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.