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

x86: 添加系统磁盘或辅助磁盘

系统磁盘包含根 (/) 文件系统和/或 /usr 文件系统。如果包含其中任一文件系统的磁盘损坏,则可以使用以下两种方法恢复文件系统:

辅助磁盘不包含根 (/) 文件系统和 /usr 文件系统。辅助磁盘通常包含用于存储用户文件的空间。可以将辅助磁盘添加到系统以获得更多磁盘空间。或者,可以更换损坏的辅助磁盘。如果更换系统中的辅助磁盘,则可以在新磁盘上恢复旧磁盘的数据。

Procedurex86: 如何连接系统磁盘

此过程假定已关闭操作系统。

  1. 断开损坏的系统磁盘与系统之间的连接。

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

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

  3. 将用来替换的系统磁盘连接到系统,并检查物理连接。

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

  4. 引导系统。

    此过程假定将从 GRUB 的 Solaris 故障安全引导选项进行引导。

    1. 如果系统显示 Press any key to reboot 提示,请按任意键重新引导系统。或者,使用复位按钮重新启动系统(如果已关闭系统)。

      几分钟后将显示 GRUB 菜单。

    2. 使用方向键选择 Solaris 故障安全引导选项。

    3. 按回车键。

    4. 出现提示 Do you wish to automatically update boot archives? 时,应答 no。

      此时将显示超级用户提示符 (#)。


      注 –

      要退出 Solaris 故障安全引导模式时,必须重新引导系统。在成功添加系统磁盘、恢复数据并安装引导块后,才能将系统重新引导到多用户模式。


连接系统磁盘之后

如果磁盘小于 1 TB,则可以创建 fdisk 分区。请转至x86: 如何创建 Solaris fdisk 分区

Procedure如何更改 Solaris fdisk 标识符

通过新的 fdisk 菜单选项,可以在新标识符和旧标识符之间来回切换。即使挂载了分区中包含的文件系统,也可以更改 fdisk 标识符。

fdisk 菜单中的两个 type 值反映旧标识符和新标识符,如下所示:

  1. 成为超级用户。

  2. 显示当前的 fdisk 标识符。

    例如:


                Total disk size is 39890 cylinders
    
                Cylinder size is 4032 (512 byte) blocks
    
    
    
                                                  Cylinders
    
         Partition   Status    Type          Start   End   Length    %
    
         =========   ======    ============  =====   ===   ======   ===
    
             1       Active    x86 Boot          1     6       6      0
    
             2                 Solaris2          7  39889    39883    100
  3. fdisk 菜单中选择选项 4,将 fdisk 分区标识符更改回 0x82


    SELECT ONE OF THE FOLLOWING:
    
      1. Create a partition
    
      2. Specify the active partition
    
      3. Delete a partition
    
      4. Change between Solaris and Solaris2 Partition IDs
    
      5. Exit (update disk configuration and exit)
    
      6. Cancel (exit without updating disk configuration)
    
    Enter Selection: 4
    
  4. 选择选项 5 更新磁盘配置并退出。

  5. 如有必要,请从 fdisk 菜单中选择选项 4,将 fdisk 分区标识符更改回 0xbf

    例如:


    Total disk size is 39890 cylinders
    
                Cylinder size is 4032 (512 byte) blocks
    
    
    
                                                  Cylinders
    
         Partition   Status    Type          Start   End   Length    %
    
         =========   ======    ============  =====   ===   ======   ===
    
             1       Active    x86 Boot          1     6       6      0
    
             2                 Solaris           7  39889    39883    100
    
    
    
    SELECT ONE OF THE FOLLOWING:
    
      1. Create a partition
    
      2. Specify the active partition
    
      3. Delete a partition
    
      4. Change between Solaris and Solaris2 Partition IDs
    
      5. Exit (update disk configuration and exit)
    
      6. Cancel (exit without updating disk configuration)
    
    Enter Selection: 4
    
  6. 选择选项 5 更新磁盘配置并退出。

Procedurex86: 如何连接辅助磁盘并进行引导

有关在 x64 系统上添加磁盘标号为 EFI 的磁盘的信息,请参见带有 EFI 磁盘标号的多 TB 磁盘支持以了解更多信息。

通常,大多数新式总线类型支持热插拔。如果系统的总线类型支持热插拔,则可能无需执行下面的步骤 2 或 3。

有关热插拔设备的更多信息,请参见第 6 章,动态配置设备(任务)

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

  2. (可选的)如果磁盘不受 Solaris 软件的支持,请按照硬件附带的说明,添加磁盘的设备驱动程序。

  3. (可选的)创建将在引导系统时读取的 /reconfigure 文件。


    # touch /reconfigure
    

    稍后打开系统电源或引导系统时,/reconfigure 文件会使 SunOSTM 软件检查是否存在任何新安装的外围设备。

  4. 关闭系统。


    # shutdown -i0 -gn -y
    
    -i0

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

    -gn

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

    -y

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

    将显示提示 Press any key to reboot

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

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

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

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

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

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

  9. 打开系统的电源。

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

连接辅助磁盘并进行引导之后

引导系统后,如果磁盘小于 1 TB,则可以创建 fdisk 分区。请转至x86: 如何创建 Solaris fdisk 分区

x86: fdisk 分区创建准则

设置一个或多个 fdisk 分区时,请遵循以下准则。


仅适用于 x86 –

Solaris 片也称为分区。某些界面可能将称为分区

只有基于 x86 的系统支持 fdisk 分区。为避免混淆,Solaris 文档尝试区分 fdisk 分区和 Solaris fdisk 分区中的实体。这些实体可能称为片或分区。


Procedurex86: 如何创建 Solaris fdisk 分区

开始之前

如果需要有关 fdisk 分区的信息,请参见x86: fdisk 分区创建准则

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

  2. 调用 format 实用程序。


    # format
    

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

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

  3. 键入要创建 Solaris fdisk 分区的磁盘的编号。


    Specify disk (enter its number): disk-number
    

    其中 disk-number 是要创建 Solaris fdisk 分区的磁盘的编号。

  4. 选择 fdisk 菜单。


    format> fdisk
    

    所显示的 fdisk 菜单取决于磁盘上是否已存在fdisk 分区。使用下表确定下一步操作。

    任务 

    请转至 

    更多信息 

    创建一个跨整个磁盘的 Solaris fdisk 分区。

    步骤 5 

    示例 14–1

    创建一个 Solaris fdisk 分区,并保留一个或多个现有的非 Solaris fdisk 分区。

    步骤 6 

    示例 14–2

    创建一个 Solaris fdisk 分区以及一个或多个其他非 Solaris fdisk 分区。

    步骤 6 

    示例 14–3

  5. 通过在提示符下指定 y,创建并激活跨整个磁盘的 Solaris fdisk 分区。然后,转至步骤 13。


    No fdisk table exists. The default partition for the disk is:
    
    
    
    a 100% "SOLARIS System" partition
    
    
    
    Type "y" to accept the default partition, otherwise type "n" to edit the
    
    partition table.
    
    y
    
  6. 如果不希望 Solaris fdisk 分区占满整个磁盘,请在提示符下指定 n


    Type "y" to accept the default partition, otherwise type "n" to edit the
    
     partition table.
    
    n
    
                 Total disk size is 3498 cylinders
    
                 Cylinder size is 1199 (512 byte) blocks
    
                                             Cylinders
    
        Partition   Status    Type      Start   End   Length    %
    
        =========   ======    ========  =====   ===   ======   ===
    
    SELECT ONE OF THE FOLLOWING:
    
         
    
      1. Create a partition
    
      2. Specify the active partition
    
      3. Delete a partition
    
      4. Change between Solaris and Solaris2 Partition IDs
    
      5. Exit (update disk configuration and exit)
    
      6. Cancel (exit without updating disk configuration)
    
    Enter Selection:
  7. 选择选项 1 (Create a partition) 以创建 fdisk 分区。


    Enter Selection: 1
    
  8. 通过选择 1(=Solaris2) 创建 Solaris fdisk 分区。


    Indicate the type of partition you want to create
    
      1=SOLARIS2   2=UNIX        3=PCIXOS     4=Other
    
      5=DOS12      6=DOS16       7=DOSEXT     8=DOSBIG
    
      9=DOS16LBA   A=x86 Boot    B=Diagnostic C=FAT32
    
      D=FAT32LBA   E=DOSEXTLBA   F=EFI        0=Exit? 1
    
  9. 确定要为 Solaris fdisk 分区保留的磁盘百分比。计算此百分比时,请牢记任何现有 fdisk 分区的大小。


    Specify the percentage of disk to use for this partition
    
    (or type "c" to specify the size in cylinders). nn
    
  10. 通过在提示符下键入 y,激活 Solaris fdisk 分区。


    Should this to become the active partition? If yes, it will be 
    
    activated each time the computer is reset or turned on.
    
    Please type "y" or "n". y
    

    激活 fdisk 分区后,将显示提示 Enter Selection

  11. 选择选项 1 Create a partition 以创建另一个 fdisk 分区。

    有关创建 fdisk 分区的说明,请参见步骤 8–10。

  12. 更新磁盘配置,然后从 selection 菜单退出 fdisk 菜单。


    Selection: 5 
    
  13. 使用 label 命令重新标记磁盘。


    format> label
    
    Ready to label disk, continue? yes
    
    format> 
  14. 退出 format 实用程序。


    format> quit
    

示例 14–1 x86: 创建一个占满整个驱动器的 Solaris fdisk 分区

以下示例使用 format 实用程序的 fdisk 选项创建一个占满整个驱动器的 Solaris fdisk 分区。


# format

Searching for disks...done

AVAILABLE DISK SELECTIONS:

       0. c0d0 <DEFAULT cyl 2466 alt 2 hd 16 sec 63>

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

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

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

       2. c1d0 <DEFAULT cyl 13102 alt 2 hd 16 sec 63>

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

Specify disk (enter its number): 0

selecting c0d0

Controller working list found

[disk formatted]

format> fdisk

No fdisk table exists. The default partitioning for your disk is:

 

  a 100% "SOLARIS System" partition.

 

Type "y" to accept the default partition, otherwise type "n" to edit the

partition table. y



format> label

Ready to label disk, continue? yes

format> quit


示例 14–2 x86: 创建 Solaris fdisk 分区并保留现有的 fdisk 分区

以下示例说明如何在包含现有 DOS-BIG fdisk 分区的磁盘上创建 Solaris fdisk 分区。


format> fdisk

             Total disk size is 3498 cylinders

             Cylinder size is 1199 (512 byte) blocks



                                               Cylinders

      Partition   Status    Type          Start   End   Length    %

      =========   ======    ============  =====   ===   ======   ===

          1       Active    DOS-BIG           1   699     699     20

SELECT ONE OF THE FOLLOWING:

  1. Create a partition

  2. Specify the active partition

  3. Delete a partition

  4. Change between Solaris and Solaris2 Partition IDs

  5. Exit (update disk configuration and exit)

  6. Cancel (exit without updating disk configuration)  

Enter Selection: 1

Indicate the type of partition you want to create

  1=SOLARIS2  2=UNIX        3=PCIXOS     4=Other

  5=DOS12     6=DOS16       7=DOSEXT     8=DOSBIG

  9=DOS16LBA  A=x86 Boot    B=Diagnostic C=FAT32

  D=FAT32LBA  E=DOSEXTLBA   F=EFI        0=Exit?1

Indicate the percentage of the disk you want this partition

to use (or enter "c" to specify in cylinders). 80

Should this become the active partition? If yes, it will be 

activated each time the computer is or turned on. 

Please type "y" or "n". y

             Total disk size is 3498 cylinders

             Cylinder size is 1199 (512 byte) blocks

                                               Cylinders

      Partition   Status    Type          Start   End   Length    %

      =========   ======    ============  =====   ===   ======   ===

          1                 DOS-BIG           1   699     699     20

          2       Active    Solaris2        700  3497    2798     80

    

SELECT ONE OF THE FOLLOWING:

  1. Create a partition

  2. Specify the active partition

  3. Delete a partition

  4. Change between Solaris and Solaris2 Partition IDs

  5. Exit (update disk configuration and exit)

  6. Cancel (exit without updating disk configuration)   

Enter Selection:5

Partition 2 is now the active partition 

format> label

Ready to label disk, continue? yes

format> q


示例 14–3 x86: 创建 Solaris fdisk 分区和另一个 fdisk 分区

以下示例说明如何创建 Solaris fdisk 分区和 DOSBIG fdisk 分区。


format> fdisk

No fdisk table exists. The default partitioning for your disk is:

   a 100% "SOLARIS System" partition.

Type "y" to accept the default partition, otherwise type "n" to edit the

partition table.

n

             Total disk size is 3498 cylinders

             Cylinder size is 1199 (512 byte) blocks

                                               Cylinders

      Partition   Status    Type          Start   End   Length    %

      =========   ======    ============  =====   ===   ======   ===

SELECT ONE OF THE FOLLOWING:

  1. Create a partition

  2. Specify the active partition

  3. Delete a partition

  4. Change between Solaris and Solaris2 Partition IDs

  5. Exit (update disk configuration and exit)

  6. Cancel (exit without updating disk configuration)  

Enter Selection: 1

Indicate the type of partition you want to create

1=SOLARIS2   2=UNIX        3=PCIXOS     4=Other

5=DOS12      6=DOS16       7=DOSEXT     8=DOSBIG

9=DOS16LBA   A=x86 Boot    B=Diagnostic C=FAT32

D=FAT32LBA   E=DOSEXTLBA   F=EFI        0=Exit?  8

Specify the percentage of disk to use for this partition

(or type "c" to specify the size in cylinders)20

Should this to become the Active partition? If yes, it will be 

activated each time the computer is reset or turned on. 

again. Please type "y" or "n". n

             Total disk size is 3498 cylinders

             Cylinder size is 1199 (512 byte) blocks

                                               Cylinders

      Partition   Status    Type          Start   End   Length    %

      =========   ======    ============  =====   ===   ======   ===

          1                 DOS-BIG           1   699     699     20

  SELECT ONE OF THE FOLLOWING:

  1. Create a partition

  2. Specify the active partition

  3. Delete a partition

  4. Change between Solaris and Solaris2 Partition IDs

  5. Exit (update disk configuration and exit)

  6. Cancel (exit without updating disk configuration)  

Enter Selection: 1

Indicate the type of partition you want to create

1=SOLARIS2   2=UNIX        3=PCIXOS     4=Other

5=DOS12      6=DOS16       7=DOSEXT     8=DOSBIG

9=DOS16LBA   A=x86 Boot    B=Diagnostic C=FAT32

D=FAT32LBA   E=DOSEXTLBA   F=EFI        0=Exit? 1

Indicate the percentage of the disk you want this partition

to use (or enter "c" to specify in cylinders). 80

Should this become the active partition? If yes, it will be 

activated each time the computer is reset or turned on.

Please type "y" or "n". y

             Total disk size is 3498 cylinders

             Cylinder size is 1199 (512 byte) blocks

                                               Cylinders

      Partition   Status    Type          Start   End   Length    %

      =========   ======    ============  =====   ===   ======   ===

          1                 DOS-BIG           1   699     699     20

          2       Active    Solaris2         700  3497    2798     80

SELECT ONE OF THE FOLLOWING:

  1. Create a partition

  2. Specify the active partition

  3. Delete a partition

  4. Change between Solaris and Solaris2 Partition IDs

  5. Exit (update disk configuration and exit)

  6. Cancel (exit without updating disk configuration)  

Enter Selection: 5

Partition 2 is now the Active partition 

format> q

创建 Solaris fdisk 分区之后

在磁盘上创建 Solaris fdisk 分区后,可以在该磁盘上创建片。请转至x86: 如何创建磁盘片和标记磁盘

Procedurex86: 如何创建磁盘片和标记磁盘

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

  2. 调用 format 实用程序。


    # format
    

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

  3. 键入要重新分区的磁盘的编号。


    Specify disk (enter its number): disk-number
    

    其中 disk-number 是要重新分区的磁盘的编号。

  4. 选择 partition 菜单。


    format> partition
    
  5. 显示当前分区(片)表。


    partition> print
    
  6. 开始修改过程。


    partition> modify
    
  7. 将磁盘全部设置为浮动片 (free hog slice)。


    Choose base (enter number) [0]? 1
    

    有关浮动片 (free hog slice) 的更多信息,请参见使用浮动片 (free hog slice)

  8. 在提示继续时应答 yes 创建新分区表。


    Do you wish to continue creating a new partition
    
    table based on above table[yes]? yes
    
  9. 出现提示时,标识浮动 (free hog) 分区(片)和片大小。

    添加系统磁盘时,必须为以下项设置片:

    • 根文件系统(片 0)和交换区域(片 1)和/或

    • /usr(片 6)

    标识片后,将显示新的分区表。

  10. 通过在出现提示时应答 yes,使显示的分区表成为当前分区表。


    Okay to make this the current partition table[yes]? yes
    

    如果不需要当前分区表但希望对其进行更改,请应答 no 并转至步骤 6

  11. 命名分区表。


    Enter table name (remember quotes): "partition-name"
    

    其中 partition-name 是新分区表的名称。

  12. 在新磁盘上完成片的分配后,用新分区表标记磁盘。


    Ready to label disk, continue? yes
    
  13. 退出 partition 菜单。


    partition> quit
    
  14. 检验新的磁盘标号。


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


    format> quit
    
创建磁盘片和标记磁盘之后

创建磁盘片并标记磁盘后,可以在磁盘上创建文件系统。请转至x86: 如何创建文件系统

Procedurex86: 如何创建文件系统

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

  2. 为每个片创建文件系统。


    # newfs /dev/rdsk/cwtxdysz
    

    其中 /dev/rdsk/cwtxdysz 是要创建的文件系统的原始设备。

    有关 newfs 命令的更多信息,请参见第 18 章,创建 UFS、TMPFS 和 LOFS 文件系统(任务)newfs(1M)

  3. 通过挂载新文件系统对其进行检验。


    # mount /dev/dsk/cwtxdysz /mnt
    
    # ls /mnt
    
    lost+found
创建文件系统之后

Procedurex86: 如何在系统磁盘上安装引导块

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

  2. 在系统磁盘上安装引导块。


    # /sbin/installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/cwtxdysz
    
    /boot/grub/stage1

    是分区引导文件。

    /boot/grub/stage2

    是引导块代码。

    /dev/rdsk/cwtxdysz

    是原始设备名称,该名称表示 GRUB 菜单 /boot/grub/menu.lst 在 Solaris 根片上的位置。

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

  3. 通过将系统重新引导到运行级 3,验证是否已安装引导块。


    # init 6
    

示例 14–4 x86: 在系统磁盘上安装引导块

以下示例说明如何在 x86 系统上安装引导块。


# /sbin/installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c1d0s0

stage1 written to partition 0 sector 0 (abs 2016)

stage2 written to to partition 0, 227 sectors starting 50 (abs 2066)