Page 1 sur 1

Passer une VM Debian OpenVz Proxmox vers ESXi 5.0

Publié : mar. 14 août 2012 15:07
par augur1
J'ai un serveur sous ProxMox 1.9 avec des VM Debian en OpenVZ.

Je souhaite migrer l'une des VM OpenVZ (103) vers ESXi 5.0

Pour ce faire, j'ai sous la main 2 tuto ; je bloque sur les deux aux étapes ci dessous

1. http://www.raphink.info/2012/03/from-op ... mware.html
Install grub on the disk:
[cpp]grub-install --root-directory /mnt /dev/loop0[/cpp]

2. http://communities.vmware.com/message/1719787#1719787
convert image to VMDK format
[cpp]kvm-img convert -f raw speed.img -O vmdk speed.vmdk[/cpp]

Si vous avez une idée ou avez une autre méthode pour passer une VM en OpenVz de Proxmox à ESXi, je suis preneur !

++

Passer une VM Debian OpenVz Proxmox vers ESXi 5.0

Publié : mar. 14 août 2012 15:15
par poulpito
j'en vois pas bien d'autres ... ca bloque en disant quoi ?

Passer une VM Debian OpenVz Proxmox vers ESXi 5.0

Publié : mar. 14 août 2012 15:50
par augur1
La problématique : à priori une VM OpenVZ dans Proxmox ne contient pas le boot ; du coup, si on veut migrer directement une VM Proxmox OpenVZ vers ESXi = la VM ne bootera pas.
Tag : OpenVZ 2 ESXi ; Proxmox 2 Esxi ; OpenVz to VMWare

Voici donc la manip, adapté à mes besoins

Je crée un image de 2 Go
[cpp]dd if=/dev/zero of=/tmp/galerie.img bs=516096c count=4000
/sbin/mke2fs /tmp/galerie.img[/cpp]

Là il me dit
[cpp]/tmp/galerie.img is not a block special device.
Proceed anyway? (y,n)[/cpp]
Je réponds Y

Je crée le dossier /mnt/tmp

Ensuite je monte l'image
[cpp]mount -o loop /tmp/galerie.img /mnt/tmp[/cpp]

Je copie dans le répertorie /mnt/tmp qui correspond au RAW galerie.img
[cpp]cp -av /var/lib/vz/private/103/* /mnt/tmp[/cpp]

C'est là que je tente d'ajouter le bootloader :
[cpp]grub-install --root-directory=/mnt/tmp /dev/loop0[/cpp]

[#ff0000]L'erreur que j'obtiens : [/#ff0000]
[cpp]grub-probe: error: Cannot find a GRUB drive for /dev/loop0. Check your device.map.
[/cpp]

:fou:

Passer une VM Debian OpenVz Proxmox vers ESXi 5.0

Publié : mar. 14 août 2012 16:01
par Zedoune
galerie.img c'est une partition ou un disque ?
http://www.zplay.eu/article/10 si ça peut t'aider ;)

Passer une VM Debian OpenVz Proxmox vers ESXi 5.0

Publié : mar. 14 août 2012 16:02
par augur1
edt :

C'est là que je tente d'ajouter le bootloader :
[cpp]grub-install --root-directory=/mnt/tmp /dev/loop0[/cpp]

[#ff0000]L'erreur que j'obtiens : [/#ff0000]
[cpp]grub-probe: error: Cannot find a GRUB drive for /dev/loop0. Check your device.map.[/cpp]
galerie.img c'est une partition ou un disque ?
http://www.zplay.eu/article/10 si ça peut t'aider ;)
D'après ces manip, c'est le dossier /mnt/tmp

Passer une VM Debian OpenVz Proxmox vers ESXi 5.0

Publié : mar. 14 août 2012 16:09
par Zedoune
Essaie ça : http://ebroder.net/2009/08/04/installin ... isk-image/

C'est Linux qui ne reconnait pas correctement loop0 vu qu'au démarrage c'était pas un disque ^^

Passer une VM Debian OpenVz Proxmox vers ESXi 5.0

Publié : mar. 14 août 2012 16:14
par augur1
galerie.img c'est une partition ou un disque ?
http://www.zplay.eu/article/10 si ça peut t'aider ;)
Essaie ça : http://ebroder.net/2009/08/04/installin ... isk-image/

C'est Linux qui ne reconnait pas correctement loop0 vu qu'au démarrage c'était pas un disque ^^
Loop mount your partitioned disk image:
[cpp]ls -l /dev/loop0
brw-rw---- 1 root disk 7, 0 Aug 14 15:20 /dev/loop0
[/cpp]

To setup the device map, you’ll need the major and minor numbers of the loop device, and the size (in bytes) of the disk.
The latter is easiest to get from the disk image file, instead of from the loop device (emphasis mine):

[cpp]ls -l /tmp/galerie.img
-rw-r--r-- 1 root root 2064384000 Aug 14 15:44 /tmp/galerie.img
[/cpp]

Create a device-mapper node. Any name of the form hd[a-z], sd[a-z], or vd[a-z] will work. Others might as well.
The size of the disk should be converted to 512-byte sectors, and the device numbers for the loop device should be in the form major:minor.
This will create a new device node in /dev/mapper

[cpp]echo '0 20971520 linear 7:0 0' | sudo dmsetup create hda
-bash: sudo: command not found[/cpp]

Du coup, téléchargement du packet debian dmsetup
[cpp]wget http://ftp.de.debian.org/debian/pool/ma ... _amd64.deb[/cpp]

Installation du packet debian dmsetup
[cpp]sudo dpkg -i dmsetup_1.02.48-5_amd64.deb[/cpp]
= moultes erreur : manque des fichiers dépendants
... et dpkg -i dmsetup_1.02.48-5_amd64.deb apt-get -f install = erreur "cannot access archive: No such file or directory"

Passer une VM Debian OpenVz Proxmox vers ESXi 5.0

Publié : mar. 14 août 2012 16:24
par Zedoune
t'as essayé d'ajouter "--recheck" à grub-install ?

Passer une VM Debian OpenVz Proxmox vers ESXi 5.0

Publié : mar. 14 août 2012 16:31
par augur1
t'as essayé d'ajouter "--recheck" à grub-install ?
[cpp]grub-install --root-directory=/mnt/tmp /dev/loop0 --recheck[/cpp]
ou
[cpp]grub-install --recheck --root-directory=/mnt/tmp /dev/loop0[/cpp]

= même erreur :
[cpp]grub-probe: error: Cannot find a GRUB drive for /dev/loop0. Check your device.map.[/cpp]

Passer une VM Debian OpenVz Proxmox vers ESXi 5.0

Publié : mar. 14 août 2012 16:32
par Zedoune
http://www.omninerd.com/articles/Instal ... Image_File

Ici ils proposent d'utiliser --device-map=/dev/null :D

Passer une VM Debian OpenVz Proxmox vers ESXi 5.0

Publié : mar. 14 août 2012 20:12
par augur1
http://www.omninerd.com/articles/Instal ... Image_File

Ici ils proposent d'utiliser --device-map=/dev/null :D
Sauf que lui a des fichiers boot, qu'il copie
[cpp]mkdir -p mnt/hdd/boot/grub
cp -r /boot/grub/stage1 /boot/grub/stage2 /boot/grub/menu.lst mnt/hdd/boot/grub
cp -r the_kernel mnt/hdd/
[/cpp]
.... fastoche ! sauf que la débian en OpenVZ dans Proxmox n'a pas ces fichiers boot :/

Avec de légères corrections :

Création du fichier rempli de 0 de 2gigs :

Code : Tout sélectionner

dd if=/dev/zero of=/tmp/galerie.img bs=516096c count=4000
Créer une table de partition, important a faire ça !

Code : Tout sélectionner

cd /tmp
fdisk galerie.img

.... avec ça comme param : o x c 2048 r n p 1 2048 w
( pas de table de partition = la suite du tuto marchera pas et grub voudra rien savoir )


On monte un loopback qui va simuler un block device pour notre image :

Code : Tout sélectionner

losetup -o 2048 /dev/loop0 galerie.img

... sinon mk2fs nous fera chier sa maman et a partir de ce moment là, on ne travaillera plus en mode image puisqu'on aura un block device virtuel
(le driver loop s'occupe de tout, sinon grub peu pas bosser non plus /!\ne pas oublier de renseigner le -o cylindre par rapport a ta taille de partoche ! /!\)



On formate le block device monté avec une taille de block de 1k :

Code : Tout sélectionner

/sbin/mke2fs -b1024 /dev/loop0


On installe une journalisation sur le block device, optionnel :

Code : Tout sélectionner

tune2fs -j /dev/loop0
On monte notre block device dans un coin, on s'en fou de dire que c'est un loop a mount, puisque le block device virtuel a déjà été configuré AVANT :

Code : Tout sélectionner

mount /dev/loop0 /mnt/tmp
On fait la copie du raw :

Code : Tout sélectionner

cp -av /var/lib/vz/private/103/* /mnt/tmp
Jusque là tout se passe bien


et hop on grubise

Code : Tout sélectionner

grub-install --root-directory /mnt/tmp /dev/loop0
Sauf qu'il me dit :
[cpp]grub-install --root-directory /mnt/tmp /dev/loop0
Unrecognized option `--root-directory'
Usage: grub-install [OPTION] install_device
Install GRUB on your drive.

-h, --help print this message and exit
-v, --version print the version information and exit
--root-directory=DIR install GRUB images under the directory DIR
instead of the root directory
--grub-shell=FILE use FILE as the grub shell
--no-floppy do not probe any floppy drive
--force-lba force GRUB to use LBA mode even for a buggy
BIOS
--recheck probe a device map even if it already exists

INSTALL_DEVICE can be a GRUB device name or a system device filename.

grub-install copies GRUB images into the DIR/boot directory specfied by
--root-directory, and uses the grub shell to install grub into the boot
sector.

Report bugs to .
[/cpp]

What iz ze goud wey tou procid ?

Passer une VM Debian OpenVz Proxmox vers ESXi 5.0

Publié : mar. 14 août 2012 20:21
par augur1
et hop on grubise

Code : Tout sélectionner

grub-install --root-directory /mnt/tmp /dev/loop0
Sauf qu'il me dit :
[cpp]grub-install --root-directory /mnt/tmp /dev/loop0
Unrecognized option `--root-directory'
Usage: grub-install [OPTION] install_device
Install GRUB on your drive.

-h, --help print this message and exit
-v, --version print the version information and exit
--root-directory=DIR install GRUB images under the directory DIR
instead of the root directory
--grub-shell=FILE use FILE as the grub shell
--no-floppy do not probe any floppy drive
--force-lba force GRUB to use LBA mode even for a buggy
BIOS
--recheck probe a device map even if it already exists

INSTALL_DEVICE can be a GRUB device name or a system device filename.

grub-install copies GRUB images into the DIR/boot directory specfied by
--root-directory, and uses the grub shell to install grub into the boot
sector.

Report bugs to .
[/cpp]

What iz ze goud wey tou procid ?
Peut être une idée :
=> http://savannah.gnu.org/bugs/?27737
I found a workaround. It seems that the problem is the extra subdirectory in /dev/mapper.

If I recreate the block devices that are under /dev/mapper and place them directly under /dev (with a different name), and update the device.map file for grub2, then I can install grub onto the disk using grub-install

Step 1: lookup the major/minor created under /dev/mapper
Step 2: mknod the same devices directory under /dev

I created two devices /dev/mapper/sda and /dev/mapper/sda1 using dmsetup and kpartx. /dev/mapper/sda received major device number 252 and minor 0, and /dev/mapper/sda1 received minor 1.

Then I did:


[cpp]mknod /dev/msda b 252 0
mknod /dev/msda1 b 252 1[/cpp]

Make sure that you mount /dev/msda1 instead of /dev/mapper/sda1, update your device.map with "(hd0) /dev/msda" and voila, grub-install works.
.... par contre, aucune idée de comment faire sous Debian !! :/

++

Passer une VM Debian OpenVz Proxmox vers ESXi 5.0

Publié : mar. 14 août 2012 20:44
par fighting_falcon
passe par un chroot :

mount -o bind /proc /mnt/tmp/proc
mount -o bind /sys /mnt/tmp/sys
mount -o bind /dev /mnt/tmp/dev
chroot /mnt/tmp
grub-install /dev/loop0

Passer une VM Debian OpenVz Proxmox vers ESXi 5.0

Publié : mar. 14 août 2012 20:49
par augur1
passe par un chroot :

mount -o bind /proc /mnt/tmp/proc
mount -o bind /sys /mnt/tmp/sys
mount -o bind /dev /mnt/tmp/dev
chroot /mnt/tmp
grub-install /dev/loop0

Ne fonctionne pas :
[cpp]grub-install /dev/loop0
grub-install: command not found[/cpp]

Passer une VM Debian OpenVz Proxmox vers ESXi 5.0

Publié : mer. 15 août 2012 08:59
par fighting_falcon
bon je viens de lire les tutos que tu cites au 1er post ...

je ne sais pourquoi ils voulait à tout prix te faire lancer grub-install depuis ton hôte en spécifiant un root-directory ...

donc, pour finir, une fois dans ton chroot :
* vérifie que tu as bien un fichier /etc/apt/sources.list avec un contenu correct. Au minimum (cf http://debgen.simplylinux.ch/ ) :
deb http://ftp2.fr.debian.org/debian squeeze main contrib non-free
deb http://ftp.debian.org/debian/ squeeze-updates main contrib non-free
deb http://security.debian.org/ squeeze/updates main contrib non-free
* vérifie le fichier /etc/inittab comme indiqué dans les tutos
* vérifie le fichier /etc/fstab
* apt-get update
* apt-get install grub-pc linux-image- # = 686 ou amd64 selon ton cas
* grub-install /dev/loop0
* update-grub