| Using Linux to backup and recover Windows and Linux systems |
| Posted by: shshjun on 03-20-2005. (557 views) |
Using Linux to backup and recover Windows and Linux systems
name: s. shen (shshjun@yahoo.com)
date: 03/20/2005
This document explains how to backup windows/Linux (so that you don't need to install again and again)
0.system configuration
the test is on HP pavilion 716n x86 workstation with 2 80GB hard disks and 1GB memory (allow 32M for graphic card)
It has the following system on
Windows XP prof with SP2 (winxp)
SUSE linux Server 9.0 (sles)
SUSE Linux Professional 9.2 (slp)
Java Desktop System Release II (jds)
Solaris 10 for x86
The partition info is (using fdisk – l )
/dev size note
dev/hda1 (primary) 24G
dev/hda2 (primary) 24G
Windows user data dev/hda5 (extended) 4.8G
Windows user data (iso files etc) dev/hda6 4.8G
Windows user data (holder for burning DVD) dev/hda7 1G
Windows user data dev/hda8 700M
Windows user data (holder for burning CD) dev/hda9 15G
SLES dev/hda10 2G
Oss as sharing for operating systems dev/hda11 600M
Boot loader using JDS grub dev/hda12 2G
Linux swap dev/hda1(primary) 30G
reserved for Solaris dev/hda2(primary) 24G
Windows user data dev/hda5(extended) 2G
Linux swap dev/hda6 12G
JDS dev/hda7 12G
SLP
1.bootloader installation
do a minimum installation of JDS just for grub loader, not x, no
device drivers, no network. You may want to add your preferred editor
(if not vi) such as pico
use reiserfs is fine. I prefer to use ext3 for this partition.
the configuration files are:
code:linux:/media/iso # cat etc/fstab
/dev/hda11 / ext3 defaults 1 1
/dev/hda9 /sles auto noauto,user 0 0
/dev/hda10 /oss auto noauto,user 0 0
/dev/hdb6 /data3 auto noauto,user 0 0
/dev/hdb7 /data4 auto noauto,user 0 0
/dev/hda12 swap swap pri=42 0 0
/dev/hdb5 swap swap pri=42 0 0
devpts /dev/pts devpts mode=0620,gid=5 0 0
proc /proc proc defaults 0 0
usbdevfs /proc/bus/usb usbdevfs noauto 0 0
/dev/cdrecorder /media/cdrecorder auto ro,noauto,user,exec 0 0
/dev/cdrom /media/cdrom auto ro,noauto,user,exec 0 0
/dev/dvd /media/dvd auto ro,noauto,user,exec 0 0
/dev/fd0 /media/floppy auto noauto,user,sync 0 0
code:linux:/media/iso # cat boot/grub/menu.lst
gfxmenu (hd0,11)/boot/message
color white/blue black/light-gray
default 0
timeout 8
title jds - java desktop system ii
kernel (hd1,5)/boot/vmlinuz root=/dev/hdb6 hdc=ide-scsi vga=794
initrd (hd1,5)/boot/initrd
title sles - suse linux enterprise server 9.0
kernel (hd0,9)/boot/vmlinuz root=/dev/hda10 vga=0x31a splash=silent
noresume
initrd (hd0,9)/boot/initrd
title slp - suse linux prof 9.2
kernel (hd1,6)/boot/vmlinuz root=/dev/hdb7 vga=0x31a noresume
initrd (hd1,6)/boot/initrd
title solaris 10
root (hd1,0)
makeactive
chainloader +1
title jdsboot
kernel (hd0,10)/boot/vmlinuz root=/dev/hda11 hdc=ide-scsi vga=794
initrd (hd0,10)/boot/initrd
now let's say that all other systems (winxp, sol10, sles, slp) are ready and the boot menu is from jdsboot grub
2.install captive for windows backup
to support NTFS write support, i installed Captive (http://www.jankratochvil.net/project/captive/) on slp.
How to install Captive on SUSE Linux professional 9.2?
download
http://www.jankratochvil.net/project/captive/dist/captive-static-1.1.5-0.i386.rpm
http://www.jankratochvil.net/project/captive/dist/captive-1.1.5.tar.gz
http://www.jankratochvil.net/project/captive/dist/lufs-0.9.7captive8.tar.gz
note that captive rpm works fine. Download source if you prefer. You do need to get lufs source.
rpm -ivh captive-static-1.1.5-0.i386.rpm
you then get ntfs driver from your system or from web by running
captive-install-acquire
then mount your windows
mount -t captive-lufs /dev/hda1 /windows/c
sure you will have problem. To resolve it, compile your kernel (so many doc on this).
For example, i run the following:
code: su root
uname -rm
cd /usr/src/linux
make oldconfig
make all
drink coffee
make modules_install
make install # you may need to backup something now
# make clean
reboot
do a
code: su
tar zxf /tmp/lufs-0.9.7captive8.tar.gz
./configure;
make;
/usr/share/lufs/captive_modprobe
exit
and finally you are ready to use captive and write your ntfs by
code: su
mount -t captive-lufs /dev/hda1 /windows/c
exit
3.backup and recover linux
To backup linux os with your customization is really easy. I would
suggest to use an external harddisk for this purpose. If not, have a
big partition (such as using /dev/hdb2 in my example)
I will use /dev/sdc2 via a USB external hard disk for my backups.
The following will backup your linux partition jds (/dev/hdb6) when you are running slp
code: su
mount /dev/hdb6 /jds # (the partition to backup)
mount /dev/sdc2 /oss # (the external hard disk)
cd /jds
tar zcf /oss/jds.tar.gz .
cd ..
umount /jds
umount /oss
exit
# (you don't need to exclude anything as space is not a problem. Or you do)
The following will recover a linux operating system with your fully customized settings and user data – everything
code: su
mount /dev/hdb6 /jds # (the partition to backup)
mount /dev/sdc2 /oss # (the external hard disk)
cd /jds
rm -rf * # (if you didn't format, erase everything)
tar zxf /oss/sles.tar.gz .
cd ..
umount /jds
umount /oss
exit
and you are so happy that you followed me to get a recovered system within 10 minutes!
The whole cycle of backup and recovery takes half an hour or so. Note that once you recovered your jds system, do a
fdisk – l
to check for safety. If you noticed any changes which you wouldn't,
modify your recovered jds system files (/etc/fstab and
/boot/grub/menu.lst to allow it boots later). When this is the case,
you may need to modify jdsboot's setting as well.
4.backup and recover windows
We now have captive running on slp. It's time to backup your windows.
If you separated your data from your system, you only need to back
system drive, generally speaking.
Note: all links to other windows drives, such as database files, your
web sites, your personal info, etc, will get back once your system
drive recovered (giving that no changes on those linked data on other
drives, of course)
noted that lufs doesn't support to read certain files (drivers i guess) such as IO.SYS
so mount as ntfs for read-only to do a backup first. Depending on your
system, the size of your whole windows system drive will vary from 4 ~
12 GB
code: su
mount -t ntfs /dev/hda1 /windows/c
mount /dev/sda2 /oss
cd /windows/c
tar zcf /oss/os/winxp.tar.gz . # (or 3 tarballs here)
# note: you do not want to back up your pagefile.sys
# note: it seemed that captive doesn't support writing files >1G in ntfs. My pagefile.sys is 1.5G and failed to be unpacked later.
# note: it's wise to have 3 tarballs for your windows backup should you need to burn CD/DVD: one for WINDOWS folder; one for PROGRAM FILES folder; one for all other files.
# note: you may want to set recovery off in windows and remove all windows update uninstaller to speed up the recovery process.
cd ..
umount /windows/c
umount /oss
exit
Now the backup is done. I didn't do backups for other windows drives.
Feel free to do it yourself and not explained here as example.
Let's start recovery – this is a bit complex, however. I am trying to
find easier ways since i do not have a windows xp boot diskette set.
First, erase all files on /dev/hda1
unfortunately you can't do it within slp. Reboot the machine and use
your windows XP installation CD/DVD to start the installation on the
same partition (it is not necessary to be the same partition, in my
opinion, guess who doesn't) and select new installation then a FAST
format NTFS on the partition. Once done and windows tries to copy
files, popup the CD and reboot.
Note: in my test somehow when i did a full format it failed the
recovery later. Didn't try again. It saves time by quick format anyway.
When reboot, since the format changed MBR and now you need your linux
installation CD/DVD to boot to jdsboot now. Choose manual installation
then boot existing system and select /dev/hda11 (my jdsboot) you should
now boot to jdsboot with no problem.
Login as root and run
/sbin/grub-install /dev/hda
reboot
will bring you back jdsboot grub menu erased by windows installation CD/DVD.
Note: you may want to check using fdisk -l. if you see any partition
number changes, you may need to edit (remember i remind your favorite
editor earlier?) some files.
Now you will boot to slp and start windows recovery.
Run the following in a sery to recover:
code: su
mount -t captive-ntfs /dev/hda1 /windows/c
mount /dev/sda2 /oss
cd /windows/c
rm -rf /windows/c/*
# (a few files may be copied already from windows installation CD/DVD)
tar zxf /oss/winxp.tar.gz . 2>/dev/null
# speedup the process by not displaying file setting errors, for example, owner/group info
# note: when pagefile.sys is not recovered, you may manually create a 20M or so file in /windows/c. Copy any file will work
cd ..
umount /windows/c
umount /oss
exit
configurations!!! you just recovered your windows system with all your programs, files, and settings.
Now you back to windows and might note something different. For
example, your recycle bin corrupts – who cares and windows will create
it for you again (so for pagefile.sys as well).
The whole backup and recovery process takes less than 2 hours. Recovery
itself takes 1 hour or so. (Does this have something to do with
lufs-sandbox? but it's off by default)
I guess use floppy to format ntfs will be a bit simpler. Not tried yet.
Since it says in some forum that ntfs version varies from windows XP to
sp1 to sp2, definitely from 2000 to 2003, and someone says that captive
doesn't support windows XP SP2 yet (which doesn't affect me somehow),
you are on your own risk!
This document is created using staroffice 7.0 update 4 in jds. |
| Discuss this article
|
|
| All times are GMT -7 hours. The time now is 08:02 PM. |
|
|
|