备份系统分区表

我正在备份Linux Ubuntu 10.04 LTS的分区表。

其实我正在用虚拟机(VirtualBox)进行testing。 我在虚拟磁盘中有一个源系统,另一个虚拟机作为救援系统,另一个虚拟磁盘的大小与源系统磁盘完全相同。

所以,运行救援系统我挂载源系统磁盘和用户这个命令做分区表备份:

sfdisk /dev/sdb –d > /backup/sdb-part-table.sf 

这个输出消息生成并保存文件:

 Warning: extended partition does not start at a cylinder boundary. DOS and Linux will interpret the contents differently. 

一旦我有分区表文件,我卸载源磁盘并挂载备份空磁盘。

我尝试使用这个命令:

 sfdisk /dev/sdb < /backup/sdb-part-table.sf 

然后我再次尝试恢复parition表,但给我这个错误:

 Checking that no-one is using this disk right now ... OK Disk /dev/sdc: 265 cylinders, 255 heads, 63 sectors/track Warning: extended partition does not start at a cylinder boundary. DOS and Linux will interpret the contents differently. Old situation: Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0 Device Boot Start End #cyls #blocks Id System /dev/sdc1 * 0+ 245- 246- 1973248 83 Linux /dev/sdc2 245+ 265- 20- 155649 5 Extended /dev/sdc3 0 - 0 0 0 Empty /dev/sdc4 0 - 0 0 0 Empty /dev/sdc5 245+ 265- 20- 155648 82 Linux swap / Solaris New situation: Units = sectors of 512 bytes, counting from 0 Device Boot Start End #sectors Id System /dev/sdc1 * 2048 3948543 3946496 83 Linux /dev/sdc2 3950590 4261887 311298 5 Extended /dev/sdc3 0 - 0 0 Empty /dev/sdc4 0 - 0 0 Empty /dev/sdc5 3950592 4261887 311296 82 Linux swap / Solaris Warning: partition 1 does not end at a cylinder boundary sfdisk: I don't like these partitions - nothing changed. (If you really want this, use the --force option.) 

所以最后我用武力来恢复和似乎工作:

 sfdisk --force /dev/sdb < /backup/sdb-part-table.sf 

得到这个结果:

 Checking that no-one is using this disk right now ... OK Disk /dev/sdc: 265 cylinders, 255 heads, 63 sectors/track Warning: extended partition does not start at a cylinder boundary. DOS and Linux will interpret the contents differently. Old situation: Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0 Device Boot Start End #cyls #blocks Id System /dev/sdc1 * 0+ 245- 246- 1973248 83 Linux /dev/sdc2 245+ 265- 20- 155649 5 Extended /dev/sdc3 0 - 0 0 0 Empty /dev/sdc4 0 - 0 0 0 Empty /dev/sdc5 245+ 265- 20- 155648 82 Linux swap / Solaris New situation: Units = sectors of 512 bytes, counting from 0 Device Boot Start End #sectors Id System /dev/sdc1 * 2048 3948543 3946496 83 Linux /dev/sdc2 3950590 4261887 311298 5 Extended /dev/sdc3 0 - 0 0 Empty /dev/sdc4 0 - 0 0 Empty /dev/sdc5 3950592 4261887 311296 82 Linux swap / Solaris Warning: partition 1 does not end at a cylinder boundary Successfully wrote the new partition table Re-reading the partition table ... If you created or changed a DOS partition, /dev/foo7, say, then use dd(1) to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1 (See fdisk(8).) 

但是,当我将备份移动到新的文件系统似乎是好的,系统不启动,我有一个黑屏,好像没有在备份机中安装的操作系统,在工作来源的分区表的比较是相等的磁盘和备份非工作磁盘中。

Mbr备份已经完成并安装。 我试过在分区表恢复之前和之后安装。

那么,我怎样才能使它工作?

在此先感谢,并有一个愉快的一周:D

你尝试了一个更低层次的方法吗? 例如,使用dd if=/dev/sdc of=mbr.sav bs=512 count=1 ,这将会完全符合您的期望,也就是说将您的硬盘的前512字节备份到mbr.sav ? 要恢复备份,请反转参数值。

以前的答案其实非常接近; 您只备份了分区表。 分区表是第一部分的一部分。 第一部分的另一件事是引导程序。

但是,如果您完全复制第一个扇区,而不完全复制第一个扇区,则可以轻松地获得第一个扇区中的代码跳转到没有所需文件的地址的情况。 在这种情况下,启动一些相关的媒体,并重新安装引导程序(我认为Ubuntu甚至在他们的媒体上有一个帮手)。