用 FastBack 实现 Linux 裸机恢复(3)
- UID
- 1066743
|
用 FastBack 实现 Linux 裸机恢复(3)
在裸机恢复的 Linux 机器上配置信息通过以上步骤对 FastBack 服务器完成配置之后,我们需要在裸机恢复的 Linux 的机器上做相关的系统信息配置。
1. 停止 iSCSI TARGET 服务。此时所有数据被强制写入硬盘。
SUSE Linux:
1
| # /etc/init.d/iscsitarget stop
|
Fedora:
1
2
3
| # tgtadm --lld iscsi --op delete --mode logicalunit --tid 1 --lun 1
# tgtadm --lld iscsi --op delete --mode target --tid=1
# service tgtd stop
|
2. 执行 partprobe 命令让 kernel 重新读取分区表。
注意:执行这个命令时可能会出现“An Invalid partition table error”的错误信息,这是 因为机器里存在未还原的分区,属于正常情况。
3. 确保所需要的分区都被还原了。
1
2
3
4
5
6
7
8
9
| # fdisk -l /dev/sda
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00018613
Device Boot Start End Blocks Id System
/dev/sda1 1 13 104391 83 Linux
/dev/sda2 14 3661 29302560 83 Linux
|
4. 还原 Grub bootloader 以确保系统可以正常启动。
1
2
3
4
5
6
7
8
9
10
11
| # grub
grub> find /boot/grub/stage1
(or find /grub/stage1 if you get Error 15: File not found)
(hd0,0) #Grub is already installed on the first partition of first disk
grub> root (hd0,0) #Tell grub where / (root partition) can be found
grub> setup (hd0) #Tell grub where to install the bootload (will overwrite the MBR)
grub> quit
|
如果是 SUSE Linux 机器,需要以下步骤才能找到 Stage1
1
2
3
4
5
| # mount /dev/sda1 /boot
# cd /boot
# grub
grub> find /grub/stage1 (hd0, 0)
#grub is already installed on the first partition of the disk
|
如果/boot 引导区或者/ 根目录被还原到不同的硬盘上,menu.lst 文件需要更新。
- Fedora:menu.lst 文件在/mnt/grub/ 下。
- SUSE Linux:menu.lst 文件在/mnt/boot/grub/下。
为了编辑 menu.lst,我们应当把还原的分区先加载上:
编辑该文件中所有相关的部分:
1
2
3
4
| root (hd0,0)
kernel /boot/vmlinuz-2.6.16.60-0.42.5-default root=/dev/sda2 vga=0x314
load_ramdisk=1 init=linuxrc resume=/dev/sda2 splash=silent showopts
initrd /boot/initrd-2.6.16.60-0.42.5-default
|
卸载该分区:
5. 重建 Swap 分区:
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
31
32
33
34
| # fdisk /dev/sda
Command (m for help): n #Tell fdisk to create a new partition
Command action
l logical (5 or over)
p primary partition (1-4)
p
Partition Number (1-4): 3
First cylinder (3662-3916, default 3662): Enter
Using default value 3662
Last cylinder, +cylinders or +size{K,M,G} (3662-3916, default 3916): +2048M
Command (m for help): t # change partition type
Partition number (1-6): 3 # select partition we want to change
Hex code (type L to list codes): 82 # 82 stand for swap
Changed system type of partition 2 to 82 (Linux swap / Solaris)
Command (m for help): p # print partition table
[…]
Device Start End Blocks Id System
/dev/sda1 1 13 104391 83 Linux
/dev/sda2 14 3661 29302560 83 Linux
/dev/sda3 3662 3916 2048287+ 82 Linux swap / Solaris
Partition table entries are not in disk order
Command (m for help): w # save the changes
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
|
运行以下命令初始 Swap 分区
6. 加载还原好的 Root 分区,编辑 Swap 的配置信息以使它能开机加载。
1
2
3
| # mount /dev/sda2 /mnt
# vi /mnt/etc/fstab
/dev/sda3 none swap sw 0 0
|
7. 取出 CD 并重启 LINUX 机器
|
|
|
|
|
|