[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [TEKNIK] KVM med base image



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2010-12-21 13:50, Kenni Lund wrote:
> 2010/12/21 Robert Larsen <sslug@sslug>:
>> Min VM som har UbuntuWebServerBase.img som disk starter fint op.
>
> ...hvis du bruger den som disk, er det jo ikke et base image? Base
> images er read only og må ikke blive ændret fra det øjeblik at du
> baserer andre images på det. Derfor fjerner man almindeligvis også
> alle skriverettigheder fra filen når man udnævner den til base
> image, så man ikke ved et uheld kommer til at starte et VM med
> det. Hvis du ændrer i base imaget - f.eks. ved at boote et VM som
> benytter base imaget som disk, så vil det resultere i
> datakorruption og i at alle images baseret på dette base image,
> ødelægges.
>
> Mvh. Kenni
>
>
Det ved jeg. Jeg opretter så en ny klon efter modifikationen. Det var
kun for at tjekke, at mit base image virker.

Det er så kun når jeg når ud i det tredje led at det går galt.

Jeg har faktisk lavet et script, som gør alt for mig, incl. at brokke
sig, hvis base image filen ikke er skrivebeskyttet:

#!/bin/bash
#vm_clone

VM_IMAGE_PATH=/var/lib/libvirt/images

if test -z "${2}"; then
    echo "Usage: ${0} <basehost> <newhost> [start]"
    exit
fi

BASE_HOST=${1}
NEW_HOST=${2}
BASE_HOST_IMG="${VM_IMAGE_PATH}/${BASE_HOST}.img"
NEW_HOST_IMG="${VM_IMAGE_PATH}/${NEW_HOST}.img"

if test $USER != "root"; then
    echo "You need to be root to run this script."
    exit 1
fi

if ! test -f "${BASE_HOST_IMG}"; then
    echo "No such base host: ${BASE_HOST}"
    exit 1
fi

if ls -l ${BASE_HOST_IMG}|awk '{print $1}'|grep w>/dev/null 2>&1; then
    echo "The base host image should not be writable."
    exit 1
fi

if test $(kvm-img info ${BASE_HOST_IMG} | grep "file format:" | awk -F
': ' '{print $2}') != "qcow2"; then
    echo "The base host image should use the qcow2 format."
    exit 1
fi

HOST_XML_FILE=$(tempfile)
virsh dumpxml ${BASE_HOST} | grep -v uuid | grep -v "mac address" |
sed "s/${BASE_HOST}/${NEW_HOST}/g" > $HOST_XML_FILE
kvm-img create -f qcow2 -b ${BASE_HOST_IMG} ${NEW_HOST_IMG} >/dev/null
chmod 600 ${NEW_HOST_IMG}
virsh define ${HOST_XML_FILE} >/dev/null
rm ${HOST_XML_FILE}

if test -n "${3}" && test "${3}" = "start"; then
    virsh start ${NEW_HOST}
fi
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk0QpGkACgkQzDMeisFqGZZijgCgpS1DtDr8hrTVt/LHsnOc/Opp
doEAnjowH94IKXk3R8ts/YFshisnCbPR
=NTGY
-----END PGP SIGNATURE-----



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2011-01-01, 02:01 CET [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *