Restauration d’une image Linux depuis un live CD

Updated on 2009-04-09 by Kerim Teboulbi

Updated on 2009-04-08 by Kerim Teboulbi

Created on 2009-03-24 by Kerim Teboulbi

 

Restauration d’une image Linux depuis un live CD

[demarrage_du_liveCD]Démarrage du live cd et contrôle à distance :

[Formatage]Formatage du disque

[Restauration]Restauré l’image

[Premier_demarrage]Premier démarrage

 

Après avoir restaurer l’image du le système. Il faut réinstaller Grub sinon il y aura des problèmes d’installation.

[demarrage_du_liveCD]Démarrage du live cd et contrôle à distance :

 

Démarrer le serveur asterisk sur le live cd. Il suffit d'appuyer sur enter quand on démarre.

 

Lorsque le démarrage demande de changer de clavier, il faut choisir le clavier suisse en entrant  43. Vous avez 20 secondes pour le faire

 

 

A la fin du démarage vous verrez cette ligne.

 

 

Vous allez devoir définir un mot de passe simple, par exemple qwertz, ce mot de passe sera exclusivement utilisé pour vous connecter a distance pour simplifier la restauration du système.

 

root@sysresccd /root % passwd

Enter new UNIX password:

Retype new UNIX password:

passwd: password updated successfully

 

 

On attribut une adresse a notre interface avec la commande :

root@sysresccd /root % dhclient eth0

Internet Systems Consortium DHCP Client V3.1.0-Gentoo

Copyright 2004-2007 Internet Systems Consortium.

All rights reserved.

For info, please visit http://www.isc.org/sw/dhcp/

 

Listening on LPF/eth0/00:0d:b9:0d:63:80

Sending on   LPF/eth0/00:0d:b9:0d:63:80

Sending on   Socket/fallback

DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 5

DHCPOFFER from 192.168.1.1

option_space_encapsulate: option space agent does not exist, but is configured.

DHCPREQUEST on eth0 to 255.255.255.255 port 67

DHCPACK from 192.168.1.1

bound to 192.168.1.xxx -- renewal in 34430 seconds.

 

 

Se connecter sur l'ALIX avec le ssh en utilisant putty (vous pouvez le télécharger sur le site officiel [go] ou une copie local ici [exe]).

 

Remarque: Astuce pour putty vous pouvez coller la commande que vous avez copier depuis la page web en cliquant droit sur l'écran de putty.  

 

Dans le cas précis nous allons travailler avec l'adresse : 192.168.1.xxx (adresse IP attribuée par le DHCP)

 

 

Login : root

Password que vous avez mis en haut, par exemple qwertz

 

[Formatage]Formatage du disque

sysresccd ~ # fdisk /dev/sda

 

Command (m for help): d

Selected partition 1

 

Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-971, default 1): 1

Last cylinder or +size or +sizeM or +sizeK (1-971, default 971): 971

 

Command (m for help): w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

Syncing disks.

sysresccd cdrom # mkfs -t ext3 /dev/sda1

mke2fs 1.40.2 (12-Jul-2007)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

489600 inodes, 978760 blocks

48938 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=1002438656

30 block groups

32768 blocks per group, 32768 fragments per group

16320 inodes per group

Superblock backups stored on blocks:

        32768, 98304, 163840, 229376, 294912, 819200, 884736

 

Writing inode tables: done

Creating journal (16384 blocks): done

Writing superblocks and filesystem accounting information: done

 

This filesystem will be automatically checked every 30 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

 

[Restauration]Restauré l’image

 

Se deplacé dans le repertoire CDROM du live cd, trouver le fichier qui servira à la restauration et restaurer ce fichier.

sysresccd ~ # cd /mnt/cdrom

sysresccd cdrom # ls *.000

090324-0225500125.000

sysresccd cdrom # partimage -b -f3 restore /dev/sda1 yymmdd-xxxxxxxxxx.000

 

 

sysresccd cdrom # mount /dev/sda1 /mnt/custom/

sysresccd cdrom # mount -o bind /dev /mnt/custom/dev

sysresccd cdrom # mount -o bind /proc /mnt/custom/proc

sysresccd cdrom # chroot /mnt/custom/ /bin/bash

sysresccd:/# sed -i.BAK 's/hda/sda/' /boot/grub/device.map

sysresccd:/# sed -i.BAK 's/hda1/sda1/' /etc/mtab

sysresccd:/# sed -i.BAK 's/hda1/sda1/' /etc/fstab

sysresccd:/# grub-install /dev/sda

Searching for GRUB installation directory ... found: /boot/grub

Installation finished. No error reported.

This is the contents of the device map /boot/grub/device.map.

Check if this is correct or not. If any of the lines is incorrect,

fix it and re-run the script `grub-install'.

 

(hd0)   /dev/sda

sysresccd:/# mv /boot/grub/device.map.BAK /boot/grub/device.map

sysresccd:/# mv /etc/mtab.BAK /etc/mtab

sysresccd:/# mv /etc/fstab.BAK /etc/fstab

sysresccd:/# exit

exit

sysresccd cdrom # umount /mnt/custom/dev/

sysresccd cdrom # umount /mnt/custom/proc/

sysresccd cdrom # umount /mnt/custom

sysresccd cdrom # reboot

 

Maintenant vous pouvez enlever le lecteur DVD pour démarer normalement sur l'image qui vient d'être recréer.

[Premier_demarrage]Premier démarrage

Après s'être connecté la première fois avec le login root et avec le premier password root qui vous a été communiqué dans la lettre de bienvenue, tapez les deux commandes ci-dessous.

 

SwitzernetPBX:~# rm /etc/udev/rules.d/z25_persistent-net.rules

SwitzernetPBX:~# reboot

 

*          *          *