Dimensione: 11731
Commento:
|
Dimensione: 12809
Commento:
|
Le cancellazioni sono segnalate in questo modo. | Le aggiunte sono segnalate in questo modo. |
Linea 1: | Linea 1: |
##title KVM Create Guests | |
Linea 5: | Linea 5: |
= Creating virtual machines = Now that KVM is installed, let's see how we create our first VM. This can be done using: * [[http://virt-manager.et.redhat.com|virt-manager]]: a GUI tool * [[http://www.howtoforge.com/installing-kvm-guests-with-virt-install-on-ubuntu-8.10-server|virt-install]], a python script developed by Red Hat * [[https://help.ubuntu.com/8.04/serverguide/C/ubuntu-vm-builder.html|ubuntu-vm-builder]], developed by Canonical. == Ubuntu-vm-builder: the fast & powerful way to create Ubuntu JEOS VMs == [[http://doc.ubuntu.com/ubuntu/serverguide/C/ubuntu-vm-builder.html|Ubuntu-vm-builder]] is probably the best tool to use if you want to create VMs running Ubuntu JEOS 8.04, as the install is entirely scripted (very fast). This tool is packaged, and in universe: |
KVM/CreazioneOspiti = Creazione di macchine virtuali = Una volta installato KVM, è possibile procedere alla creazione della VM. Ciò può essere fatto usando: * [http://virt-manager.et.redhat.com virt-manager]: uno strumento GUI. * [http://www.howtoforge.com/installing-kvm-guests-with-virt-install-on-ubuntu-8.10-server virt-install], uno script python sviluppato da Red Hat * [https://help.ubuntu.com/8.04/serverguide/C/ubuntu-vm-builder.html ubuntu-vm-builder], sviluppato da Canonical. == Ubuntu-vm-builder: un mezzo veloce e potente per creare VMs Ubuntu JEOS == [http://doc.ubuntu.com/ubuntu/serverguide/C/ubuntu-vm-builder.html Ubuntu-vm-builder] è probabilmente il miglior strumento per la creazione di VMs che eseguono Ubuntu JEOS 8.04, dato che l'installazione avviene interamente tramite script (molto veloce). Questo strumento è pacchettizzato, e si trova nel repository universe: |
Linea 24: | Linea 24: |
'''Note for 8.10 (intrepid)''': the package is now named '''python-vm-builder''', the command is now named '''vmbuilder''' and you can find a [[https://help.ubuntu.com/community/JeOSVMBuilder|detailed tutorial on the wiki]]. === Basic use === Here is a very basic example of how to use it: |
'''Nota: a partire dalla 8.10 (intrepid)''': il pacchetto viene chiamato '''python-vm-builder''', il comando '''vmbuilder''' ed è possibile trovare un [https://help.ubuntu.com/community/JeOSVMBuilder dettagliato tutorial sul wiki].*******Tradurre === Utilizzo elementare === Questo è un esempio elementare di come utilizzarlo: |
Linea 34: | Linea 34: |
This will create an Ubuntu Hardy, with all options set to default. Or you can use this URL to a Javascript tool that generates the lengthy set of parameters available for ubuntu-vm-builder: |
Ciò creerà una Ubuntu Hardy, con tutte le opzione impostate in modo predefinito. Oppure è possibile usare questo URL in uno strumento per script java per generare la lunga serie di parametri disponibili per ubuntu-vm-builder: |
Linea 39: | Linea 39: |
Note: if you want to use Virsh to manage your virtual machines as detailed below, you must add this parameter: | Nota: se si preferisce usare Virsh per la gestione della macchina virtuale, come descritto più avanti, bisogna aggiungere questo parametro: |
Linea 45: | Linea 45: |
The javascript does not have an option for this itself, unfortunately. '''Note''': when using --libvirt, the xml file is injected into libvirt and not stored locally. Use {{{virsh -c qemu:///system}}} or {{{virt-manager -c qemu:///system}}} to start your machine or modify its configuration. === More complex example === Now here is a somewhat more complex example: |
Sfortunatamente lo script java non contiene una opzione per farlo automaticamente. '''Nota''': utilizzando il parametro --libvirt, il file XML non viene archiviato localmente ma viene iniettato in libvirt. Utilizzare {{{virsh -c qemu:///system}}} oppure {{{virt-manager -c qemu:///system}}} per avviare la macchina o modificarne la configurazione. === Esempio più complesso === In seguito è riportato un esempio più complesso: |
Linea 74: | Linea 74: |
This will create a new Ubuntu Hardy VM called "newvm", the hostname will be set to "hostnameformyvm", the network will be configured with a static IP address and a gateway at address 192.168.0.1. The --mirror will tell the script to download the packages from a local Ubuntu mirror instead of the default server (this may speed up by a lot the time necessary to create the VM). The components argument will enable main and universe by default on the VM, --addpkg vim will install vim, and finally the last argument will automatically add the newly created VM to KVM. By adding 'openssh-server' with --addpkg, we will be able to ssh into our new machine once its started (provided the networking works correctly). Note: The manual isn't specific about the --exec option, used to execute a script file during the vm build process. If you specify the --exec option then you must provide the full path to the script you are executing. Not doing so will cause the installer to tell you that it can't find the script file. '''Bug notice: ''' it seems that the package 'linux-package' is not found during the machine building process unless 'restricted' is also specified as a component option to ubuntu-vm-builder. If not specified, you'll get a non-functioning system that boots into grub only. This line makes it work for me: |
Ciò creerà una nuova Ubuntu Hardy VM chiamata "newvm", l' hostname sarà impostato a "hostnameformyvm", la rete sarà configurata con un indirizzo IP statico ed il gateway all'indirizzo 192.168.0.1. il parametro --mirror richiederà allo script lo scaricamentodei pacchetti da un mirror locale di ubuntu piuttosto che dal server centrale (ciò diminuirà di molto il tempo necesario alla creazione della VM). L'argomento components abiliterà i repository main e universe predefiniti sulla VM, --addpkg vim installerà vim, ed infine l'ultimo argomento aggiungerà automaticamente la VM appena creata a KVM. L'aggiunta di 'openssh-server' a --addpkg, consentirà di eseguire una sessione ssh sulla nuova macchina una volta avviata (Assicurarsi che i dispositivi di connessione siano funzionino correttamente). Nota: Il manuale non fornisce spiegazioni dettagliate sull'utilizzo dell'opzione --exec, usata per lanciare uno script durante il processo dicostruzione della VM. Quindi se si specifica l'opzione --exec è necessario fornire l'indirizzo completo dallo script. In mancanza di ciò il programma d'installazione restituirà un errore relativo all'impossibilità di recuperare lo script. '''Avviso bug: ''' Sembra che il pacchetto 'linux-package' non venga trovato durante la costruzione della VM fino a che non viene aggiunta l'opzione 'restricted' nell'argomento component di ubuntu-vm-builder. se non specificato si otterrà un SO non funzionante che si avvierà solamente da grub., Quest linea risolve il problema: |
Linea 86: | Linea 86: |
I'm assuming this is a bug in ubuntu-vm-builder. === Install on a raw block device === Ubuntu-vm-builder doesn't allow you to create the VM on a raw block device yet (like a standalone partition, or a iSCSI share). You can use ubuntu-vm-builder to create the qcow2 image and then move the VM to the block device with qemu-img though; if /dev/sdb is the disk device on which you want to move the virtual machine: |
Presumendo che ciò sia un bug di ubuntu-vm-builder. === Intallazione su un dispositivo a blocchi grezzo === Ubuntu-vm-builder non consente la creazione di VM su un dispositivo a blocchi grezzo (come ad esempio una partizione indipendente, oppure una condivisione iSCSI). È possibile usare ubuntu-vm-builder per creare l'immagine qcow2 e quindi spostare la VM sul dispositivo a blocchi con qemu-img; se /dev/sdb è il disco sul quale trasferire la macchina virtuale: |
Linea 96: | Linea 96: |
Edit the XML definition file for the VM in /etc/libvirt/qemu/, and set the source file to be: | Editare il file definizione XML per la VM in /etc/libvirt/qemu/, ed impostare il file sorgente per esere: |
Linea 101: | Linea 101: |
Redefine the VM and start it; it is now running from /dev/sdb. Ubuntu-vm-builder is a very powerful tool - to get a more detailed list of its capabilities, use ubuntu-vm-builder --help. == Create VMs running other operating systems: virt-install == Virt-install is radically different in the way it works. Instead of creating automagically a new VM, it will allow you to boot on an iso, and therefore to install almost any operating system. For a list of supported operating system, consult [[http://www.linux-kvm.org/page/Guest_Support_Status|kvm's official webpage]]. As you need virt-install to setup Windows guests, we will here describe how to install windows XP. There are a couple of small issues during the install, so I will also describe the workarounds. === Example Windows install === {{http://waste.mandragor.org/windows-kvm.png}} NB: The following install is for Windows XP under KVM-62 (default in Hardy as time of writing). I have been unable to run windows 2000 server in accelerated mode on it. To run windows 2000 server, I use the KVM-72 backport for Hardy provided by Soren in his PPA: https://launchpad.net/~soren/+archive. Copy the ISO of the system you want to install to your working directory: |
Ridefinire la VM ed avviarla; così facendo funzionerà da /dev/sdb. Ubuntu-vm-builder è uno strumento potentissimo - per avere un più dettagliato elenco delle sue capacità, utilizzare ubuntu-vm-builder --help. == Creazione di una VMs in grado di eseguire altri sistemi operativi: virt-install == Virt-install è redicalmente differente nel modo in cui funziona. Invece di creare automagicamente una nuova VM, consente di avviare un immagine iso, e quindi di installare qualsiasi sistema operativo. Per l'elenco dei sistemi operativi supportati, consultare la [http://www.linux-kvm.org/page/Guest_Support_Status pagina web ufficiale di KVM]. Di seguito viene descritto come installare Windows XPA. Durante la fase d'installazione, avverranno alcuni piccoli problemi, ma verrà spiegato come aggirarli. === Esempio di installazione di Windows === [http://waste.mandragor.org/windows-kvm.png] NB: La seguente descrizione è relativa a windows XP sotto KVM-62 (Predefinito in Hardy durante la stesura di questo testo). In questa versione è impossibile l'esecuzione di windows 2000 server in modalità accelerata, per cui occorre usare KVM-72 adattato per Hardy fornito da Soren nel suo PPA: https://launchpad.net/~soren/+archive. Copiare la ISO del sistema da installare nella vostra directory funzionante:of the system you want to install to your working directory: |
Linea 122: | Linea 122: |
or create an ISO from a cd/dvd: | oppure creare una ISO da cd/dvd: |
Linea 127: | Linea 127: |
Install virt-install: | Installare virt-install: |
Linea 132: | Linea 132: |
Then, you need to run virt-install. On Ubuntu Hardy, with KVM-62, the install of windows XP doesn't work when accelerated (ie, using --accelerate), so run the install without that argument, and replace qemu by kvm in the XML defintiion file (in /etc/libvirt/qemu) after the first reboot. | Eseguire virt-install. SU Ubuntu Hardy, con KVM-62, l'installazione di windows XP non funziona se accelerata (cioè, usando --accelerate), Quindi bigsogna installare senza questo argomento e sosituire qemu con kvm nel file definizione XML (in /etc/libvirt/qemu) dopo il primo riavvio. |
Linea 138: | Linea 138: |
'''Note for 8.10 (intrepid)''': to make above command work add --hvm option to enable fully virtualized guest. This will boot a new VM from the ISO. Connect to the new VM using virt-viewer: |
'''Note per 8.10 (Intrepid)''': per far si che il precedente comando funzioni, aggiungere l'opzione --hvm per avere l'ospite completamente virtualizzato. Questo avvierà una nuova VM dalla ISO. Connettere alla nuova VM usando virt-viewer: |
Linea 146: | Linea 146: |
Or if KVM is running on a different server: | Oppure se KVM è in funzione su di un altro server: |
Linea 152: | Linea 152: |
You can now start the install. Another problem is that after the first reboot, in the process of the installation, the windows installer will complain that it can not see the disk anymore. In the XML definition of the VM again, add this to the list of devices: | È quindi possibile avviare l'installazione. Un'altro problema è che dopo il primo riavvio, nel processo di installazione, il programma di installazione di windows, riferirà che non è più possibile trovare il disco d'installazione. Quindi nel file definizione XML della VM aggiungere le seguenti linee alla lista dei dispositivi: |
Linea 160: | Linea 160: |
<source file='//home/yhamon/windowsxpsp2.iso'/> | <source file='//home/nomeutente/windowsxpsp2.iso'/> |
Linea 168: | Linea 168: |
Redefine the VM in virsh (sudo virsh define /etc/libvirt/qemu/xpsp2.xml) and restart the VM - it should work fine. Another problem with virt-install in combination with Windows is that the created disk image is corrupted. At first the installation seems to work, but then after a reboot it stops with the message 'A read error occured'. This can be easily fixed by creating a new disk image (prior to installation): |
Ridefinire la VM in virsh (sudo virsh define /etc/libvirt/qemu/xpsp2.xml) e riavviare la VM. Un altro problema con la combinazione virt-install - Wndowsin combination with Windows è che il disco immagine creato è corrotto. inizialmente l'installazione sembra funzionare, ma dopo il primo riavvio si fermerà riportando il messaggio 'A read error occured'. Ciò può essere agevolmente risolto creando un nuovo disco immagine (prima dell'installazione): |
Linea 174: | Linea 174: |
Overwrite the qcow2 file created by virt-install by this new file, reboot your VM and you are ready to go. === Example Ubuntu install === You can perform the following to install Ubuntu Hardy:{{{ |
Sovrascrive il file qcow2 creato da virt-install con questo nuovo file, riavviare la VM. === Esempio di installazione di Ubuntu === Per installare Ubuntu Hardy eseguire il comando: {{{ |
Linea 181: | Linea 182: |
The '--network' option sets up the machine to use the default libvirt network. You can see available libvirt networks with:{{{ | L'opzione '--network' imposta la machina all'uso della rete libvirt predefinita. Per un elenco delle reti libvirt usare il comando: {{{ |
Linea 185: | Linea 187: |
=== Other Operating Systems === Other Operating Systems can be installed using the same method as above. See 'man virt-install' for more information on different options for your virtual machine and supported OS types and OS variants. '''Warning:''' this method fails with Fedora LiveCD installations and possibly others; see the bug here: https://bugs.launchpad.net/ubuntu/+source/kvm/+bug/220463 == Cloning a virtual machine == You can clone an existing virtual machine using the virt-clone tool. This duplicates the disk image and sets up the virtual machine domain configuration. If you wish to clone a virtual machine named ''srchost'' to a new machine ''newhost'', ensure that the virtual machine ''srchost'' is not running and execute the following command. {{{ $ virt-clone --connect=qemu:///system -o srchost -n newhost -f /path/to/newhost.qcow2 }}} == Create a virtual machine from pre-existing image == Assuming: * Virt-manager is being used to manage virtual machines. * You wish to add a pre-existing image to virt-manager. Use case: Using qcow2 with overlays, you can experiment heavily with your virtual machines without having to perform complete reinstalls if you manage to corrupt them. A side effect of this method in comparison to cloning, is that less disk space is used. Procedure: 1. Create the hard drive image with qcow2 format: {{{ $ qemu-img create -f qcow2 <image name>.qcow2 }}} 2. Install the virtual machine using virt-manager: Instead of allowing virt-manager to create a new drive image, simply direct it to use the image you created in the previous step. 3. Create the overlay: {{{ $ qemu-img create -f qcow2 -b <image name>.qcow2 <image name>.ovl }}} 4. Create virtual image XML descriptor. Read first: |
=== Altri sistemi operativi === È possibile installare altri sistemi operativi seguendo il metocdo precedente. Consultare 'man virt-install' per maggiori informazioni e differenti opzioni per la macchina virtuale, SO supportati e relative varianti. '''Attenzione:''' questo metodo non funziona con il LiveCD di Fedora Fedora LiveCD e probabilmente anche altri; vedere: [https://bugs.launchpad.net/ubuntu/+source/kvm/+bug/220463 bug #220463]. == Clonazione di una macchina virtuale == È possibile clonare una macchina virtuale usando lo strumento virt-clone. Quest'ultimo duplicherà l'immagine del disco e configurerà il dominio della macchina virtuale. Per clonare una macchina virtuale chiamata ''srchost'' in una nouva macchina ''newhost'', assicurarsi che la macchina virtuale ''srchost'' non sia in esecuzione ed eseguire il seguente comando: {{{ $ virt-clone --connect=qemu:///system -o srchost -n newhost -f /indirizzo/per/newhost.qcow2 }}} == Creazione di una macchina virtuale da un'immagine preesistente == Assumendo che: * Virt-manager viene utilizzato per gestire macchine virtuali. * Si vuole aggiungere un'immagine preesistente a virt-manager. Caso d'uso: Nel caso si voglia corrompere un immagine è possibile sperimentare pesantemente sulle macchine virtuali, senza dover eseguire complete reinstallazioni, usando qcow2 con overlays. Un lato positivo di questo metodo, rispetto alla clonazione, è il minor utilizzo di spazio su disco. Procedura: 1. Creare un immagine del hard disk in formato qcow2: {{{ $ qemu-img create -f qcow2 <nome immagine>.qcow2 }}} 2. Installare la macchina virtuale usando virt-manager: Invece di consentire a virt-manager la creazione di una nuova immagine del disco, indirizzarlo all'uso dell'immagine precedentemente creata. 3. Creazione dell'overlay: {{{ $ qemu-img create -f qcow2 -b <nome immagine>.qcow2 <nome immagine>.ovl }}} 4. Creare l'immagine virtuale del descrittore XML. Leggere prima di proseguire: |
Linea 230: | Linea 231: |
Copy the XML file created in step 2 above: {{{ $ cp ~/.libvirt/qemu/<vm name>.xml overlay.xml }}} Then using your favorite editor, open and edit the copied XML file: |
Copiare il file XML creato: {{{ $ cp ~/.libvirt/qemu/<nome vm>.xml overlay.xml }}} Aprire ed editare il file XML copiato con l'editor preferito: |
Linea 238: | Linea 239: |
Create the virtual image XML descriptor based on the virt-image(5) manpage. I simply commented out the original text, and used it as a guide when creating the new descriptor. 5. Create the new virtual machine from the image descriptor: |
Creare l'immagine virtuale del descrittore XML basandosi sulla pagina del manuale: virt-image(5), commentando il testo originale ed usandolo come guida durante la creazione del descrittore. 5. Creare la nuova macchina virtuale dall'immagine del descrittore: |
Linea 246: | Linea 245: |
6. Run and test the new virtual machine based on the overlay. Open the new virtual machine in virt-manager and test to your hearts content. If you 'break' the virtual machine, simply destroy and delete it. Then recreate the overlay image and recreate the overlay virtual machine as described above. You can commit the overlay changes to the base image if desired, see the qemu-img manpage for details. == See also == The [[../FAQ#systemadjustments|system specific adjustment recommended in the FAQ]]. [[http://packages.ubuntu.com/search?keywords=apt-cacher-ng|apt-cacher-ng]] for mirroring. You can reduce setup time to 3-4 minutes using ubuntu-vm-builder on a reasonable machine. |
6. Avviare e verificare che la nuova macchina sia basata sull'overlay. Avviare la macchina virtuale e testarla come meglio si crede. In caso di malfunzionamento, basta semplicemente distruggerla e cancellarla. Quindi ricreare l'immagine e la macchina overlay come descritto sopra. È possibile effettuare cambiamenti overlay all'immagine di base. In tal caso consultare il manuale alla pagina qemu-img per i dettagli. == Vedere anche == The [[../FAQ#systemadjustments|system specific adjustment recommended in the FAQ]].***********************ancorare a domande frequenti. [http://packages.ubuntu.com/search?keywords=apt-cacher-ng apt-cacher-ng] per il mirroring. |
Linea 263: | Linea 258: |
CategoryHomepage | CategoryHomepage CategoryInTraduzione |
BR Indice(depth=2 align=right) KVM/CreazioneOspiti
Creazione di macchine virtuali
Una volta installato KVM, è possibile procedere alla creazione della VM. Ciò può essere fatto usando:
[http://virt-manager.et.redhat.com virt-manager]: uno strumento GUI.
[http://www.howtoforge.com/installing-kvm-guests-with-virt-install-on-ubuntu-8.10-server virt-install], uno script python sviluppato da Red Hat
[https://help.ubuntu.com/8.04/serverguide/C/ubuntu-vm-builder.html ubuntu-vm-builder], sviluppato da Canonical.
Ubuntu-vm-builder: un mezzo veloce e potente per creare VMs Ubuntu JEOS
[http://doc.ubuntu.com/ubuntu/serverguide/C/ubuntu-vm-builder.html Ubuntu-vm-builder] è probabilmente il miglior strumento per la creazione di VMs che eseguono Ubuntu JEOS 8.04, dato che l'installazione avviene interamente tramite script (molto veloce).
Questo strumento è pacchettizzato, e si trova nel repository universe:
sudo apt-get install ubuntu-vm-builder
Nota: a partire dalla 8.10 (intrepid): il pacchetto viene chiamato python-vm-builder, il comando vmbuilder ed è possibile trovare un [https://help.ubuntu.com/community/JeOSVMBuilder dettagliato tutorial sul wiki].*******Tradurre
Utilizzo elementare
Questo è un esempio elementare di come utilizzarlo:
sudo ubuntu-vm-builder kvm hardy
Ciò creerà una Ubuntu Hardy, con tutte le opzione impostate in modo predefinito.
Oppure è possibile usare questo URL in uno strumento per script java per generare la lunga serie di parametri disponibili per ubuntu-vm-builder:
Nota: se si preferisce usare Virsh per la gestione della macchina virtuale, come descritto più avanti, bisogna aggiungere questo parametro:
--libvirt qemu:///system
Sfortunatamente lo script java non contiene una opzione per farlo automaticamente.
Nota: utilizzando il parametro --libvirt, il file XML non viene archiviato localmente ma viene iniettato in libvirt. Utilizzare virsh -c qemu:///system oppure virt-manager -c qemu:///system per avviare la macchina o modificarne la configurazione.
Esempio più complesso
In seguito è riportato un esempio più complesso:
ubuntu-vm-builder kvm hardy \ --domain newvm \ --dest newvm \ --arch i386 \ --hostname hostnameformyvm \ --mem 256 \ --user john \ --pass doe \ --ip 192.168.0.12 \ --mask 255.255.255.0 \ --net 192.168.0.0 \ --bcast 192.168.0.255 \ --gw 192.168.0.1 \ --dns 192.168.0.1 \ --mirror http://archive.localubuntumirror.net/ubuntu \ --components main,universe \ --addpkg vim openssh-server \ --libvirt qemu:///system ;
Ciò creerà una nuova Ubuntu Hardy VM chiamata "newvm", l' hostname sarà impostato a "hostnameformyvm", la rete sarà configurata con un indirizzo IP statico ed il gateway all'indirizzo 192.168.0.1. il parametro --mirror richiederà allo script lo scaricamentodei pacchetti da un mirror locale di ubuntu piuttosto che dal server centrale (ciò diminuirà di molto il tempo necesario alla creazione della VM). L'argomento components abiliterà i repository main e universe predefiniti sulla VM, --addpkg vim installerà vim, ed infine l'ultimo argomento aggiungerà automaticamente la VM appena creata a KVM.
L'aggiunta di 'openssh-server' a --addpkg, consentirà di eseguire una sessione ssh sulla nuova macchina una volta avviata (Assicurarsi che i dispositivi di connessione siano funzionino correttamente).
Nota: Il manuale non fornisce spiegazioni dettagliate sull'utilizzo dell'opzione --exec, usata per lanciare uno script durante il processo dicostruzione della VM. Quindi se si specifica l'opzione --exec è necessario fornire l'indirizzo completo dallo script. In mancanza di ciò il programma d'installazione restituirà un errore relativo all'impossibilità di recuperare lo script.
Avviso bug: Sembra che il pacchetto 'linux-package' non venga trovato durante la costruzione della VM fino a che non viene aggiunta l'opzione 'restricted' nell'argomento component di ubuntu-vm-builder. se non specificato si otterrà un SO non funzionante che si avvierà solamente da grub., Quest linea risolve il problema:
--components 'main,universe,restricted'
Presumendo che ciò sia un bug di ubuntu-vm-builder.
Intallazione su un dispositivo a blocchi grezzo
Ubuntu-vm-builder non consente la creazione di VM su un dispositivo a blocchi grezzo (come ad esempio una partizione indipendente, oppure una condivisione iSCSI). È possibile usare ubuntu-vm-builder per creare l'immagine qcow2 e quindi spostare la VM sul dispositivo a blocchi con qemu-img; se /dev/sdb è il disco sul quale trasferire la macchina virtuale:
sudo qemu-img convert root.qcow2 -O raw /dev/sdb
Editare il file definizione XML per la VM in /etc/libvirt/qemu/, ed impostare il file sorgente per esere:
<source file='/dev/sdb'/>
Ridefinire la VM ed avviarla; così facendo funzionerà da /dev/sdb.
Ubuntu-vm-builder è uno strumento potentissimo - per avere un più dettagliato elenco delle sue capacità, utilizzare ubuntu-vm-builder --help.
Creazione di una VMs in grado di eseguire altri sistemi operativi: virt-install
Virt-install è redicalmente differente nel modo in cui funziona. Invece di creare automagicamente una nuova VM, consente di avviare un immagine iso, e quindi di installare qualsiasi sistema operativo. Per l'elenco dei sistemi operativi supportati, consultare la [http://www.linux-kvm.org/page/Guest_Support_Status pagina web ufficiale di KVM].
Di seguito viene descritto come installare Windows XPA. Durante la fase d'installazione, avverranno alcuni piccoli problemi, ma verrà spiegato come aggirarli.
Esempio di installazione di Windows
[http://waste.mandragor.org/windows-kvm.png]
NB: La seguente descrizione è relativa a windows XP sotto KVM-62 (Predefinito in Hardy durante la stesura di questo testo). In questa versione è impossibile l'esecuzione di windows 2000 server in modalità accelerata, per cui occorre usare KVM-72 adattato per Hardy fornito da Soren nel suo PPA: https://launchpad.net/~soren/+archive.
Copiare la ISO del sistema da installare nella vostra directory funzionante:of the system you want to install to your working directory:
yhamon@paris:~$ ls *.iso ubuntu-8.04-server-i386.iso windowsxpsp2.iso
oppure creare una ISO da cd/dvd:
dd if=/dev/dvd of=dvd.iso
Installare virt-install:
sudo apt-get install python-virtinst
Eseguire virt-install. SU Ubuntu Hardy, con KVM-62, l'installazione di windows XP non funziona se accelerata (cioè, usando --accelerate), Quindi bigsogna installare senza questo argomento e sosituire qemu con kvm nel file definizione XML (in /etc/libvirt/qemu) dopo il primo riavvio.
sudo virt-install --connect qemu:///system -n xpsp2 -r 512 -f windows.qcow2 -s 12 -c windowsxpsp2.iso --vnc --noautoconsole --os-type windows --os-variant winxp
Note per 8.10 (Intrepid): per far si che il precedente comando funzioni, aggiungere l'opzione --hvm per avere l'ospite completamente virtualizzato.
Questo avvierà una nuova VM dalla ISO. Connettere alla nuova VM usando virt-viewer:
virt-viewer -c qemu:///system xpsp2
Oppure se KVM è in funzione su di un altro server:
virt-viewer -c qemu+ssh://ip/system xpsp2
È quindi possibile avviare l'installazione. Un'altro problema è che dopo il primo riavvio, nel processo di installazione, il programma di installazione di windows, riferirà che non è più possibile trovare il disco d'installazione. Quindi nel file definizione XML della VM aggiungere le seguenti linee alla lista dei dispositivi:
<domain type='kvm'> [...] <devices> [...] <disk type='file' device='cdrom'> <source file='//home/nomeutente/windowsxpsp2.iso'/> <target dev='hdc' bus='ide'/> <readonly/> </disk> </devices> </domain>
Ridefinire la VM in virsh (sudo virsh define /etc/libvirt/qemu/xpsp2.xml) e riavviare la VM.
Un altro problema con la combinazione virt-install - Wndowsin combination with Windows è che il disco immagine creato è corrotto. inizialmente l'installazione sembra funzionare, ma dopo il primo riavvio si fermerà riportando il messaggio 'A read error occured'. Ciò può essere agevolmente risolto creando un nuovo disco immagine (prima dell'installazione):
qemu-img create -f qcow2 disk0.qcow2 12G
Sovrascrive il file qcow2 creato da virt-install con questo nuovo file, riavviare la VM.
Esempio di installazione di Ubuntu
Per installare Ubuntu Hardy eseguire il comando:
sudo virt-install --connect qemu:///system -n hardy -r 512 -f hardy.qcow2 -s 12 -c hardy-server-amd64.iso --vnc --noautoconsole --os-type linux --os-variant ubuntuHardy --accelerate --network=network:default
L'opzione '--network' imposta la machina all'uso della rete libvirt predefinita. Per un elenco delle reti libvirt usare il comando:
virsh net-list --all
Altri sistemi operativi
È possibile installare altri sistemi operativi seguendo il metocdo precedente. Consultare 'man virt-install' per maggiori informazioni e differenti opzioni per la macchina virtuale, SO supportati e relative varianti.
Attenzione: questo metodo non funziona con il LiveCD di Fedora Fedora LiveCD e probabilmente anche altri; vedere: [https://bugs.launchpad.net/ubuntu/+source/kvm/+bug/220463 bug #220463].
Clonazione di una macchina virtuale
È possibile clonare una macchina virtuale usando lo strumento virt-clone. Quest'ultimo duplicherà l'immagine del disco e configurerà il dominio della macchina virtuale.
Per clonare una macchina virtuale chiamata srchost in una nouva macchina newhost, assicurarsi che la macchina virtuale srchost non sia in esecuzione ed eseguire il seguente comando:
$ virt-clone --connect=qemu:///system -o srchost -n newhost -f /indirizzo/per/newhost.qcow2
Creazione di una macchina virtuale da un'immagine preesistente
Assumendo che:
- Virt-manager viene utilizzato per gestire macchine virtuali.
- Si vuole aggiungere un'immagine preesistente a virt-manager.
Caso d'uso:
Nel caso si voglia corrompere un immagine è possibile sperimentare pesantemente sulle macchine virtuali, senza dover eseguire complete reinstallazioni, usando qcow2 con overlays. Un lato positivo di questo metodo, rispetto alla clonazione, è il minor utilizzo di spazio su disco.
Procedura:
1. Creare un immagine del hard disk in formato qcow2:
$ qemu-img create -f qcow2 <nome immagine>.qcow2
2. Installare la macchina virtuale usando virt-manager:
Invece di consentire a virt-manager la creazione di una nuova immagine del disco, indirizzarlo all'uso dell'immagine precedentemente creata.
3. Creazione dell'overlay:
$ qemu-img create -f qcow2 -b <nome immagine>.qcow2 <nome immagine>.ovl
4. Creare l'immagine virtuale del descrittore XML.
Leggere prima di proseguire:
$ man virt-image $ man 5 virt-image
Copiare il file XML creato:
$ cp ~/.libvirt/qemu/<nome vm>.xml overlay.xml
Aprire ed editare il file XML copiato con l'editor preferito:
$ <editor> overlay.xml
Creare l'immagine virtuale del descrittore XML basandosi sulla pagina del manuale: virt-image(5), commentando il testo originale ed usandolo come guida durante la creazione del descrittore.
5. Creare la nuova macchina virtuale dall'immagine del descrittore:
$ virt-image --vnc overlay.xml
6. Avviare e verificare che la nuova macchina sia basata sull'overlay.
Avviare la macchina virtuale e testarla come meglio si crede. In caso di malfunzionamento, basta semplicemente distruggerla e cancellarla. Quindi ricreare l'immagine e la macchina overlay come descritto sopra. È possibile effettuare cambiamenti overlay all'immagine di base. In tal caso consultare il manuale alla pagina qemu-img per i dettagli.
Vedere anche
The system specific adjustment recommended in the FAQ.***********************ancorare a domande frequenti.
[http://packages.ubuntu.com/search?keywords=apt-cacher-ng apt-cacher-ng] per il mirroring.