• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 682
  • Last Modified:

How to clone Debian Linux server

Hi,

one of my customers has 7 yrs old Linux server on a PC-hardware, and I would like to back it up in case of hardware fault. Performance-wise it is sufficient, does not suffer from bottlenecks, CPU and disk handle it perfectly...and most of all, it has been tuned an setup every now or then, so now it works perfectly, blocking spam, blocking unwanted web sites, defending attacks, filtering traffic, graphing all netwotk with MRTG, alerting, serving as VPN server etc.
And we also have simmilar hardware still on stock (reserved for long-time warranty), unused...so I do not see any reason why not to keep it, versus brand new solution.

But I have had problems cloning hard disk.
Tried with Acronis and Norton Ghost, different vestions, copying partitions or full disk, sector-by-sector...any method produced non-bootable clone. It is few months ago, so I do not remember exact error, but it was something to do with Grub...partition start and end points did not match on source and cloned disk, if I remember right.

So my idea is to try again.
Maybe with dd?

But as I am not Linux expert, I am not sure if DD will handle it...
As I know, there is some sort of SOFTWARE MIRROR...
I do not know if there is LVM involved...regarding to output, it is NOT.

This is what I know:
charlie-1:~# mount
/dev/sda2 on / type reiserfs (rw,noatime,notail)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
usbfs on /proc/bus/usb type usbfs (rw)
/dev/sda3 on /samba type reiserfs (rw,noatime,notail)

charlie-1:~# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              18G   15G  3.3G  82% /
tmpfs                 188M     0  188M   0% /dev/shm
/dev/sda3             135G  2.2G  132G   2% /samba

charlie-1:~# uname -r
2.6.14.5-sata-raid1

charlie-1:~# cat /etc/issue
Debian GNU/Linux testing/unstable \n \l

charlie-1:~# lsb_release -a
-bash: lsb_release: command not found

charlie-1:~# cat /etc/*-release
cat: /etc/*-release: No such file or directory

charlie-1:~# pvdisplay
-bash: pvdisplay: command not found

Open in new window


And this is from GRUB:

charlie-1:~# ls -al /boot/grub/
ls: unrecognized prefix: do
ls: unparsable value for LS_COLORS environment variable
total 185
drwxr-xr-x   2 root     root          408 Dec  5  2006 .
drwxr-xr-x   3 root     root          704 Nov 15  2006 ..
-rw-r--r--   1 root     root          197 Oct 23  2006 default
-rw-r--r--   1 root     root           14 Dec  5  2006 device.map
-rw-r--r--   1 root     root         7584 Oct 23  2006 e2fs_stage1_5
-rw-r--r--   1 root     root         7424 Oct 23  2006 fat_stage1_5
-rw-r--r--   1 root     root         8192 Oct 23  2006 jfs_stage1_5
-rw-r--r--   1 root     root         4036 Dec  5  2006 menu.lst
-rw-r--r--   1 root     root         3603 Aug 22  2006 menu.lst~
-rw-r--r--   1 root     root         6848 Oct 23  2006 minix_stage1_5
-rw-r--r--   1 root     root         9280 Oct 23  2006 reiserfs_stage1_5
-rw-r--r--   1 root     root          512 Oct 23  2006 stage1
-rw-r--r--   1 root     root       108392 Oct 23  2006 stage2
-rw-r--r--   1 root     root         8904 Oct 23  2006 xfs_stage1_5
charlie-1:~# cat /boot/grub/menu.lst
default         0
timeout         5

# Pretty colours
color cyan/blue white/blue

title           Debian GNU/Linux, kernel 2.6.14.5-sata_raid1
root            (hd0,1)
kernel          /boot/vmlinuz-2.6.14.5-sata_raid1 root=/dev/sda2 ro
savedefault
boot

title           Debian GNU/Linux, kernel 2.6.14.5-sata
root            (hd0,1)
kernel          /boot/vmlinuz-2.6.14.5-sata root=/dev/hda2 ro
savedefault
boot

title           Debian GNU/Linux, kernel 2.6.14.5-sata (recovery mode)
root            (hd0,1)
kernel          /boot/vmlinuz-2.6.14.5-sata root=/dev/hda2 ro single
savedefault
boot

title           Debian GNU/Linux, kernel 2.6.14.5
root            (hd0,1)
kernel          /boot/vmlinuz-2.6.14.5 root=/dev/hda2 ro
savedefault
boot

title           Debian GNU/Linux, kernel 2.6.14.5 (recovery mode)
root            (hd0,1)
kernel          /boot/vmlinuz-2.6.14.5 root=/dev/hda2 ro single
savedefault
boot

title           Debian GNU/Linux, kernel 2.6.14.4
root            (hd0,1)
kernel          /boot/vmlinuz-2.6.14.4 root=/dev/hda2 ro
savedefault
boot

title           Debian GNU/Linux, kernel 2.6.14.4 (recovery mode)
root            (hd0,1)
kernel          /boot/vmlinuz-2.6.14.4 root=/dev/hda2 ro single
savedefault
boot

title           Debian GNU/Linux, kernel 2.6.8-2-686
root            (hd0,1)
kernel          /boot/vmlinuz-2.6.8-2-686 root=/dev/hda2 ro
initrd          /boot/initrd.img-2.6.8-2-686
savedefault
boot

title           Debian GNU/Linux, kernel 2.6.8-2-686 (recovery mode)
root            (hd0,1)
kernel          /boot/vmlinuz-2.6.8-2-686 root=/dev/hda2 ro single
initrd          /boot/initrd.img-2.6.8-2-686
savedefault
boot

### END DEBIAN AUTOMAGIC KERNELS LIST
charlie-1:~#

Open in new window



Could you advice me:
- what should I check prior to doing full disk image?
- which tool should I use?
- if MOUNTING is involved...please, give me step-by-step instructions how to mount external drive

Thanx!
0
Andrej Pirman
Asked:
Andrej Pirman
3 Solutions
 
farzanjCommented:
If the hardware is not the same, you cannot clone it.  If it is same then there are many ways to do it.  But there still will be problems after you do it and you will have to take care of it.

You have to use advance tar command options, one partition at a time.  Do a minimal install of the system and then overwrite one partition at a time.
0
 
Andrej PirmanAuthor Commented:
Actually, I have IDENTICAL HW, so my goal is to clone existing disk (working firewall) onto another disk, so to have it mounted into 2nd hardware, to be ready in case of failure.
0
 
farzanjCommented:
This makes the things a whole lot easier. However the problem is that you would need to somehow get the hard drivers of the target machines connect to the source machine.

http://www.backuphowto.info/linux-backup-hard-disk-clone-dd

0
 
farzanjCommented:
You can use dd but the trick would be to bring the source system up using rescue media/live CD.

0
 
shahzoorCommented:
Acronis Backup and Recovery can do it for you

Acronis® Backup & Recovery™ 11 Advanced Server
http://www.acronis.com/backup-recovery/advanced-server/#overview

As far as the Booting problems is concerned after cloning, it happens in newer versions of especially in Linux because it copies the hardware id.
During the backup in advanced settings you can turn off that feature
0
 
amit_panjwaniCommented:
My 2 cents :

Why do you need to clone it in the bery first place ?

Why not just backup config files - ? Understand them - Apply them on new server..

Cloning is temporary solution - with its own pitfalls.
Understanding config will further allow you ttroubleshoot faster and look for further refinements/other software benchmarks for better performance and security.
0
 
Andrej PirmanAuthor Commented:
Hi all,

I somehow decided to go with "dd".
Can somebody give me some details or instructions, particullary on:
- how to "dd" boot sector...I mean, how to deal with GRUB when doing dd copy?
- how to mount new drive, actually, how to do anything prior to issuing "dd...." command?

Once then I have "dd" clone of a drive, I'll test it to see if it boots and runs OK.
Then my idea is to make a script, which would "dd" partitions on a weekly basis....on weekends, for example. What do you think?

That would be it.
Thanx!
0
 
Andrej PirmanAuthor Commented:
SOLVED!

I apologee for the distribution failure - mine server was not Debian, but RHEL RedHat 5.1.19. Nevermind...I solved the cloning problem myself:

As told, after cloning the cloned disk was not bootable. GRUB did not start, displaying only "GRUB" in top left corner and nothing more.
I found an article on net (sorry, lost the link, I just have copied text).

Here is what I did to fix this:
I ALREADY HAVE: disk-to-disk clone, made with either Norton Ghost or Acronis True Image. It is not bootable, but is exact copy.

1. Since I did not have and could not obtain RedHat RHEL 5.1.19 instalation media, I downloaded CentOS 5.7 first installation CD.

2. Then I booted from this media, having cloned (non-working) disk connected as the only disk.

3. At the boot screen, I chose F5 - Rescue

4. At the next prompt screen, entered:
linux rescue

5. Checked with
df -h
to see, that my partitions were mostly mapped under /mnt/sysimage/

Here I guess that /dev/hda coresponds to (hd0) for GRUB. But caution - this is my guess, which worked for me, but I cannot guarantee it works for you, too.

6. Ok, let's reinstall GRUB interactively:
grub

7. Then type:
root (hd0,0)
setup (hd0)

If all goes fine, something like this should appear on the screen:
install /grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/grub/stage2 /grub/grub.conf

8. Once done, finish:
quit

9. Remove CD and exit rescue mode:
exit

10. Reboot and if yo lucky, you should get to normal login prompt.

hope this helps somebody!

-------------

Regarding backup, in my case only one directory is important and only under this one changes are made during operation. So I included this directory in my daily FILE backup (via samba share), so in case of disaster, I only need to use cloned disk, copy over the directory content, and voila!...I have working hardcore backup on another hardware.
0
 
Andrej PirmanAuthor Commented:
Thanx guyz,
none of you offered complete solution, but you tried.
0
Tackle projects and never again get stuck behind a technical roadblock.
Join Now