当前位置: 首页>>技术教程>>正文


分区不是从物理扇区边界开始的?

, , , ,

问题描述

我的笔记本电脑上有一个HD,有两个分区(一个安装了Ubuntu 12.04的ext3和一个交换)。

fdisk给我一个分区1没有开始物理扇区边界警告。原因是什么,我需要解决它吗?如果是这样,怎么样?


这是sudo fdisk -l

Disk /dev/sda: 750.2 GB, 750156374016 bytes
255 testine, 63 settori/tracce, 91201 cilindri, totale 1465149168 settori
Unità = settori di 1 * 512 = 512 byte
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Identificativo disco: 0x5a25087f

Dispositivo Boot      Start         End      Blocks   Id  System
/dev/sda1   *          63  1448577023   724288480+  83  Linux
Partition 1 does not start on physical sector boundary.
/dev/sda2      1448577024  1465147391     8285184   82  Linux swap / Solaris

这是sudo lshw的相关结果:

 *-disk
                description: ATA Disk
                product: WDC WD7500BPKT-0
                vendor: Western Digital
                physical id: 0
                bus info: scsi@0:0.0.0
                logical name: /dev/sda
                version: 01.0
                serial: WD-WX21CC1T0847
                size: 698GiB (750GB)
                capabilities: partitioned partitioned:dos
                configuration: ansiversion=5 signature=5a25087f
              *-volume:0
                   description: EXT3 volume
                   vendor: Linux
                   physical id: 1
                   bus info: scsi@0:0.0.0,1
                   logical name: /dev/sda1
                   logical name: /
                   version: 1.0
                   serial: cc5c562a-bc59-4a37-b589-805b27b2cbd7
                   size: 690GiB
                   capacity: 690GiB
                   capabilities: primary bootable journaled extended_attributes large_files recover ext3 ext2 initialized
                   configuration: created=2010-02-27 09:18:28 filesystem=ext3 modified=2012-06-23 18:33:59 mount.fstype=ext3 mount.options=rw,relatime,errors=remount-ro,user_xattr,barrier=1,data=ordered mounted=2012-06-28 00:20:47 state=mounted
              *-volume:1
                   description: Linux swap volume
                   physical id: 2
                   bus info: scsi@0:0.0.0,2
                   logical name: /dev/sda2
                   version: 1
                   serial: 16a7fee0-be9e-4e34-9dc3-28f4eeb61bf6
                   size: 8091MiB
                   capacity: 8091MiB
                   capabilities: primary nofs swap initialized
                   configuration: filesystem=swap pagesize=4096

这些是相关的/etc/fstab线:

UUID=cc5c562a-bc59-4a37-b589-805b27b2cbd7 /               ext3    errors=remount-ro,user_xattr 0       1
UUID=16a7fee0-be9e-4e34-9dc3-28f4eeb61bf6 none            swap    sw              0       0

最佳解决办法

您的硬盘具有高级格式4096字节扇区,分区未完全对齐

这一行解释了警告:

Sector size (logical/physical): 512 bytes / 4096 bytes
  • 您的硬盘是较新的型号之一,它使用每个物理扇区4096字节的Advanced Format而不是旧的512字节/扇区。

  • 这些HDD仍然可以提供512字节/扇区的”legacy”仿真,这就是您将逻辑扇区大小视为512的原因。

  • 事实上,lshw显示它是西部数据驱动器,是第一家转向AF的公司。 They have an extensive page with lots of information on it,您可能希望看一下。

因此,发生警告是因为分区1开始于逻辑扇区63 =字节32256,一个不能被4096整除的数字;事实上,它接近第7个物理部门的结束(准确地说是7.875位置:)

你应该修好吗?如果是这样,怎么样? [永远备份!]

理论上,这种分区可能会稍微影响读/写IO速率,具体取决于驱动器的固件。如果您现在对性能感到满意,请忽略该警告,无需执行任何操作。如果没有,先备份所有重要数据,然后使用Gparted移动分区,使其从4096字节扇区开始;将起始边界设置为1 MiB是一种简单的方法。

  • 从技术上讲,您可以将开头设置为8的倍数的任何逻辑扇区,例如, 64好,256好,等等,但63,255 ……不是。

次佳解决办法

对于新硬盘,首先根据您的意愿使用gparted创建分区。

然后,使用sudo fdisk device_name访问您的硬盘。 fdisk中的m命令将打印帮助菜单。


npcompete@npcompete-desktop:~$ sudo fdisk /dev/sda

The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.

Command (m for help): p

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x0008e009

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048   209717247   104857600   83  Linux
/dev/sda2       209717248  1953525167   871903960    5  Extended
/dev/sda5       600349113   795667319    97659103+  83  Linux
Partition 5 does not start on physical sector boundary.
/dev/sda6       795667383   990985589    97659103+  83  Linux
Partition 6 does not start on physical sector boundary.
/dev/sda7       990985653  1953520064   481267206   83  Linux
Partition 7 does not start on physical sector boundary.
/dev/sda8       209719296   600349112   195314908+  83  Linux

Partition table entries are not in disk order
Command (m for help): d
Partition number (1-8): 5

Command (m for help): p

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x0008e009

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048   209717247   104857600   83  Linux
/dev/sda2       209717248  1953525167   871903960    5  Extended
/dev/sda5       795667383   990985589    97659103+  83  Linux
Partition 5 does not start on physical sector boundary.
/dev/sda6       990985653  1953520064   481267206   83  Linux
Partition 6 does not start on physical sector boundary.
/dev/sda7       209719296   600349112   195314908+  83  Linux

Partition table entries are not in disk order

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
npcompete@npcompete-desktop:~$ sudo fdisk /dev/sda

The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.

Command (m for help): n
Partition type:
   p   primary (1 primary, 1 extended, 2 free)
   l   logical (numbered from 5)
Select (default p): l
Adding logical partition 8
First sector (600351161-1953525167, default 600352768): 
Using default value 600352768
Last sector, +sectors or +size{K,M,G} (600352768-795667382, default 795667382): 
Using default value 795667382

Command (m for help): p

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x0008e009

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048   209717247   104857600   83  Linux
/dev/sda2       209717248  1953525167   871903960    5  Extended
/dev/sda5       795667383   990985589    97659103+  83  Linux
Partition 5 does not start on physical sector boundary.
/dev/sda6       990985653  1953520064   481267206   83  Linux
Partition 6 does not start on physical sector boundary.
/dev/sda7       209719296   600349112   195314908+  83  Linux
/dev/sda8       600352768   795667382    97657307+  83  Linux

Partition table entries are not in disk order

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

现在删除在fdisk中使用d选项发出警告的分区。

第一个命令d,然后是分区号(在警告中提到)。

现在使用w命令将更改写入磁盘。它将退出fdisk。

第二次使用sudo fdisk device_name访问你的硬盘。

现在使用fdisk中的n命令使用可用空间(以前我们已经删除了一个分区,即可用空间或未分配的空间)创建一个新分区。

在New partition命令中,不要为First和Last Sector输入任何值,只需按Enter键即可。它将采用默认值。

现在使用w命令将更改写入磁盘。它将退出fdisk。

对所有分区执行上述步骤。完成此格式后,使用gparted创建新创建的分区。 (这就是我为我所做的工作。在fdisk -l输出中没有警告。)

第三种解决办法

正如izx所指出的:

your hard disk has Advanced Format 4096-byte sectors to which the partition is not perfectly aligned.

this article很好地解释了高级格式规范及其对user-side硬盘分区实践的影响。

要解决此问题,您必须备份数据,然后执行以下操作之一:

  1. 将错误大小的分区调整为适当的大小。

  2. 删除错误大小的分区并创建适当大小的新分区。

要使用名为GParted的图形化hard-drive分区软件来完成此任务,您可以:

  1. 使用super-user权限启动Gparted应用程序;谨慎行事!

    gksudo gparted
    
  2. 从GParted菜单右上角的pull-down菜单中选择包含错误大小分区的存储设备。

  3. 通过在矩形分区映射中单击它来选择erroneously-sized分区。

  4. 现在您可以选择删除并创建新分区,也可以选择调整现有分区的大小。无论您的选择如何,您都会看到一个允许您设置分区大小的菜单。您必须清除“Round to cylinders”复选框并设置1MiB之前的可用空间大小。它看起来很像

partitioning,hard-drive,gparted,format,ubuntu

第四种办法

通过切换”u”单元。创建分区时将显示默认扇区大小。如果您开始分区新磁盘并且出现此错误,则可以。

  1. 用defaut创建一个分区。

  2. n,p,1,回车,回车

  3. 显示并获取分区错误消息。 “p”。

  4. 开关单元”u”

  5. 删除分区。 “d”

  6. 现在重新创建。这次默认值将显示正确的扇区。 (在我看来是1024)。


Command (m for help): p

Disk /dev/sdb: 599.9 GB, 599932844032 bytes
255 heads, 63 sectors/track, 72937 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 524288 bytes
Disk identifier: 0x2016bdc5

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-72937, default 1): 1
Last cylinder, +cylinders or +size{K,M,G} (1-72937, default 72937):
Using default value 72937

Command (m for help): p

Disk /dev/sdb: 599.9 GB, 599932844032 bytes
255 heads, 63 sectors/track, 72937 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 524288 bytes
Disk identifier: 0x2016bdc5

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       72937   585866421   83  Linux
Partition 1 does not start on physical sector boundary.

Command (m for help): u
Changing display/entry units to sectors

Command (m for help): p

Disk /dev/sdb: 599.9 GB, 599932844032 bytes
255 heads, 63 sectors/track, 72937 cylinders, total 1171743836 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 524288 bytes
Disk identifier: 0x2016bdc5

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1              63  1171732904   585866421   83  Linux
Partition 1 does not start on physical sector boundary.

Command (m for help): d
Selected partition 1

Command (m for help): p

Disk /dev/sdb: 599.9 GB, 599932844032 bytes
255 heads, 63 sectors/track, 72937 cylinders, total 1171743836 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 524288 bytes
Disk identifier: 0x2016bdc5

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 8
Value out of range.
Partition number (1-4): 1
First sector (63-1171743835, default 1024):
Using default value 1024
Last sector, +sectors or +size{K,M,G} (1024-1171743835, default 1171743835):
Using default value 1171743835

Command (m for help): p

Disk /dev/sdb: 599.9 GB, 599932844032 bytes
255 heads, 63 sectors/track, 72937 cylinders, total 1171743836 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 524288 bytes
Disk identifier: 0x2016bdc5

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            1024  1171743835   585871406   83  Linux

Command (m for help): w
The partition table has been altered!

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/2100.html,未经允许,请勿转载。