This siteAll blogsLe 17ClémentCCBCuisineLe 3ContactSe connecterS'inscrire
  • All blogs
  • Le 17
  • Clément
  • CCB
  • Cuisine
  • Le 3
  • Contact

  • S'inscrire

Recettes informatiques

  • Page de garde
  • Contact
  • Se connecter
  • « Montage SSHFS

Clone a Debian system

Posted by mazet on Nov 10 2009 in Systeme, Debian

This is my own recipe to clone a Debian system on two hard disks. It can also be done via network connection (ssh) if the two disks are not in the same computer; it only need to setup the network connections by ifconfig

Boot on RescueCD

Shell

rescuecd docache

If it can't find media (too long anwser), after the liveCD get up to a secure shell, try again using

Shell

exec /linuxrc

Choose the French language by entering the value 16 or fr

Find origanal device

Find original device and list partition table

Shell

fdisk -l /dev/sda

Mount it

Shell

mkdir /mnt/orig
mount /dev/sda1 /mnt/orig

Find clone device and partition it

Shell

echo "n p 1 1 100G n p 2  4G t 2 83 w" | \
    sed 's/ /\n/g' | \
    fdisk /dev/sdb

Format clone partitions

Shell

mkfs -t ext3 /dev/sdb1
mkswap /dev/sdb2

Mount clone

Shell

mkdir /mnt/clone
mount /dev/sdb1 /mnt/clone

Clone disk

Shell

rsync -va /mnt/orig/ mnt/clone

Check that clone coresponds to original

Shell

ls /mnt/orig /mnt/clone

Install grub

  • for grub 1

    Shell

    grub-install --root-directory=/mnt/clone --recheck /dev/sdb
  • for grub 2

    Shell

    grub2-install --root-directory=/mnt/clone --recheck /dev/sdb
    Remove UUID reference in /boot/grub/grub.cfg by replacing root=UUID=... by root=/dev/sda1. After first boot, you will need to update grub2 configuration with update-grub2

Configure network interfaces

Shell

orig=1
clone=2
sed -i 's/\(172\.16\.0\.)'$orig'/\1'$clone'/' \
    /mnt/clone/etc/network/interfaces \
    /mnt/clone/etc/hosts
sed -i 's/\(blade-\)'$orig'/\1'$clone'/' \
    /mnt/clone/etc/hostname \
    /mnt/clone/etc/hosts
rm /mnt/clone/etc/udev/rules.d/70-persistent-net.rules

Rebuild ssh keys

Shell

ssh-keygen -t dsa -f /mnt/clone/etc/ssh/ssh_host_dsa_key
ssh-keygen -t rsa -f /mnt/clone/etc/ssh/ssh_host_rsa_key

Unmount disks

Shell

umount /mnt/orig
umount /mnt/clone

Reboot clone blade

This entry was posted by mazet and filed under Systeme, Debian.

No feedback yet

Catégories

  • Toutes
  • Non catégorisé
  • Programmation
    • Awk
    • Bash
    • C
    • C++
    • Javascript
    • LaTeX
    • Perl
    • Tcl/Tk
  • Systeme
    • Android
    • Debian
    • Ubuntu

Contenu

  • Linux Router
  • Creating a network between 2 virtual machines on Windows with Qemu
  • Build a Debian package for pdmenu
  • Extract informations from epub file
  • Connexion PostgreSql / Java par Socket Unix
  • Example of fork and respawn
  • Start SSH daemon on Git portable distribution
  • Create a git mirror
  • Color diff
  • Create on Debian a Minecraft server
  • GIT/HG/SVN on multiple repos simultaneously
  • Convert Comics into CBZ format
  • Random password generator function
  • Convert to camelCase
  • DKIM and SPF
  • Migration from BackupPC 3 (Debian package) to BackupPC 4 (Standalone Installation)
  • Minimal BC for Mingw
  • Diskless Debian cluster
  • Colorize log file
  • Generate certificates with (or without) a certificate authority
Novembre 2025
Lun Mar Mer Jeu Ven Sam Dim
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
 << <   > >>
  • Accueil
  • Récemment
  • Archives
  • Catégories
  • Derniers commentaires

Rechercher

Flux XML

  • RSS 2.0: Posts
  • Atom: Posts
More on RSS

©2025 by Laurent Mazet • Contact • Aide • b2evolution

RWD CMS

Cookies are required to enable core site functionality.