测试系统: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 -lModel: ATA ST330621A (scsi)Disk /dev/sda: 30.0GBSector size (logical/physical): 512B/512BPartition Table: gptDisk Flags: Number  Start   End     Size    File system     Name  Flags1      17.4kB  1000MB  1000MB  ext2                  boot2      1000MB  3000MB  2000MB  linux-swap(v1)3      3000MB  8000MB  5000MB  ext34      8000MB  30.0GB  22.0GB  ext3Model: Generic Flash Disk (scsi)Disk /dev/sdb: 8020MBSector size (logical/physical): 512B/512BPartition Table: msdosDisk Flags: Number  Start  End     Size    Type     File system  Flags1      512B   8020MB  8020MB  primary  fat32        boot, lba查看当前U盘目录及使用情况:df -hFilesystem	Size	Used	Avall	Use%	Mounted onrootfs		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/squashfstmpfs		498M	800K	497M	1%	/livemnt/memorynone		498M	800K	497M	1%	/tmpfs		512M	16K	512M	1%	/livemnt/tftpmemnone		512M	16K	512M	1%	/tftpboottmpfs		498M	636K	497M	1%	/runudev		10M	0	10M	0%	/devshm		498M	0	498M	0%	/dev/shmcgroup_root	10M	0	10M	0%	/sys/fs/cgrouptmpfs		498M	0	498M	0%	/tmp5、 挂载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 informationsSpave usage:........................8%Used space:.........................2.17 GiBFree space:.........................23.00 GiBBitmap size:........................3.15 MiBLabel:..............................Number of groups:...................202First block:........................0Ext3fs journalization:..............yesSparse super block:.................yesLarge files support:................yesFile 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:SuccessOperation successfully finished:Time elapased: 5m:53secSpeed: 376.9 MiB/minData copied: 2.17 GiB
7、导出分区表:[1] MBR类型# sfdisk -d /dev/sda > /mnt/floppy/ncweb.fdisk[2] GPT等类型# gdiskGPT fdisk (gdisk) version 0.8.8Type device filename, or press <Enter> to exit: /dev/sdaPartition table scan:MBR: MBR onlyBSD: not presentAPM: not presentGPT: not present*****************************************************************Found invalid GPT and valid MBR; converting MBR to GPT formatin memory. THIS OPERATION IS POENTIALLY DESTRUCTIVE! Exit bytyping 'q'  if you don't want to convert your MBR partitionsto GPT format!*****************************************************************Command (? for help): [3]输入备份命令:bCommand (? for help): bEnter backup filename to save:[4]输入要备份的区域://livemnt/boot/ncwww_img/ncwww.fdiskEnter backup filename to save: /livemnt/boot/ncwww_img/ncwww.fdiskThe operation has completed successfully.[5]退出:q恢复系统
1、导入分区表[1] MBR类型:# sfdisk /dev/sda < /mnt/floppy/ncweb.fdisk[2] GPT等类型#gdiskGPT fdisk (gdisk) version 0.8.8Type device filename, or press <Enter> to exit: /dev/sdaPartition table scan:MBR: MBR onlyBSD: not presentAPM: not presentGPT: not present*****************************************************************Found invalid GPT and valid MBR; converting MBR to GPT formatin memory. THIS OPERATION IS POENTIALLY DESTRUCTIVE! Exit bytyping 'q'  if you don't want to convert your MBR partitionsto GPT format!*****************************************************************Command (? for help): [3] 输入恢复命令:rCommand (? for help): rRecovery/transformation command (? for help):[4] 输入子命令:lRecovery/transformation command (? for help): lEnter backup filename to load:[5] 输入要恢复的文件名:/livemnt/boot/ncwww_img/ncwww.fdiskEnter backup filename to load: /livemnt/boot/ncwww_img/ncwww.fdiskRecovery/transformation command (? for help):[6] 输入写入的子命令:wRecovery/transformation command (? for help): wFinal checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTINGPARTITIONS!![7] 输入Y,确认进行恢复:Do you want to proceed? (Y/N): YOK; 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盘。gdisk其它功能,如创建分区[n],删除分区[d],改写分区类型[t] 等命令参数,请自行通过帮助命令?,来了解。