首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用sfdisk的近似分区表备份

使用sfdisk的近似分区表备份
EN

Unix & Linux用户
提问于 2014-10-19 22:18:30
回答 1查看 779关注 0票数 5

我想将一些逻辑分区转换为扩展分区,所以我遵循了这个被接受的答案。但是,在备份当前分区表的步骤中,我错误地输入了下面的内容,而不是编写的内容。

代码语言:javascript
复制
sfdisk -f /dev/sda > /mnt/parts.txt

其结果是:

代码语言:javascript
复制
Disk /dev/sda: 30401 cylinders, 255 heads, 63 sectors/track
Old situation:
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/sda1          0+    304-    304-   2441214+  82  Linux swap / Solaris
/dev/sda2   *    304+    565-    262-   2097152   83  Linux
/dev/sda3        565+   4486-   3921-  31495168   83  Linux
/dev/sda4       4486+  30401-  25916- 208163840    5  Extended
/dev/sda5       4486+  24026-  19540- 156954624   83  Linux

正如你所看到的,单位是圆柱体和块,这可能造成精度的损失,与正确的出口与部门。

问题是,我已经破坏了我的分区表,现在我必须利用这个不完整的(或者它是吗?)后援。

到目前为止,我已经尝试使用扇区作为一个单元重写分区表(柱面不会导致任何地方),知道一个块是两个扇区(我不知道它是否是通用的,但是导出扇区中的分区表告诉您,一个扇区= 512字节,以及一个块= 1024字节.)。

代码语言:javascript
复制
root@debian:/home/user# sfdisk -u S /dev/sda
Checking that no-one is using this disk right now ...
OK

Disk /dev/sda: 30401 cylinders, 255 heads, 63 sectors/track
Old situation:
Units = sectors of 512 bytes, counting from 0

   Device Boot    Start       End   #sectors  Id  System
/dev/sda1             1   4882429    4882429  82  Linux swap / Solaris
/dev/sda2       4882430   9076733    4194304  83  Linux
/dev/sda3       9076734  72067069   62990336  83  Linux
/dev/sda4      72067070 488394749  416327680  83  Linux
Input in the following format; absent fields get a default value.
<start> <size> <type [E,S,L,X,hex]> <bootable [-,*]> <c,h,s> <c,h,s>
Usually you only need to specify <start> and <size> (and perhaps <type>).

/dev/sda1 :1 4882429 S
/dev/sda1             1   4882429    4882429  82  Linux swap / Solaris
/dev/sda2 :4882430 4194304 L *
/dev/sda2   *   4882430   9076733    4194304  83  Linux
/dev/sda3 :9076734 62990336
/dev/sda3       9076734  72067069   62990336  83  Linux
/dev/sda4 :72067070 416327680 E
/dev/sda4      72067070 488394749  416327680   5  Extended
/dev/sda5 :72067071 313909248
/dev/sda5      72067071 385976318  313909248  83  Linux
/dev/sda6 :
/dev/sda6     385976320 488394749  102418430  83  Linux
/dev/sda7 :
No room for more
New situation:
Units = sectors of 512 bytes, counting from 0

   Device Boot    Start       End   #sectors  Id  System
/dev/sda1             1   4882429    4882429  82  Linux swap / Solaris
/dev/sda2   *   4882430   9076733    4194304  83  Linux
/dev/sda3       9076734  72067069   62990336  83  Linux
/dev/sda4      72067070 488394749  416327680   5  Extended
/dev/sda5      72067071 385976318  313909248  83  Linux
/dev/sda6     385976320 488394749  102418430  83  Linux
Warning: partition 1 does not end at a cylinder boundary
Warning: partition 2 does not start at a cylinder boundary
Warning: partition 2 does not end at a cylinder boundary
Warning: partition 3 does not start at a cylinder boundary
Warning: partition 3 does not end at a cylinder boundary
Warning: partition 4 does not start at a cylinder boundary
Warning: partition 4 does not end at a cylinder boundary
Warning: partition 5 does not end at a cylinder boundary
Warning: partition [6] does not start at a cylinder boundary
Warning: partition [6] does not end at a cylinder boundary
Warning: partition 6 does not end at a cylinder boundary
Do you want to write this to disk? [ynq] y
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).)

它写着:在圆柱体边界上没有分区开始/停止。我不知道这是什么意思,但由于有+和-,这意味着数字已经四舍五入,在原始导出,我认为这是正常的。

我还发出了同样的错误命令,查看输出是否相同:

代码语言:javascript
复制
Disk /dev/sda: 30401 cylinders, 255 heads, 63 sectors/track
Old situation:
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/sda1          0+    303-    304-   2441214+  82  Linux swap / Solaris
/dev/sda2   *    303+    565-    262-   2097152   83  Linux
/dev/sda3        565+   4485-   3921-  31495168   83  Linux
/dev/sda4       4485+  30401-  25916- 208163840    5  Extended
/dev/sda5       4485+  24025-  19540- 156954624   83  Linux
/dev/sda6      24025+  30401-   6376-  51209215   83  Linux

很近,但不完全一样。此外,G以来似乎不识别任何分区文件系统(一切都是“未知的”)。

另外,/dev/sda1 1如何能大到304缸,但以303缸结尾呢?

我想我已经接近解决方案了,但我无法得到所需的确切数字,可能是因为我计算错了什么,或者我做错了。但是,我不能一个一个地改变它们,看哪种组合可以工作(我可以,但这需要一些bash编码和处理时间,我不知道哪里出了问题)。

我最近备份了这个磁盘中最重要的一个,但是如果我可以在不重新安装和复制文件的情况下修复它,那就太好了。

EN

回答 1

Unix & Linux用户

回答已采纳

发布于 2014-10-20 06:04:36

这将是一个棘手的手工修复。我希望你没有修改这个磁盘上的任何数据,除了你写的坏了的分区表。

使用sfdisk、fdisk等来创建分区表的备份是一个好主意(当您没有意外地键入错误的命令:)。但对于额外的保险,我喜欢备份我的驱动器的引导扇区使用dd。

您确定sda1是从第1块开始的,还是猜测?过去,在磁盘开始时只使用一个块是很常见的,因为这是保存MBR和(主)分区表所需的全部,但是近年来,分区软件通常会保留更多的空间,例如,第一个分区的起始扇区为63,这并不罕见。我还见过分区软件(gparted,IIRC)在驱动器开始时保留一个兆字节,然后强制所有后续分区到兆字节边界。

在较旧的系统中,分区在圆柱边界上开始和停止是很重要的。IOW,磁盘开头的未分区区域应该是一个完整的圆柱,每个后续的主分区也应该是这样;通常在磁盘的末尾也会有未分配的空间。但多年来,这通常不是一个问题,但很多分区软件仍然提到它,以防万一你感兴趣。:)

但是,分区必须在扇区边界上开始和停止。这使得对第一个清单中面向块的数据的分析变得容易得多。因此,2441214+块只能引用2441214.5块= 4882429扇区= 2499803648字节。

但是,您应该认真考虑使用像测试盘这样的工具,而不是试图手工解决这个问题。您甚至可能已经安装在您的发行版,如果没有,它应该在您的回复。

票数 4
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/163045

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档