系统管理指南:设备和文件系统

第 12 章 管理磁盘(任务)

本章介绍管理磁盘的过程。如果您已经熟悉如何在运行 SolarisTM OS 的系统中管理磁盘,则本章介绍的许多过程是可选的。

有关与管理磁盘关联的过程的信息,请参见管理磁盘(任务列表)

有关磁盘管理的概述信息,请参见第 11 章,管理磁盘(概述)

管理磁盘(任务列表)

任务 

说明 

参考 

确定系统中的磁盘。 

如果不能确定系统中的磁盘类型,请使用 format 实用程序确定磁盘类型。

如何确定系统中的磁盘

格式化磁盘。 

使用 format 实用程序确定磁盘是否已格式化。

如何确定磁盘是否已格式化

 

大多数情况下,磁盘已经格式化。如果需要格式化磁盘,请使用 format 实用程序。

如何格式化磁盘

显示片信息。 

使用 format 实用程序显示片信息。

如何显示磁盘片信息

标记磁盘。 

使用 format 实用程序创建磁盘标号。

如何标记磁盘

检查磁盘标号。 

使用 prtvtoc 命令检查磁盘标号。

如何检查磁盘标号

恢复损坏的磁盘标号。 

可以尝试恢复因系统或电源故障而损坏的磁盘标号。 

如何恢复损坏的磁盘标号

创建 format.dat 项。

创建 format.dat 项以支持第三方磁盘。

如何创建 format.dat

自动配置 SCSI 磁盘。 

可以自动配置符合磁盘设备模式感知页面的 SCSI-2 规范的 SCSI 磁盘,即使 /etc/format.dat 文件中未列出该特定驱动器类型也是如此。

如何自动配置 SCSI 驱动器

确定有缺陷的磁盘扇区。 

使用 format 实用程序确定有缺陷的磁盘扇区。

如何使用表面分析确定有缺陷的扇区

如有必要,请修复有缺陷的磁盘扇区。 

使用 format 实用程序修复有缺陷的磁盘扇区。

如何修复有缺陷的扇区

确定系统中的磁盘

使用 format 实用程序搜索已连接到系统的磁盘的类型。还可以使用 format 实用程序验证磁盘是否是系统可识别的。有关使用 format 实用程序的详细信息,请参见第 16 章,format 实用程序(参考)

Procedure如何确定系统中的磁盘

  1. 成为超级用户或承担等效角色。

    角色包含授权和具有一定权限的命令。有关角色的更多信息,请参见《系统管理指南:安全性服务》中的“配置 RBAC(任务列表)”

  2. 使用 format 实用程序确定系统可识别的磁盘。


    # format
    

    format 实用程序在 AVAILABLE DISK SELECTIONS 下显示它所识别的磁盘的列表。


示例 12–1 确定系统中的磁盘

以下示例说明 format 命令的输出来自具有一个磁盘的系统。


# format

AVAILABLE DISK SELECTIONS:

 0. c0t1d0 <FUJITSU  MAN3367M SUN36G  1804 43d671f>

    /pci@1f,0/pci@1,1/scsi@2/sd@1,0

该输出将磁盘的物理设备名称和逻辑设备名称与磁盘的市场名称(位于尖括号 <> 中)相关联。请参见下面的示例。使用此方法可以轻松地确定哪些逻辑设备名称表示已连接到系统的磁盘。有关逻辑设备名称和物理设备名称的说明,请参见第 10 章,访问设备(概述)

以下示例使用通配符显示已连接到第二个控制器的四个磁盘。


# format /dev/rdsk/c2*

AVAILABLE DISK SELECTIONS:

       0. /dev/rdsk/c2t10d0s0 <SUN9.0G cyl 4924 alt 2 hd 27 sec 133>

          /sbus@3,0/SUNW,fas@3,8800000/sd@a,0

       1. /dev/rdsk/c2t11d0s0 <SUN9.0G cyl 4924 alt 2 hd 27 sec 133>

          /sbus@3,0/SUNW,fas@3,8800000/sd@b,0

       2. /dev/rdsk/c2t14d0s0 <SUN18G cyl 7506 alt 2 hd 19 sec 248>

          /sbus@3,0/SUNW,fas@3,8800000/sd@e,0

       3. /dev/rdsk/c2t15d0s0 <SUN18G cyl 7506 alt 2 hd 19 sec 248>

          /sbus@3,0/SUNW,fas@3,8800000/sd@f,0

Specify disk (enter its number): 

以下示例说明如何确定基于 SPARC 的系统中的磁盘。


# format

0. c0t1d0 <FUJITSU  MAN3367M SUN36G  1804 43d671f>

   /pci@1f,0/pci@1,1/scsi@2/sd@1,0

Specify disk (enter its number): 

该输出表明磁盘 0(目标 1)已连接到第二个 SCSI 主机适配器 (scsi@2),该适配器已连接到第二个 PCI 接口 (/pci@1f0/pci@1,1...)。该输出还将物理设备名称和逻辑设备名称与磁盘的市场名称 SUN36G 相关联。

以下示例说明如何确定基于 x86 的系统中的磁盘。


# format

AVAILABLE DISK SELECTIONS:

 0. c0d0 <DEFAULT cyl 615 alt 2 hd 64 sec 63>

     /pci@0,0/pci-ide@7,1/ata@0/cmdk@0,0

 1. c0d1 <DEFAULT cyl 522 alt 2 hd 32 sec 63>

     /pci@0,0/pci-ide@7,1/ata@0/cmdk@1,0

 2. c1d0 <DEFAULT cyl 817 alt 2 hd 256 sec 63>

     /pci@0,0/pci-ide@7,1/ata@1/cmdk@0,0

Specify disk (enter its number):  

该输出说明磁盘 0 已连接到第一个 PCI 主机适配器 (pci-ide@7...),该适配器已连接到 ATA 接口 (ata...)。基于 x86 的系统上的 format 输出不根据其市场名称确定磁盘。


如果 format 实用程序无法识别磁盘...

格式化磁盘

磁盘通常由制造商或转售商进行格式化。在安装驱动器时,通常无需重新格式化磁盘。

必须已对磁盘进行格式化后才能执行以下操作:


注意 – 注意 –

格式化磁盘是一个破坏性过程,因为它覆写磁盘上的数据。由于此原因,磁盘通常仅由制造商或转售商进行格式化。如果认为磁盘缺陷是导致某个问题反复出现的原因,则可以使用 format 实用程序执行表面分析。但是,应非常谨慎地仅使用不会破坏数据的命令。


Procedure如何确定磁盘是否已格式化

  1. 成为超级用户或承担等效角色。

  2. 调用 format 实用程序。


    # format
    

    将显示可用磁盘的编号列表。

  3. 键入要检查的磁盘的编号。


    Specify disk (enter its number): 0
    
  4. 通过查看以下消息,验证所选磁盘是否已格式化:


    [disk formatted]

示例 12–2 确定磁盘是否已格式化

以下示例说明磁盘 c1t0d0 已格式化。


# format /dev/rdsk/c1*

AVAILABLE DISK SELECTIONS:

       0. /dev/rdsk/c1t0d0s0 <SUN18G cyl 7506 alt 2 hd 19 sec 248>

          /sbus@2,0/QLGC,isp@2,10000/sd@0,0

       1. /dev/rdsk/c1t1d0s0 <SUN18G cyl 7506 alt 2 hd 19 sec 248>

          /sbus@2,0/QLGC,isp@2,10000/sd@1,0

       2. /dev/rdsk/c1t8d0s0 <SUN18G cyl 7506 alt 2 hd 19 sec 248>

          /sbus@2,0/QLGC,isp@2,10000/sd@8,0

       3. /dev/rdsk/c1t9d0s0 <SUN18G cyl 7506 alt 2 hd 19 sec 248>

          /sbus@2,0/QLGC,isp@2,10000/sd@9,0

Specify disk (enter its number): 0

selecting /dev/rdsk/c1t0d0s0

[disk formatted]

Procedure如何格式化磁盘

  1. 成为超级用户或承担等效角色。

  2. 调用 format 实用程序。


    # format
    

    将显示可用磁盘的编号列表。

  3. 键入要格式化的磁盘的编号。


    Specify disk (enter its number): 0
    

    注意 – 注意 –

    请勿选择系统磁盘。如果格式化系统磁盘,则会删除此磁盘上的 OS 和任何数据。


  4. 要开始格式化磁盘,请在 format> 提示符下键入 format。通过键入 y 确认该命令。


    format> format
    
    Ready to format.  Formatting cannot be interrupted
    
    and takes 23 minutes (estimated). Continue? yes
    
  5. 通过查看以下消息,验证磁盘格式化是否已成功:


    Beginning format. The current time Tue ABC xx xx:xx:xx xxxx
    
    
    
    Formatting...
    
    done
    
    
    
    Verifying media...
    
            pass 0 - pattern = 0xc6dec6de
    
       2035/12/18  
    
    
    
            pass 1 - pattern = 0x6db6db6d
    
       2035/12/18  
    
    
    
    Total of 0 defective blocks repaired.
  6. 退出 format 实用程序。


    format> quit
    

示例 12–3 格式化磁盘

以下示例说明如何格式化磁盘 c0t6d0


# format

Searching for disks...done





AVAILABLE DISK SELECTIONS:

       0. c0t0d0 <SUNW18G cyl 7506 alt 2 hd 19 sec 248

          /pci@1f,0/pci@1,1/scsi@2/sd@0,0

       1. c0t1d0 <FUJITSU  MAN3367M SUN36G  1804 43d671f>

          /pci@1f,0/pci@1,1/scsi@2/sd@1,0

       2. c0t2d0 <FUJITSU  MAN3367M SUN36G  1804 43d671f>

          /pci@1f,0/pci@1,1/scsi@2/sd@2,0

       3. c0t3d0 <FUJITSU  MAN3367M SUN36G  1804 43d671f>

          /pci@1f,0/pci@1,1/scsi@2/sd@3,0

       4. c0t4d0 <FUJITSU  MAN3367M SUN36G  1804 43d671f>

          /pci@1f,0/pci@1,1/scsi@2/sd@4,0

       5. c0t5d0 <FUJITSU  MAN3367M SUN36G  1804 43d671f>

          /pci@1f,0/pci@1,1/scsi@2/sd@5,0

       6. c0t6d0 <FUJITSU  MAN3367M SUN36G  1804 43d671f>

          /pci@1f,0/pci@1,1/scsi@2/sd@6,0

Specify disk (enter its number): 6

selecting c0t6d0

[disk formatted]

format> format

Ready to format.  Formatting cannot be interrupted

and takes 332 minutes (estimated). Continue? y

Beginning format. The current time is Wed Jan  7 16:16:05 2004



Formatting...

   99% complete (00:00:21 remaining) done



Verifying media...

        pass 0 - pattern = 0xc6dec6de

   71132922  



        pass 1 - pattern = 0x6db6db6d

   71132922  



Total of 0 defective blocks repaired.

format> quit

显示磁盘片

可以使用 format 实用程序检查磁盘是否具有适当的磁盘片。如果确定磁盘不包含要使用的片,请使用 format 实用程序重新创建它们并标记磁盘。有关创建磁盘片的信息,请参见SPARC: 如何创建磁盘片和标记磁盘x86: 如何创建磁盘片和标记磁盘


注 –

format 实用程序使用术语 partition 而不是 slice


Procedure如何显示磁盘片信息

  1. 成为超级用户或承担等效角色。

  2. 调用 format 实用程序。


    # format
    

    将显示可用磁盘的编号列表。

  3. 键入要显示其片信息的磁盘的编号。


    Specify disk (enter its number):1
    
  4. 选择 partition 菜单。


    format> partition 
    
  5. 显示选定磁盘的片信息。


    partition> print
    
  6. 退出 format 实用程序。


    partition> q
    
    format> q
    
    #
  7. 通过确定特定的片标记和片,验证所显示的片信息。

    如果屏幕输出说明未指定片大小,则磁盘很可能没有片。


示例 12–4 显示磁盘片信息

以下示例显示标号为 VTOC 的磁盘的片信息。


# format

Searching for disks...done

Specify disk (enter its number):1

Selecting c0t0d0

format> partition

partition> print

Current partition table (original):

Total disk cylinders available: 8892 + 2 (reserved cylinders)



Part      Tag    Flag     Cylinders        Size            Blocks

  0       root    wm    1110 - 4687        1.61GB    (0/3578/0) 3381210

  1       swap    wu       0 - 1109      512.00MB    (0/1110/0) 1048950

  2     backup    wm       0 - 8891        4.01GB    (0/8892/0) 8402940

  3 unassigned    wm       0               0         (0/0/0)          0

  4 unassigned    wm       0               0         (0/0/0)          0

  5 unassigned    wm       0               0         (0/0/0)          0

  6 unassigned    wm       0               0         (0/0/0)          0

  7       home    wm    4688 - 8891        1.89GB    (0/4204/0) 3972780

partition> q

format> q

#

有关这些示例中片信息的详细说明,请参见第 11 章,管理磁盘(概述)

以下示例显示标号为 EFI 的磁盘的片信息。


# format

Searching for disks...done

Specify disk (enter its number): 9

selecting c4t1d0

[disk formatted]

format> partition

partition> print

Current partition table (original):

partition> q

format> q

Part      Tag    Flag     First Sector          Size          Last Sector

  0       root    wm                34       300.00GB           629145633

  1        usr    wm         629145634       300.00GB           1258291233

  2 unassigned    wm                 0            0                0    

  3 unassigned    wm                 0            0                0    

  4 unassigned    wm                 0            0                0    

  5 unassigned    wm                 0            0                0    

  6        usr    wm        1258291234       628.77GB           2576924637

  8   reserved    wm        2576924638         8.00MB           2576941021    

创建和检查磁盘标号

标记磁盘通常是在系统安装过程中或者创建新磁盘片时进行的。如果磁盘标号已损坏,则可能需要重新标记磁盘。例如,磁盘标号因电源故障而损坏。

format 实用程序会尝试自动配置任何未标记的 SCSI 磁盘。如果 format 实用程序能够自动配置未标记的磁盘,则它将显示与以下内容类似的消息:


	c0t0d1: configured with capacity of 4.00GB

提示 –

有关标记具有相同磁盘标号的多个磁盘的信息,请参见使用 prtvtocfmthard 命令标记多个磁盘


Procedure如何标记磁盘

可以使用接下来的过程执行以下操作:

如果要用标号 EFI 标记小于 1 TB 的磁盘,请参见示例 12–6

  1. 成为超级用户或承担等效角色。

  2. 调用 format 实用程序。


    # format
    

    将显示可用磁盘的编号列表。

  3. 键入要标记的磁盘的编号。


    Specify disk (enter its number):1
    

    如果 format 实用程序识别该磁盘类型,则下一步是搜索备份标号以标记磁盘。使用备份标号标记磁盘时,会以正确的分区信息、磁盘类型和磁盘几何参数标记磁盘。

  4. 选择以下内容之一以标记磁盘:

    • 如果磁盘是未标记的但已成功配置,请转至步骤 5 标记磁盘。

      format 实用程序将询问您是否要标记磁盘。

    • 如果已标记磁盘但您要更改磁盘类型,或者如果 format 实用程序无法自动配置磁盘,请继续执行步骤 6 设置磁盘类型并标记磁盘。

  5. 通过在 Label it now? 提示符下键入 y 来标记磁盘。


    Disk not labeled. Label it now? y
    

    现在已标记磁盘。转至步骤 10 以退出 format 实用程序。

  6. format> 提示符下输入 type


    format> type
    

    将显示 "Available Drive Types" 菜单。

  7. 从可能的磁盘类型列表中选择一种磁盘类型。


    Specify disk type (enter its number)[12]: 12
    

    或者,选择 0 自动配置 SCSI-2 磁盘。有关更多信息,请参见如何自动配置 SCSI 驱动器

  8. 标记磁盘。如果磁盘未标记,则显示以下消息。


    Disk not labeled. Label it now? y
    

    否则,将显示以下消息提示您:


    Ready to label disk, continue? y
    
  9. 验证磁盘标号。


    format> verify 
    
  10. 退出 format 实用程序。


    format> q
    
    #

示例 12–5 标记磁盘

以下示例说明如何自动配置并标记 1.05 GB 磁盘。


# format

	c1t0d0: configured with capacity of 1002.09MB

 

AVAILABLE DISK SELECTIONS:

	  0. c0t3d0 <SUN1.05 cyl 2036 alt 2 hd 14 sec 72>

     /iommu@f,e0000000/sbus@f,e0001000/espdma@f,400000/esp@f,800000/sd@1,0

	  1. c1t0d0 <SUN1.05 cyl 2036 alt 2 hd 14 sec 72>

     /iommu@f,e0000000/sbus@f,e0001000/espdma@f,400000/esp@f,800000/sd@1,0

Specify disk (enter its number): 1

Disk not labeled.  Label it now?  yes

format> verify

format> q

#


示例 12–6 用标号 EFI 标记小于 1 TB 的磁盘

以下示例说明如何使用 format -e 命令以标号 EFI 标记小于 1 TB 的磁盘。请记住验证分层软件产品是否继续在包含标号 EFI 的磁盘的系统上起作用。有关 EFI 标号限制的常规信息,请参见EFI 磁盘标号限制


# format -e

Searching for disks...done

AVAILABLE DISK SELECTIONS:

       1. c1t0d0 <SUNW18g cyl 7506 alt 2 hd 19 sec 248>

          /sbus@2,0/QLGC,isp@2,10000/sd@0,0

       2. c1t1d0 <SUNW18g cyl 7506 alt 2 hd 19 sec 248>

          /sbus@2,0/QLGC,isp@2,10000/sd@1,0

       3. c1t8d0 <SUNW18g cyl 7506 alt 2 hd 19 sec 248>

          /sbus@2,0/QLGC,isp@2,10000/sd@8,0

       4. c1t9d0 <SUNW18g cyl 7506 alt 2 hd 19 sec 248>

          /sbus@2,0/QLGC,isp@2,10000/sd@9,0

Specify disk (enter its number): 4

selecting c1t9d0

[disk formatted]

format> label

[0] SMI Label

[1] EFI Label

Specify Label type[0]: 1

Ready to label disk, continue? yes

format> quit

Procedure如何检查磁盘标号

使用 prtvtoc 命令检查磁盘标号信息。有关磁盘标号的详细说明和 prtvtoc 命令所显示的信息,请参见第 11 章,管理磁盘(概述)

  1. 成为超级用户或承担等效角色。

  2. 显示磁盘标号信息。


    # prtvtoc /dev/rdsk/device-name
    

    其中 device-name 是要检查的原始磁盘设备。


示例 12–7 检查磁盘标号

以下示例说明标号为 VTOC 的磁盘的磁盘标号信息。


# prtvtoc /dev/rdsk/c0t0d0s0

* /dev/rdsk/c0t0d0s0 partition map

*

* Dimensions:

*     512 bytes/sector

*      63 sectors/track

*      15 tracks/cylinder

*     945 sectors/cylinder

*    8894 cylinders

*    8892 accessible cylinders

*

* Flags:

*   1: unmountable

*  10: read-only

*

*                          First     Sector    Last

* Partition  Tag  Flags    Sector     Count    Sector  Mount Directory

       0      2    00    1048950   3381210   4430159   /

       1      3    01          0   1048950   1048949

       2      5    00          0   8402940   8402939

       7      8    00    4430160   3972780   8402939   /export/home

以下示例说明标号为 EFI 的磁盘的磁盘标号信息。


# prtvtoc /dev/rdsk/c3t1d0s0

* /dev/rdsk/c3t1d0s0 partition map

*

* Dimensions:

*     512 bytes/sector

* 2479267840 sectors

* 2479267773 accessible sectors

*

* Flags:

*   1: unmountable

*  10: read-only

*

*                          First      Sector       Last

* Partition  Tag  Flags    Sector     Count        Sector  Mount Directory

       0      2    00          34      262144      262177

       1      3    01      262178      262144      524321

       6      4    00      524322  2478727100  2479251421

       8     11    00  2479251422       16384  2479267805

恢复损坏的磁盘标号

有时,电源或系统故障会导致磁盘标号变得无法识别。损坏的磁盘标号并不总是意味着,必须重新创建或恢复片信息或磁盘数据。

要恢复损坏的磁盘标号,首先应使用正确的几何参数和磁盘类型信息标记磁盘。可以通过常规的磁盘标记方法完成该步骤,即使用自动配置或手动指定磁盘类型。

如果 format 实用程序识别该磁盘类型,则下一步是搜索备份标号以标记磁盘。使用备份标号标记磁盘时,会以正确的分区信息、磁盘类型和磁盘几何参数来标记磁盘。

Procedure如何恢复损坏的磁盘标号

  1. 将系统引导到单用户模式。

    如有必要,请在单用户模式下从本地 CD-ROM 或网络引导系统以访问磁盘。

    有关引导系统的信息,请参见《系统管理指南:基本管理》中的第 10  章 “引导系统(任务)”《系统管理指南:基本管理》中的第 11  章 “基于 GRUB 的引导(任务)”

  2. 重新标记磁盘。


    # format
    

    format 实用程序会尝试自动配置任何未标记的 SCSI 磁盘。如果 format 实用程序能够配置未标记的已损坏磁盘,则它将显示以下消息:


    cwtxdy: configured with capacity of abcMB

    format 实用程序然后显示系统中磁盘的编号列表。

  3. 键入需要恢复的磁盘的编号。


    Specify disk (enter its number): 1
    
  4. 选择以下内容之一以确定如何标记磁盘。

    • 如果已成功配置磁盘,则按照步骤 5 和 6 进行操作,然后转至步骤 12。

    • 如果磁盘未成功配置,则按照步骤 7–11 操作,然后转至步骤 12。

  5. 搜索备份标号。


    format> verify
    
    Warning: Could not read primary label.
    
    Warning: Check the current partitioning and 'label' the disk or 
    
    use the 'backup' command.
    
    Backup label contents:
    
    Volume name = <        >
    
    ascii name  = <SUN1.05 cyl 2036 alt 2 hd 14 sec 72>
    
    pcyl        = 2038
    
    ncyl        = 2036
    
    acyl        =    2
    
    nhead       =   14
    
    nsect       =   72
    
    Part      Tag    Flag     Cylinders        Size            Blocks
    
      0       root    wm       0 -  300      148.15MB    (301/0/0)   303408
    
      1       swap    wu     301 -  524      110.25MB    (224/0/0)   225792
    
      2     backup    wm       0 - 2035     1002.09MB    (2036/0/0) 2052288
    
      3 unassigned    wm       0               0         (0/0/0)          0
    
      4 unassigned    wm       0               0         (0/0/0)          0
    
      5 unassigned    wm       0               0         (0/0/0)          0
    
      6        usr    wm     525 - 2035      743.70MB    (1511/0/0) 1523088
    
      7 unassigned    wm       0               0         (0/0/0)          0
  6. 如果 format 实用程序找到备份标号,而且备份标号的内容符合要求,请使用 backup 命令以备份标号标记磁盘。


    format> backup
    
    Disk has a primary label, still continue? y
    
     
    
    Searching for backup labels...found.
    
    Restoring primary label

    磁盘标号已恢复。转至步骤 12。

  7. 如果 format 实用程序无法自动配置磁盘,请使用 type 命令指定磁盘类型。


    format> type
    

    将显示 "Available Drive Types" 菜单。

  8. 选择 0 以自动配置磁盘。或者,从可能的磁盘类型列表中选择一种磁盘类型。


    Specify disk type (enter its number)[12]: 12
    
  9. 如果成功配置磁盘,则在 format 实用程序询问您是否要标记磁盘时应答 no


    Disk not labeled.  Label it now?  no
    
  10. 使用 verify 命令搜索备份标号。


    format> verify
    
    Warning: Could not read primary label.
    
    Warning: Check the current partitioning and 'label' the disk
    
    or use the 'backup' command.
    
    .
    
    .
    
    .
  11. 如果 format 实用程序找到备份标号,而且备份标号的内容符合要求,请使用 backup 命令以备份标号标记磁盘。


    format> backup
    
    Disk has a primary label, still continue? y
    
    Searching for backup labels...found.
    
    Restoring primary label

    磁盘标号已恢复。

  12. 退出 format 实用程序。


    format> q
    
  13. 使用 fsck 命令验证已恢复磁盘上的文件系统。

    有关使用 fsck 命令的信息,请参见第 22 章,检查 UFS 文件系统一致性(任务)

添加第三方磁盘

Solaris OS 支持许多第三方磁盘。但是,为了识别磁盘,您可能需要提供设备驱动程序和/或 format.dat 项。用于添加磁盘的其他选项如下:

如果第三方磁盘设计为使用标准的 SunOS 兼容设备驱动程序,则创建适当的 format.dat 项应该足以使 format 实用程序能够识别该磁盘。在其他情况下,需要装入第三方设备驱动程序以支持磁盘。


注 –

Sun 无法保证其 format 实用程序将与所有第三方磁盘驱动程序兼容。如果磁盘驱动程序与 Solaris format 实用程序不兼容,则磁盘驱动器供应商应该为您提供自定义的磁盘格式化程序。


本节讨论在缺少某些此软件支持时需要执行的操作。通常,在调用 format 实用程序如果发现未识别出磁盘类型,则说明缺少软件支持。

如本节所述提供缺少的软件。然后,参阅第 13 章,SPARC:添加磁盘(任务)第 14 章,x86:添加磁盘(任务)中添加系统磁盘或辅助磁盘的相应配置过程。

创建 format.dat

如果没有有关磁盘几何参数和操作参数的准确信息,则无法格式化无法识别的磁盘。此信息在 /etc/format.dat 文件中提供。


注 –

SCSI-2 磁盘不需要 format.dat 项。如果在重新配置引导过程中打开了磁盘电源,则 format 实用程序自动配置 SCSI-2 驱动程序。有关自动配置 SCSI 磁盘驱动器的逐步说明,请参见如何自动配置 SCSI 驱动器


如果磁盘是无法识别的,请使用文本编辑器在 format.dat 文件中为该磁盘创建项。在开始之前,需要收集与磁盘及其控制器有关的所有技术规格。磁盘应该附带有此信息。如果没有此信息,请与磁盘制造商或供应商联系。

Procedure如何创建 format.dat

  1. 成为超级用户或承担等效角色。

  2. 生成 /etc/format.dat 文件的副本。


    # cp /etc/format.dat /etc/format.dat.gen
    
  3. 修改 /etc/format.dat 文件以包括第三方磁盘的项。

    使用第 16 章,format 实用程序(参考)中所述的 format.dat 信息。

    此外,使用磁盘的硬件产品文档收集所需的信息。

自动配置 SCSI 磁盘驱动器

format 实用程序自动配置 SCSI 磁盘驱动器,即使 /etc/format.dat 文件中未列出该特定类型的驱动器也将如此。通过此功能,可以对符合磁盘设备模式感知页面的 SCSI-2 规范的任何磁盘驱动程序进行格式化、创建片和标记。

以下是用于添加磁盘的其他选项:

使用自动配置功能配置 SCSI 驱动器涉及以下步骤:

在执行重新配置引导后,调用 format 实用程序。format 实用程序将尝试配置磁盘;如果配置成功,则提醒用户已配置磁盘。有关自动配置 SCSI 磁盘驱动器的逐步说明,请参见如何自动配置 SCSI 驱动器

以下是 format 实用程序所显示的 1.3 GB SCSI 磁盘驱动器分区表的示例。


Part    Tag    Flag     Cylinders     Size        Blocks

   0     root    wm       0 -   96    64.41MB      (97/0/0)

   1     swap    wu      97 -  289   128.16MB     (193/0/0)

   2   backup    wu       0 - 1964     1.27GB    (1965/0/0)

   6      usr    wm     290 - 1964     1.09GB    (1675/0/0)

Procedure如何自动配置 SCSI 驱动器

  1. 成为超级用户或等效角色。

  2. 创建将在引导系统时读取的 /reconfigure 文件。


    # touch /reconfigure
    
  3. 关闭系统。


    # shutdown -i0 -gn -y
    
    -i0

    将系统降至 init 级别 0(即电源关闭状态)。

    -gn

    通知已登录的用户,n 秒之后系统将开始关闭。

    -y

    指定命令应该在没有用户干预的情况下运行。

    在关闭系统后将显示 ok 提示符。

  4. 关闭系统和所有外部外围设备的电源。

  5. 确保所添加的磁盘与系统中的其他设备具有不同的目标号码。

    通常,磁盘背面有一个用于此目的的小开关。

  6. 将磁盘连接到系统,并检查物理连接。

    有关详细信息,请参阅磁盘的硬件安装指南。

  7. 打开所有外部外围设备的电源。

  8. 打开系统的电源。

    系统将引导并显示登录提示。

  9. 再次作为超级用户登录或承担等效角色。

  10. 调用 format 实用程序,然后选择要自动配置的磁盘。


    # format
    
    Searching for disks...done
    
    c1t0d0: configured with capacity of 1002.09MB
    
    AVAILABLE DISK SELECTIONS:
    
    0. c0t1d0 <SUN1.05 cyl 2036 alt 2 hd 14 sec 72>
    
       /iommu@f,e0000000/sbus@f,e0001000/espdma@f,400000/esp@f,800000/sd@1,0
    
    1. c0t3d0 <SUN1.05 cyl 2036 alt 2 hd 14 sec 72>
    
       /iommu@f,e0000000/sbus@f,e0001000/espdma@f,400000/esp@f,800000/sd@3,0
    
    Specify disk (enter its number): 1
    
  11. 作为对提示的响应,键入 y 以标记磁盘。

    键入 y 时,将使用 SCSI 自动配置生成磁盘标号并将其写入磁盘。


    Disk not labeled. Label it now? y
    
  12. 验证磁盘标号。


    format> verify
    
  13. 退出 format 实用程序。


    format> q
    

修复有缺陷的扇区

如果系统中的磁盘存在有缺陷的扇区,可以按照本节中的过程修复磁盘。在执行以下操作时,可能会发现存在有缺陷的扇区:

Procedure如何使用表面分析确定有缺陷的扇区

  1. 成为超级用户或承担等效角色。

  2. 取消挂载包含有缺陷扇区的片中的文件系统。


    # umount /dev/dsk/device-name
    

    有关更多信息,请参见 mount(1M)

  3. 调用 format 实用程序。


    # format
    
  4. 选择受影响的磁盘。


    Specify disk (enter its number):1
    
    selecting c0t2d0:
    
    [disk formatted]
    
    Warning: Current Disk has mounted partitions.
  5. 选择 analyze 菜单。


    format> analyze
    
  6. 通过在 analyze> 提示符下键入 setup 设置分析参数。

    使用如下所示的参数:


    analyze> setup
    
    Analyze entire disk [yes]? n
    
    Enter starting block number [0, 0/0/0]: 12330
    
    Enter ending block number [2052287, 2035/13/71]: 12360
    
    Loop continuously [no]? y
    
    Repair defective blocks [yes]? n
    
    Stop after first error [no]? n
    
    Use random bit patterns [no]? n
    
    Enter number of blocks per transfer [126, 0/1/54]: 1
    
    Verify media after formatting [yes]? y
    
    Enable extended messages [no]? n
    
    Restore defect list [yes]? y
    
    Create defect label [yes]? y
    
  7. 使用 read 命令查找缺陷。


    analyze> read
    
    Ready to analyze (won't harm SunOS). This takes a long time,
    
    but is interruptible with Control-C. Continue? y
    
            pass 0
    
       2035/12/1825/7/24
    
            pass 1
    
    Block 12354  (18/4/18), Corrected media error (hard data ecc)
    
       25/7/24
    
    ^C
    
    Total of 1 defective blocks repaired.

Procedure如何修复有缺陷的扇区

  1. 成为超级用户或承担等效角色。

  2. 调用 format 实用程序。


    # format
    
  3. 选择存在有缺陷扇区的磁盘。


    Specify disk (enter its number): 1
    
    selecting c0t3d0
    
    [disk formatted]
    
    format> 
  4. 选择 repair 命令。


    format> repair
    
  5. 键入有缺陷块的编号。


    Enter absolute block number of defect: 12354
    
       Ready to repair defect, continue? y
    
       Repairing block 12354 (18/4/18)...ok.
    
    format>

    如果不能确定用于确定有缺陷扇区的格式,请参见如何使用表面分析确定有缺陷的扇区以了解更多信息。

管理磁盘的提示和技巧

使用以下提示可帮助您更有效地管理磁盘。

调试 format 会话

调用 format -M 命令为 ATA 和 SCSI 设备启用扩展消息和诊断消息。


示例 12–8 调试 format 会话

在此示例中,Inquiry 下的数字系列表示在数字右侧显示的 inquiry 数据的十六进制值。


# format -M

Searching for disks...done

AVAILABLE DISK SELECTIONS:

  0. c0t1d0 <SUN1.05 cyl 2036 alt 2 hd 14 sec 72>

     /iommu@f,e0000000/sbus@f,e0001000/espdma@f,400000/esp@f,800000/sd@1,0

  1. c0t3d0 <SUN1.05 cyl 2036 alt 2 hd 14 sec 72>

     /iommu@f,e0000000/sbus@f,e0001000/espdma@f,400000/esp@f,800000/sd@3,0

 

Specify disk (enter its number): 0

selecting c0t3d0

[disk formatted]

format> inquiry

Inquiry:

00 00 02 02 8f 00 00 12 53 45 41 47 41 54 45 20     ........NAME....

53 54 31 31 32 30 30 4e 20 53 55 4e 31 2e 30 35     ST11200N SUN1.05

38 33 35 38 30 30 30 33 30 32 30 39 00 00 00 00     835800030209....

00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00     ................

00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00     ................

00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00     ................

00 43 6f 70 79 72 69 67 68 74 20 28 63 29 20 31     .Copyright (c) 1

39 39 32 20 53 65 61 67 61 74 65 20 41 6c 6c 20     992 NAME    All 

72 69 67 68 74 73 20 72 65 73 65 72 76 65 64 20     rights reserved 

30 30 30                                            000

Vendor:   name 

Product:  ST11200N SUN1.05

Revision: 8358

format> 

使用 prtvtocfmthard 命令标记多个磁盘

使用 prtvtocfmthard 命令标记具有相同磁盘几何参数的多个磁盘。

在脚本中使用以下 for 循环,从一个磁盘复制磁盘标号,然后在多个磁盘上复制它。


# for i in x y z

> do

> prtvtoc /dev/rdsk/cwtxdysz | fmthard -s - /dev/rdsk/cwt${i}d0s2

> done

示例 12–9 标记多个磁盘

在此示例中,将来自 c2t0d0s0 的磁盘标号复制到其他四个磁盘。


# for i in 1 2 3 5

> do

> prtvtoc /dev/rdsk/c2t0d0s0 | fmthard -s - /dev/rdsk/c2t${i}d0s2

> done

fmthard:  New volume table of contents now in place.

fmthard:  New volume table of contents now in place.

fmthard:  New volume table of contents now in place.

fmthard:  New volume table of contents now in place.

#