測試系統: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] 等命令參數,請自行通過幫助命令?,來了解。