Oracle Solaris ZFS 管理指南

安装 ZFS 根文件系统(初始安装)

在此 Solaris 发行版中,您可以使用 Solaris 交互式文本安装程序创建包含可引导的 ZFS 根文件系统的 ZFS 存储池来执行初始安装。如果您具有要用于 ZFS 根文件系统的现有 ZFS 存储池,则必须使用 Oracle Solaris Live Upgrade 将现有 UFS 根文件系统迁移到现有 ZFS 存储池中的 ZFS 根文件系统。有关更多信息,请参见将 UFS 根文件系统迁移到 ZFS 根文件系统 (Oracle Solaris Live Upgrade)

如果要在完成 ZFS 根文件系统的初始安装后配置区域,并且计划修补或升级系统,请参见使用 Oracle Solaris Live Upgrade 迁移或升级具有区域的系统 (Solaris 10 10/08)使用 Oracle Solaris Live Upgrade 迁移或升级具有区域的系统(最低Solaris 10 5/09)

如果系统上已经具有 ZFS 存储池,则会通过以下消息确认。然而,这些池保持不动,除非您选择现有池中的磁盘来创建新存储池。


There are existing ZFS pools available on this system.  However, they can only be upgraded 
using the Live Upgrade tools.  The following screens will only allow you to install a ZFS root system, 
not upgrade one.

注意 – 注意 –

如果为新池选择现有池的任何磁盘,则现有池将被销毁。


在开始初始安装以创建 ZFS 存储池之前,请参见ZFS 支持对于 Oracle Solaris 安装和 Oracle Solaris Live Upgrade 的要求


示例 5–1 可引导的 ZFS 根文件系统的初始安装

Solaris 交互式文本安装过程与先前的 Solaris 发行版安装过程基本相同,区别在于系统会提示您创建 UFS 还是 ZFS 根文件系统。在此发行版中,UFS 仍为缺省文件系统。如果选择 ZFS 根文件系统,系统会提示您创建 ZFS 存储池。安装 ZFS 根文件系统的步骤如下:

  1. 选择 Solaris 交互式安装方法,因为 Solaris Flash 安装不可用于创建可引导的 ZFS 根文件系统。但是,您可以创建在 JumpStart 安装期间要使用的 ZFS Flash 归档文件。有关更多信息,请参见安装 ZFS 根文件系统(Oracle Solaris Flash 归档文件安装)

    从 Solaris 10 10/08 发行版开始,只要已安装最低 Solaris 10 10/08 发行版,就可以将 UFS 根文件系统迁移到 ZFS 根文件系统。有关迁移到 ZFS 根文件系统的更多信息,请参见将 UFS 根文件系统迁移到 ZFS 根文件系统 (Oracle Solaris Live Upgrade)

  2. 要创建 ZFS 根文件系统,请选择 ZFS 选项。例如:


    Choose Filesystem Type
    
      Select the filesystem to use for your Solaris installation
    
    
                [ ] UFS
                [X] ZFS
  3. 在选择要安装的软件之后,系统将提示您选择用来创建 ZFS 存储池的磁盘。该屏幕与先前的 Solaris 发行版的屏幕类似。


    Select Disks
    
      On this screen you must select the disks for installing Solaris software.
      Start by looking at the Suggested Minimum field; this value is the
      approximate space needed to install the software you've selected. For ZFS,
      multiple disks will be configured as mirrors, so the disk you choose, or the
      slice within the disk must exceed the Suggested Minimum value.
      NOTE: ** denotes current boot disk
    
      Disk Device                                              Available Space
      =============================================================================
      [X]    c1t0d0                                           69994 MB  (F4 to edit)
      [ ]    c1t1d0                                           69994 MB
      [-]    c1t2d0                                               0 MB
      [-]    c1t3d0                                               0 MB
    
                                      Maximum Root Size:  69994 MB
                                      Suggested Minimum:   8279 MB

    您可以选择一个或多个用于 ZFS 根池的磁盘。如果选择两个磁盘,则会为根池设置镜像双磁盘配置。双磁盘或三磁盘镜像池为最佳。如果您有八个磁盘并选择了所有磁盘,则这八个磁盘将作为一个大的镜像用于根池。此配置并非最佳。还可以选择在完成初始安装后创建镜像根池。不支持对根池的 RAID-Z 池配置。有关配置 ZFS 存储池的更多信息,请参见ZFS 存储池的复制功能

  4. 要选择两个磁盘来创建镜像的根池,请使用光标控制键选择第二个磁盘。在以下示例中,选择了 c1t1d0c1t2d0 用作根池磁盘。这两个磁盘都必须具有 SMI 标签和分片 0。如果磁盘没有 SMI 标签或不包含分片,则必须退出安装程序,使用 format 实用程序对磁盘重新进行标记和分区,然后重新启动安装程序。


    Select Disks
    
      On this screen you must select the disks for installing Solaris software.
      Start by looking at the Suggested Minimum field; this value is the
      approximate space needed to install the software you've selected. For ZFS,
      multiple disks will be configured as mirrors, so the disk you choose, or the
      slice within the disk must exceed the Suggested Minimum value.
      NOTE: ** denotes current boot disk
    
      Disk Device                                              Available Space
      =============================================================================
      [X]    c1t0d0                                           69994 MB  
      [X]    c1t1d0                                           69994 MB  (F4 to edit)
      [-]    c1t2d0                                               0 MB
      [-]    c1t3d0                                               0 MB
    
                                      Maximum Root Size:  69994 MB
                                      Suggested Minimum:   8279 MB

    如果可用空间栏显示 0 MB,则该磁盘很有可能具有 EFI 标签。如果您想使用带 EFI 标签的磁盘,则需要退出安装程序,使用 format -e 命令用 SMI 标签重新标记该磁盘,然后重新启动安装程序。

    如果在安装期间没有创建镜像根池,您可以在安装之后轻松创建。有关信息,请参见如何创建镜像根池(安装后)

  5. 为 ZFS 存储池选择了一个或多个磁盘后,将出现一个屏幕,显示类似如下的内容:


    Configure ZFS Settings
    
      Specify the name of the pool to be created from the disk(s) you have chosen.
      Also specify the name of the dataset to be created within the pool that is
      to be used as the root directory for the filesystem.
    
                  ZFS Pool Name: rpool                                   
          ZFS Root Dataset Name: s10s_u9wos_08
          ZFS Pool Size (in MB): 69995
      Size of Swap Area (in MB): 2048
      Size of Dump Area (in MB): 1536
            (Pool size must be between 6231 MB and 69995 MB)
    
                             [X] Keep / and /var combined
                             [ ] Put /var on a separate dataset

    在此屏幕中,您可以通过在各项之间移动光标控制键,然后使用新值替换缺省值来更改 ZFS 池名称、数据集名称、池大小以及交换和转储设备大小。或者,您可以接受缺省值。另外,您可以修改创建和挂载 /var 文件系统的方式。

    在此示例中,根数据集名称更改为 zfsBE


                  ZFS Pool Name: rpool
          ZFS Root Dataset Name: zfsBE                                   
          ZFS Pool Size (in MB): 69995
      Size of Swap Area (in MB): 2048
      Size of Dump Area (in MB): 1536
            (Pool size must be between 6231 MB and 69995 MB)
    
                             [X] Keep / and /var combined
                             [ ] Put /var on a separate dataset
  6. 您可以在此最后的安装屏幕中更改安装配置文件。例如:


    Profile
    
      The information shown below is your profile for installing Solaris software.
      It reflects the choices you've made on previous screens.
    
      ============================================================================
    
                    Installation Option: Initial
                            Boot Device: c1t0d0
                  Root File System Type: ZFS
                        Client Services: None
    
                                Regions: North America
                          System Locale: C ( C )
    
                               Software: Solaris 10, Entire Distribution
                              Pool Name: rpool
                  Boot Environment Name: zfsBE
                              Pool Size: 69995 MB
                        Devices in Pool: c1t0d0
                                         c1t1d0
  7. 安装完成后,查看生成的 ZFS 存储池和文件系统信息。例如:


    # zpool status
      pool: rpool
     state: ONLINE
     scrub: none requested
    config:
    
            NAME          STATE     READ WRITE CKSUM
            rpool         ONLINE       0     0     0
              mirror-0    ONLINE       0     0     0
                c1t0d0s0  ONLINE       0     0     0
                c1t1d0s0  ONLINE       0     0     0
    
    errors: No known data errors
    # zfs list
    NAME                USED  AVAIL  REFER  MOUNTPOINT
    rpool              8.03G  58.9G    96K  /rpool
    rpool/ROOT         4.47G  58.9G    21K  legacy
    rpool/ROOT/zfsBE   4.47G  58.9G  4.47G  /
    rpool/dump         1.50G  58.9G  1.50G  -
    rpool/export         44K  58.9G    23K  /export
    rpool/export/home    21K  58.9G    21K  /export/home
    rpool/swap         2.06G  61.0G    16K  -

    zfs list 输出样例标识了根池组件,例如 rpool/ROOT 目录,该目录在缺省情况下不可访问。

  8. 要在同一存储池中创建其他 ZFS 引导环境 (boot environment, BE),可以使用 lucreate 命令。在以下示例中,创建了名为 zfs2BE 的新 BE。当前 BE 命名为 zfsBE,如 zfs list 输出所示。但是,lustatus 输出不会确认当前 BE,直到新 BE 创建完成。


    # lustatus
    ERROR: No boot environments are configured on this system
    ERROR: cannot determine list of all boot environment names

    如果在同一池中创建新 ZFS BE,请使用类似如下的语法:


    # lucreate -n zfs2BE
    INFORMATION: The current boot environment is not named - assigning name <zfsBE>.
    Current boot environment is named <zfsBE>.
    Creating initial configuration for primary boot environment <zfsBE>.
    The device </dev/dsk/c1t0d0s0> is not a root device for any boot environment; cannot get BE ID.
    PBE configuration successful: PBE name <zfsBE> PBE Boot Device </dev/dsk/c1t0d0s0>.
    Comparing source boot environment <zfsBE> file systems with the file 
    system(s) you specified for the new boot environment. Determining which 
    file systems should be in the new boot environment.
    Updating boot environment description database on all BEs.
    Updating system configuration files.
    Creating configuration for boot environment <zfs2BE>.
    Source boot environment is <zfsBE>.
    Creating boot environment <zfs2BE>.
    Cloning file systems from boot environment <zfsBE> to create boot environment <zfs2BE>.
    Creating snapshot for <rpool/ROOT/zfsBE> on <rpool/ROOT/zfsBE@zfs2BE>.
    Creating clone for <rpool/ROOT/zfsBE@zfs2BE> on <rpool/ROOT/zfs2BE>.
    Setting canmount=noauto for </> in zone <global> on <rpool/ROOT/zfs2BE>.
    Population of boot environment <zfs2BE> successful.
    Creation of boot environment <zfs2BE> successful.

    在同一池内创建 ZFS BE 时,使用 ZFS 克隆和快照功能可立即创建 BE。有关使用 Oracle Solaris Live Upgrade 进行 ZFS 根迁移的更多详细信息,请参见将 UFS 根文件系统迁移到 ZFS 根文件系统 (Oracle Solaris Live Upgrade)

  9. 接下来,验证新引导环境。例如:


    # lustatus
    Boot Environment           Is       Active Active    Can    Copy      
    Name                       Complete Now    On Reboot Delete Status    
    -------------------------- -------- ------ --------- ------ ----------
    zfsBE                      yes      yes    yes       no     -         
    zfs2BE                     yes      no     no        yes    -        
    # zfs list
    NAME                      USED  AVAIL  REFER  MOUNTPOINT
    rpool                    8.03G  58.9G    97K  /rpool
    rpool/ROOT               4.47G  58.9G    21K  legacy
    rpool/ROOT/zfs2BE         116K  58.9G  4.47G  /
    rpool/ROOT/zfsBE         4.47G  58.9G  4.47G  /
    rpool/ROOT/zfsBE@zfs2BE  75.5K      -  4.47G  -
    rpool/dump               1.50G  58.9G  1.50G  -
    rpool/export               44K  58.9G    23K  /export
    rpool/export/home          21K  58.9G    21K  /export/home
    rpool/swap               2.06G  61.0G    16K  -
  10. 要从备用 BE 引导,请使用 luactivate 命令。在基于 SPARC 的系统上激活 BE 后,如果引导设备包含 ZFS 存储池,请使用 boot - L 命令确定可用 BE。从基于 x86 的系统引导时,请从 GRUB 菜单中确定要引导的 BE。

    例如,在基于 SPARC 的系统上,可使用 boot - L 命令显示可用的 BE 列表。要从新 BE zfs2BE 引导,请选择选项 2。然后,键入显示的 boot -Z 命令。


    ok boot -L
    Executing last command: boot -L                                       
    Boot device: /pci@7c0/pci@0/pci@1/pci@0,2/LSILogic,sas@2/disk@0  File and args: -L
    1 zfsBE
    2 zfs2BE
    Select environment to boot: [ 1 - 2 ]: 2
    
    To boot the selected entry, invoke:
    boot [<root-device>] -Z rpool/ROOT/zfs2BE
    ok boot -Z rpool/ROOT/zfs2BE
    

有关引导 ZFS 文件系统的更多信息,请参见从 ZFS 根文件系统引导


Procedure如何创建镜像根池(安装后)

如果在安装期间没有创建 ZFS 镜像根池,您可以在安装之后轻松创建。

有关替换根池中的磁盘的信息,请参见如何替换 ZFS 根池中的磁盘

  1. 显示当前根池的状态。


    # zpool status rpool
      pool: rpool
     state: ONLINE
     scrub: none requested
    config:
    
            NAME        STATE     READ WRITE CKSUM
            rpool       ONLINE       0     0     0
              c1t0d0s0  ONLINE       0     0     0
    
    errors: No known data errors
  2. 附加第二个磁盘,以配置镜像根池。


    # zpool attach rpool c1t0d0s0 c1t1d0s0
    Please be sure to invoke installboot(1M) to make 'c1t1d0s0' bootable.
    Make sure to wait until resilver is done before rebooting.
  3. 查看根池状态,确认重新同步已完成。


    # zpool status rpool
      pool: rpool
     state: ONLINE
    status: One or more devices is currently being resilvered.  The pool will
            continue to function, possibly in a degraded state.
    action: Wait for the resilver to complete.
     scrub: resilver in progress for 0h1m, 24.26% done, 0h3m to go
    config:
    
            NAME          STATE     READ WRITE CKSUM
            rpool         ONLINE       0     0     0
              mirror-0    ONLINE       0     0     0
                c1t0d0s0  ONLINE       0     0     0
                c1t1d0s0  ONLINE       0     0     0  3.18G resilvered
    
    errors: No known data errors

    在上面的输出中,重新同步过程未完成。当您看到类似如下的消息时,说明重新同步已完成。


    scrub: resilver completed after 0h10m with 0 errors on Thu Mar 11 11:27:22 2010
  4. 重新同步完成后,对第二个磁盘应用根块。


    sparc# installboot -F zfs /usr/platform/`uname -i`/lib/fs/zfs/bootblk /dev/rdsk/c1t1d0s0
    

    x86# installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c1t1d0s0
    
  5. 验证您是否可以从第二个磁盘成功引导。

  6. 通过使用 SPARC 引导 PROM 中的 eeprom 命令和 setenv 命令,将系统设置为从新磁盘自动引导,或者重新配置 PC BIOS。