测试系统:linux-debian
备份系统
1、插入dd有systemrescuecd-x86-4.0.1.iso的系统备份恢复U盘;
2、开机按DEL进入BIOS,设置BOOT为USB-HDD启动。Save&Exit;
3、进入备份恢复系统界面:
--------------------------------------------------------------------
| SYSTEM-RESCUE-CD 4.0.4 (www.sysresccd.org)
--------------------------------------------------------------------
| 1) SystemRescueCd: default boot opetions
| 2) SystemRescueCd: all files cached to memory (docache)
| 3) SystemRescueCd: framebuffer console in high resolution
| 4) SystemRescueCd: do not ask for keyboard, use US keymap
| 5) Boot an exising Linux system installed on the disk
| 6) SystemRescueCd: alternative kernel with default boot option
| 7) SystemRescueCd: directly start the graphical environment
|
| A) Run system tools from floppy disk image... >
| B) Standard 32bit kernel (rescue32) with more choice... >
| C) Standard 64bit kernel (rescue64) with more choice... >
| D) Alternative 32bit kernel (altker32) with more choice... >
| E) Alternative 64bit kernel (altker64) with more choice... >
|
| *) Boot from first hard disk
| *) Boot from second hard disk
--------------------------------------------------------------------
选择1),回车。 (大概等待10分钟,视服务器而定)
4、查看系统分区:fdisk -l
Model: ATA ST330621A (scsi)
Disk /dev/sda: 30.0GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 17.4kB 1000MB 1000MB ext2 boot
2 1000MB 3000MB 2000MB linux-swap(v1)
3 3000MB 8000MB 5000MB ext3
4 8000MB 30.0GB 22.0GB ext3
Model: Generic Flash Disk (scsi)
Disk /dev/sdb: 8020MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 512B 8020MB 8020MB primary fat32 boot, lba
查看当前U盘目录及使用情况:df -h
Filesystem Size Used Avall Use% Mounted on
rootfs 498M 800K 497M 1% /
udev 10M 0 10M 0% /dev
/dev/sdb1 7.5G 2.7G 4.9G 36% /livemnt/boot
/dev/loop0 339M 339M 0 100% /livemnt/squashfs
tmpfs 498M 800K 497M 1% /livemnt/memory
none 498M 800K 497M 1% /
tmpfs 512M 16K 512M 1% /livemnt/tftpmem
none 512M 16K 512M 1% /tftpboot
tmpfs 498M 636K 497M 1% /run
udev 10M 0 10M 0% /dev
shm 498M 0 498M 0% /dev/shm
cgroup_root 10M 0 10M 0% /sys/fs/cgroup
tmpfs 498M 0 498M 0% /tmp
5、 挂载U盘分区:
mount /dev/sdb2 /mnt/floppy
或直接在U盘目录中赋予一个目录读写权限:
mount -o remount,rw /livemnt/boot/
6、 创建镜像:partimage
进入备份恢复界面:
----------------------------------------------------------------------
| Partition Image 0.6.9
|--------------------------------------------------------------------
| * Partition to save?restore
| sda1 ext2fs 953.00 MiB
| sda2 swap (v1) 1.86 GiB
| sda3 ext3fs 5.00 GiB
| sda5 ext3fs 25.16 GiB
| sdb1 fat32 7.47 GiB
|
|--------------------------------------------------------------------
| * Image file to create/use
| ___________________________________________________________ <*>
|--------------------------------------------------------------------
| Action to be done: <Next (F5)>
| (*) Save partition into a new image file
| ( ) Restore partition from an image file <About>
| ( ) Restore an MBR from the image file
| <Exit (F6)>
| [ ] Connect to server
| IP/name of the server: ________________________ Port: 4025__
| [X] Encrypt data on the network with SSL
---------------------------------------------------------------------
[1] 选择要备份的区域:
sda1 ext2fs 953.00 MiB
[2] 填写要存储的备份文件名:
/livemnt/boot/ncweb_img/ncweb_sda1_boot.img <*>
[3] 选择备份新镜像:
(*) Save partition into a new image file
[4] 按F5进入下一步:
-------------------------------------------------------------------------
| save partition to image file
|-----------------------------------------------------------------------
| Compression level
| ( ) None (very fast + very big file)
| (*) Gzip (.gz: medium speed + small image file)
| ( ) Bzip2 (.bz2: very slow + very smaill image file)
|
| Options If finished successfully:
| [X] Check partition before saving (*) Wait
| [X] Enter description ( ) Halt
| [ ] Overwrite without prompt ( ) Reboot
| ( ) Quit
| Image splut mode ( ) Last
| ( ) Automatic split (when no space left)
| (*) Into files whose size is:........... 2037____MiB
| [ ] Wait after each volume change
|
| <Contine (F5)> <Exit (F6)> <Main window (F7)>
-------------------------------------------------------------------------
[5] 描述镜像文件:
-------------------------------------------------------------------------
| Parition description
|-----------------------------------------------------------------------
| You can enter a description of the saved partition:
| ________________________________________________________________
|
| ------
| | OK |
| ------
-------------------------------------------------------------------------
如填写:ncweb sda1 boot 2.0GB image
[6] 提示当前分区信息,点击OK:
Ext3fs informations
Spave usage:........................8%
Used space:.........................2.17 GiB
Free space:.........................23.00 GiB
Bitmap size:........................3.15 MiB
Label:..............................
Number of groups:...................202
First block:........................0
Ext3fs journalization:..............yes
Sparse super block:.................yes
Large files support:................yes
File system revision:...............1
[7] 生成镜像:
---------------------------------------------------------------------------------
| save partition to image file
|-------------------------------------------------------------------------------
| Partition to save:.........../dev/sda5
| Size of the Partition:.......25.16 GiB = 27018657792 bytes
| Current image file:........../livemnt/boot/ncweb_img/ncweb_sda1_boot.img000
| Image file size:.............238.13 MiB
| Available space for image:...4.45 GiB = 4721212313 bytes
| Detected file system:........ext3fs
| Compression level:...........gzip
|
| Time elapsed:................3m:45sec
| Estimated time remaining:....1m:23sec
| Speed:.......................388.32 MiB/min
| Data copied:.................1.75 GiB / 2.17 GiB
|
| _____________________________8%___________________________________
---------------------------------------------------------------------------------
[8] 完成,点击OK:
Success
Operation successfully finished:
Time elapased: 5m:53sec
Speed: 376.9 MiB/min
Data copied: 2.17 GiB
7、导出分区表:
[1] MBR类型
# sfdisk -d /dev/sda > /mnt/floppy/ncweb.fdisk
[2] GPT等类型
# gdisk
GPT fdisk (gdisk) version 0.8.8
Type device filename, or press <Enter> to exit: /dev/sda
Partition table scan:
MBR: MBR only
BSD: not present
APM: not present
GPT: not present
*****************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. THIS OPERATION IS POENTIALLY DESTRUCTIVE! Exit by
typing 'q' if you don't want to convert your MBR partitions
to GPT format!
*****************************************************************
Command (? for help):
[3]输入备份命令:b
Command (? for help): b
Enter backup filename to save:
[4]输入要备份的区域://livemnt/boot/ncwww_img/ncwww.fdisk
Enter backup filename to save: /livemnt/boot/ncwww_img/ncwww.fdisk
The operation has completed successfully.
[5]退出:q
恢复系统
1、导入分区表
[1] MBR类型:
# sfdisk /dev/sda < /mnt/floppy/ncweb.fdisk
[2] GPT等类型
#gdisk
GPT fdisk (gdisk) version 0.8.8
Type device filename, or press <Enter> to exit: /dev/sda
Partition table scan:
MBR: MBR only
BSD: not present
APM: not present
GPT: not present
*****************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. THIS OPERATION IS POENTIALLY DESTRUCTIVE! Exit by
typing 'q' if you don't want to convert your MBR partitions
to GPT format!
*****************************************************************
Command (? for help):
[3] 输入恢复命令:r
Command (? for help): r
Recovery/transformation command (? for help):
[4] 输入子命令:l
Recovery/transformation command (? for help): l
Enter backup filename to load:
[5] 输入要恢复的文件名:/livemnt/boot/ncwww_img/ncwww.fdisk
Enter backup filename to load: /livemnt/boot/ncwww_img/ncwww.fdisk
Recovery/transformation command (? for help):
[6] 输入写入的子命令:w
Recovery/transformation command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
[7] 输入Y,确认进行恢复:
Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/sda.
The operation has completed suceesfully.
2、恢复分区: partimage
进入备份恢复界面:
----------------------------------------------------------------------
| Partition Image 0.6.9
|--------------------------------------------------------------------
| * Partition to save?restore
| sda1 ext2fs 953.00 MiB
| sda2 swap (v1) 1.86 GiB
| sda3 ext3fs 5.00 GiB
| sda5 ext3fs 25.16 GiB
| sdb1 fat32 7.47 GiB
|
|--------------------------------------------------------------------
| * Image file to create/use
| ___________________________________________________________ <*>
|--------------------------------------------------------------------
| Action to be done: <Next (F5)>
| ( ) Save partition into a new image file
| (*) Restore partition from an image file <About>
| ( ) Restore an MBR from the image file
| <Exit (F6)>
| [ ] Connect to server
| IP/name of the server: ________________________ Port: 4025__
| [X] Encrypt data on the network with SSL
----------------------------------------------------------------------
[1] 选择要恢复的区域:
sda1 ext2fs 953.00 MiB
[2] 填写要恢复用的镜像文件名:
/livemnt/boot/ncweb_img/ncweb_sda1_boot.img <*>
[3] 选择用镜像恢复:
(*) Restore partition from an image file
[4] 按F5,进入下一步,直接点击OK。
3、安装GRUB:
确认存在分区表和分区内容后,REBOOT,重启。
--------------------------------------------------------------------
| SYSTEM-RESCUE-CD 4.0.4 (www.sysresccd.org)
--------------------------------------------------------------------
| 1) SystemRescueCd: default boot opetions
| 2) SystemRescueCd: all files cached to memory (docache)
| 3) SystemRescueCd: framebuffer console in high resolution
| 4) SystemRescueCd: do not ask for keyboard, use US keymap
| 5) Boot an exising Linux system installed on the disk
| 6) SystemRescueCd: alternative kernel with default boot option
| 7) SystemRescueCd: directly start the graphical environment
|
| A) Run system tools from floppy disk image... >
| B) Standard 32bit kernel (rescue32) with more choice... >
| C) Standard 64bit kernel (rescue64) with more choice... >
| D) Alternative 32bit kernel (altker32) with more choice... >
| E) Alternative 64bit kernel (altker64) with more choice... >
|
| *) Boot from first hard disk
| *) Boot from second hard disk
--------------------------------------------------------------------
选择5),回车。 (大概等待10分钟,视服务器而定)
进入系统后,root登录终端:
# grub-install /dev/sda
若提示error,按提示添加运行参数:
# grub-install /dev/sda --force
完成后,reboot。拔出U盘。