一.源機器分區(qū)情況:
hda1 為:boot(啟動分區(qū))
hda2 為:swap(交換分區(qū))
hda3 為:boot (根 / 分區(qū))
hda4 為:data (數(shù)據(jù)盤)
#fdisk -l /dev/hda
Disk /dev/hda: 11.8 GB, 11811160064 bytes
15 heads, 63 sectors/track, 24411 cylinders
Units = cylinders of 945 * 512 = 483840 bytes
Disk identifier: 0x0eb4a58f
Device Boot Start End Blocks Id System
/dev/hda1 * 1 621 293391 83 Linux
/dev/hda2 622 1680 500377+ 82 Linux swap / Solaris
/dev/hda3 1681 10147 4000657+ 83 Linux
/dev/hda4 10148 24411 6739740 83 Linux
#cat /etc/fstab
/dev/hda1 /boot ext2 noauto,noatime 1 2
/dev/hda3 / ext3 noatime 0 1
/dev/hda2 none swap sw 0 0
/dev/hda4 /data ext3 noatime 0 1
備份源機器分區(qū):
1.備份啟動分區(qū)(boot)到數(shù)據(jù)盤
dd if=/dev/hda1 | gzip >/data/hda1.gz
2.備份根分區(qū)(/) 到數(shù)據(jù)盤
dd if=/dev/hda3 | gzip >/data/hda3.gz
二,目標機器:
1.使用啟動盤啟動系統(tǒng)
2.分區(qū):把 boot swap / 這3個分區(qū)分成跟源機器一樣的大小。
還有分出一個數(shù)據(jù)盤來存放 源機器備份下來的文件。
#mke2fs /dev/hda1
#mke2fs -j /dev/hda3
#mke2fs -j /dev/hda4
#mkswap /dev/hda2 && swapon /dev/hda2
#mkdir /data
#mount /dev/hda4 /data
#cat /etc/fstab
/dev/hda1 /boot ext2 noauto,noatime 1 2
/dev/hda3 / ext3 noatime 0 1
/dev/hda2 none swap sw 0 0
/dev/hda4 /data ext3 noatime 0 1
3.把源機器的備份文件拉到數(shù)據(jù)盤
#scp root@192.168.230.132:/data/hda1.gz /data/
#scp root@192.168.230.132:/data/hda3.gz /data/
4.恢復系統(tǒng):
#gzip -dc /data/hda1.gz | dd of /dev/hda1
#gzip -dc /data/hda3.gz | dd of /dev/hda3
5.grub 使用 dd 恢復系統(tǒng)會造成錯誤,不能啟動,所以必須重新配置一下grub
#mount /dev/hda3 /mnt/gentoo
#mount /dev/hda1 /mnt/gentoo/boot
#mount -t proc proc /mnt/gentoo/proc
#mount -o bind /dev /mnt/gentoo/dev
#chroot /mnt/gentoo /bin/bash
#env-update && source /etc/profile
>>> Regenerating /etc/ld.so.cache...
# grub
Probing devices to guess BIOS drives. This may take a long time.
grub> root (hd0,0)
Filesystem type is ext2fs, partition type 0xfd
grub> setup (hd0)
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/e2fs_stage1_5" exists... yes
Running "embed /boot/grub/e2fs_stage1_5 (hd0)"... 16 sectors are embedded.
succeeded
Running "install /boot/grub/stage1 (hd0) (hd0)1+16 p (hd0,0)/boot/grub/stage2 /boot/
grub/menu.lst"... succeeded
Done.
grub> quit
到此為止,系統(tǒng)已經(jīng)完全恢復好,重新啟動系統(tǒng)。
6.(注意)dd 恢復系統(tǒng)也會造成網(wǎng)卡不能啟動:
啟動網(wǎng)卡錯誤表現(xiàn):
#/etc/init.d/net.eth0 start
*Starting eth0
* Bringing up eth0
* dhcp
* network interface eth0 does not exist
* Please verify hardware or kernel module (driver)
查看 /var/log/kennel/Current 日志發(fā)現(xiàn)
Mar 21 12:40:04 [kernel] pcnet32.c:v1.35 21.Apr.2008 tsbogend@alpha.franken.de
Mar 21 12:40:04 [kernel] pcnet32 0000:02:00.0: PCI INT A -> GSI 18 (level, low) -> IRQ 18
Mar 21 12:40:04 [kernel] pcnet32: PCnet/PCI II 79C970A at 0x2000, 00:0c:29:94:de:df assigned IRQ 18.
Mar 21 12:40:04 [kernel] eth0: registered as PCnet/PCI II 79C970A
Mar 21 12:40:04 [kernel] pcnet32: 1 cards_found.
Mar 21 12:40:04 [kernel] Floppy drive(s): fd0 is 1.44M
Mar 21 12:40:04 [kernel] FDC 0 is a post-1991 82077
Mar 21 12:40:04 [kernel] udev: renamed network interface eth0 to eth1
interface eth0 to eth1 這里有個改名的日志(因為:系統(tǒng)從源電腦備份來的,網(wǎng)卡的mac 記錄的是源電腦網(wǎng)卡的mac,跟目標電腦的網(wǎng)卡的mac不匹配,系統(tǒng)會自動識別網(wǎng)卡的mac,并在/etc/udev/rules.d/70-persistent-net.rules 文件中產(chǎn)生一條正確的記錄)
A:解決方法一
ls /etc/init.d/
lrwxrwxrwx 1 root root 6 Mar 18 21:54 net.eth0 -> net.lo
-rwxr-xr-x 1 root root 30696 Apr 26 2008 net.lo
并沒有 net.eth1 啟動文件
#cd /etc/init.d/
#ln -s net.lo net.eth1
重新啟動網(wǎng)卡
#/etc/init.d/net.eth1 start (ok)
B: 解決方法二
編輯:/etc/udev/rules.d/70-persistent-net.rules
查出ATTR{address} 跟源電腦網(wǎng)卡mac一樣的 注掉,重新啟動電腦,網(wǎng)卡就可以使用了。
# This file was automatically generated by the /lib/udev/write_net_rules
# program run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single line.
# PCI device 0x1022:0x2000 (pcnet32)
#查出ATTR{address} 跟源電腦網(wǎng)卡mac一樣的 注掉
#SUBSYSTEM=="net", DRIVERS=="?*", ATTR{address}=="00:0c:29:95:53:ca", NAME="eth1"
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", DRIVERS=="?*", ATTR{address}=="00:0c:29:94:de:df", NAME="eth0"
注:查看網(wǎng)卡的mac 可以簡單的使用啟動盤,啟動系統(tǒng)查看。
聯(lián)系客服