www. On IT Road .com

对于 x86/x64 硬件

对于 x86/x64 硬件,我们需要为磁盘更换执行一些另外的步骤。
首先,我们需要使用 fdisk 创建一个新分区,然后才能从磁盘 c1t1d0 复制 VTOC 表。

# fdisk -b /usr/lib/fs/ufs/mboot /dev/rdsk/c1t0d0p0
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

其次,我们需要在新磁盘上安装 grub 而不是 bootblk。

# /sbin/installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c1t0d0s0
在 Solaris Volume Manager (SVM) 下如何更换出现故障的root磁盘

本文演示了在 Solaris 卷管理器下替换故障根磁盘的一些示例。
请注意,出现故障的根磁盘处于镜像配置下。

更换出现故障的根磁盘

考虑如下所示的镜像根磁盘配置,其中包含根和交换镜像以及子镜像。
如图所示,磁盘 c1t0d0 发生故障,导致根和交换子镜像(d11 和 d1)处于维护状态。

# metastat -c
d10              m  6.0GB d11 (maint) d12         --- swap
    d11          s  6.0GB c1t0d0s1 (maint)
    d12          s  6.0GB c1t1d0s1
d0               m  74GB d1 (maint) d2            --- root
    d1           s  74GB c1t0d0s0 (maint)
    d2           s  74GB c1t1d0s0
  1. 首先要拆下维修状态的副镜。
    使用 metadetach 命令分离失败的子镜像:

语法 :

# metadetach [mirror] [sub-mirror]

分离子镜像 d11 和 d1 :

# metadetach d10 d11
# metadetach d0 d1
  1. 接下来是删除故障磁盘上的所有元数据库。
    检查系统中配置的元数据库。
# metadb
        flags           first blk       block count
     a        u         16              8192            /dev/dsk/c1t0d0s7
     a        u         8208            8192            /dev/dsk/c1t0d0s7
     a        u         16400           8192            /dev/dsk/c1t0d0s7
     a        u         16              8192            /dev/dsk/c1t1d0s7
     a        u         8208            8192            /dev/dsk/c1t1d0s7
     a        u         16400           8192            /dev/dsk/c1t1d0s7

如上所示,删除 c1t0d0s7 切片上的 3 个元数据库。

# metadb -d c1t0d0s7
  1. 我们需要先从操作系统中移除磁盘,然后再从服务器中物理移除它。
    请参阅以下帖子以使用 cfgadm 或者 luxadm 删除磁盘。

如何使用 luxadm 和 cfgadm 删除故障磁盘

  1. 现在添加新磁盘并运行 devfsadm 扫描新添加的磁盘。
# devfsadm
  1. 一旦检测到磁盘,我们需要使用 fmthard 命令将 VTOC 表从 c1t0d0 复制到新添加的磁盘:
# prtvtoc /dev/rdsk/c1t0d0s2 | fmthard -s - /dev/rdsk/c1t1d0s2
   fmthard:  New volume table of contents now in place.
  1. 在新磁盘的分片 0 上安装 bootblk。
# installboot /usr/platform/sun4u/lib/fs/ufs/bootblk /dev/rdsk/c1t1d0s0
  1. 添加我们删除的元数据库。
# metadb -afc 3 c1t0d0s7
  1. 更新 SVM 数据库中的设备 ID。
# metadevadm -u c1t0d0
   Updating Solaris Volume Manager device relocation information for c1t0d0
   Old device reloc information:
       id1,sd@n5000cca000368d24
   New device reloc information:
       id1,sd@n5000c500052fb987
  1. 使用 metaattach 命令连接分离子镜。

语法 :

# metattach [mirror] [submirror]

这将启动重新同步子镜像。

# metattach d10 d11
# metattach d0 d1
  1. 如果我们没有在步骤 1 中分离子镜,请运行 metereplace 命令开始同步,这将使子镜返回到“好的”状态:
# metareplace -e d0  c1t0d0s0
   d0: device c1t0d0s0 is enabled
# metareplace -e d10  c1t0d0s1
   d10: device c1t0d0s1 is enabled
  1. 要检查同步状态,请使用 metastat -c 命令:
# metastat -c
d10              m  6.0GB d11 (resync-53%) d12
    d11          s  6.0GB c1t0d0s1
    d12          s  6.0GB c1t1d0s1
d0               m  74GB d1 (resync-27%) d2
    d1           s  74GB c1t0d0s0
    d2           s  74GB c1t1d0s0

要每 10 秒持续检查一次同步状态,请使用:

# while true; do metastat | grep done; sleep 10; done
日期:2020-09-17 00:15:12 来源:oir作者:oir