2016年1月7日 星期四

ZFS boot disk 更換成較大容量的硬碟


在有些時候我們需要更換開機硬碟,或是既有硬碟容量太小,欲更換成較大的硬碟,ZFS 與過去UFS的做法有些不同,UFS常用的方法為ufsdump 跟ufsrestore方式,而ZFS使用mirror操作,更為快速及方便。

使用設備Oracle SPARC T3-2,開機硬碟為146GB硬碟,欲改成300GB硬碟


檢視目前機器內的硬碟: 
AVAILABLE DISK SELECTIONS:
       0. c0t5000C5000EBDE997d0 <SUN146G cyl 14087 alt 2 hd 24 sec 848>
          /scsi_vhci/disk@g5000c5000ebde997/dev/chassis//SYS/SASBP/HDD0/disk
       1. c0t5000C50039BD744Bd0 <SEAGATE-ST930003SSUN300G-0B70 cyl 46873 alt 2 hd 20      sec 625> /scsi_vhci/disk@g5000c50039bd744b/dev/chassis//SYS/SASBP/HDD1/disk


檢示zpool 狀態
# zpool statu tus -v
  pool: rpool
 state: ONLINE
  scan: resilvered 70.0G in 0h18m with 0 errors on Tue Oct 27 13:08:53 2015
config:

        NAME                       STATE     READ WRITE CKSUM
        rpool                      ONLINE       0     0     0
          c0t5000C5000EBDE997d0s6  ONLINE       0     0     0

檢示磁區狀態  (現為146GB)
# df -h
Filesystem             Size   Used  Available Capacity  Mounted on
rpool/ROOT/solaris     134G   2.1G        62G     4%    /
/devices                 0K     0K         0K     0%    /devices



將第二顆硬碟(300GB)與開機硬碟mirror
# zpool attach -f rpool c0t5000C5000EBDE997d0s6 c0t5000C50039BD744

檢視mirror進度,須等兩顆資料同步後100%再行拆開
# zpool status -v
  pool: rpool
 state: DEGRADED
status: One or more devices is currently being resilvered.  The pool will
        continue to function in a degraded state.
action: Wait for the resilver to complete.
  scan: resilver in progress since Tue Oct 27 14:44:52 2015
    4.10G scanned out of 70.0G at 45.2M/s, 0h24m to go
    4.10G resilvered, 5.86% done
config:

        NAME                         STATE     READ WRITE CKSUM
        rpool                        DEGRADED     0     0     0
          mirror-0                   DEGRADED     0     0     0
            c0t5000C5000EBDE997d0s6  ONLINE       0     0     0
            c0t5000C50039BD744Bd0s6  DEGRADED     0     0     0  (resilvering)

device details:

        c0t5000C50039BD744Bd0s6    DEGRADED       scrub/resilver needed
        status: ZFS detected errors on this device.
                The device is missing some data that is recoverable.
           see: http://support.oracle.com/msg/ZFS-8000-QJ for recovery


errors: No known data errors

Mirror 完成
# zpool status -v
  pool: rpool
 state: ONLINE
  scan: resilvered 70.0G in 0h18m with 0 errors on Tue Oct 27 15:03:07 2015
config:

        NAME                         STATE     READ WRITE CKSUM
        rpool                        ONLINE       0     0     0
          mirror-0                   ONLINE       0     0     0
            c0t5000C5000EBDE997d0s6  ONLINE       0     0     0
            c0t5000C50039BD744Bd0s6  ONLINE       0     0     0

errors: No known data errors

建立第二顆硬碟(300GB)開機磁區
# installboot -F zfs /usr/platform/`uname -i`/lib/fs/zfs/bootblk /dev/rdsk/c0t5000C50039BD744Bd0s6
WARNING: target device /dev/rdsk/c0t5000C50039BD744Bd0s6 has a versioned bootblock but no versioning information was provided.
bootblock version installed on /dev/rdsk/c0t5000C50039BD744Bd0s6 is more recent or identical
Use -F to override or install without the -u option

要從第二顆硬碟開機,先將系統下至OK Mode
# init 0

設定好裝置別名,方便開機使用,第一顆命名為rootdisk,第二顆命名為rootmir
{0} ok devalias
screen                   /pci@400/pci@1/pci@0/pci@0/pci@0/display@0
mouse                    /pci@400/pci@1/pci@0/pci@b/pci@0/usb@0,2/hub@2/device@4/mouse@1
rootdisk                 /pci@400/pci@2/pci@0/pci@e/scsi@0/disk@w5000c5000ebde995,0:g
rootmir                  /pci@400/pci@2/pci@0/pci@e/scsi@0/disk@5000c50039bd7449,0:g

由第二顆開啟(300GB)
{0} ok boot rootmir
Boot device: /pci@400/pci@2/pci@0/pci@e/scsi@0/disk@5000c50039bd7449,0:g  File and args:

檢視zpool狀態
# zfspool status -v
  pool: rpool
 state: ONLINE
  scan: resilvered 70.0G in 0h18m with 0 errors on Tue Oct 27 15:03:07 2015
config:

        NAME                         STATE     READ WRITE CKSUM
        rpool                        ONLINE       0     0     0
          mirror-0                   ONLINE       0     0     0
            c0t5000C5000EBDE997d0s6  ONLINE       0     0     0
            c0t5000C50039BD744Bd0s6  ONLINE       0     0     0

將第一顆硬碟(146GB)從rpool 移除
# zpool detach rpool c0t5000C5000EBDE997d0s6

檢視zpool狀態
# zpolol stat -vatus -v
  pool: rpool
 state: ONLINE
  scan: resilvered 70.0G in 0h18m with 0 errors on Tue Oct 27 15:03:07 2015
config:

        NAME                       STATE     READ WRITE CKSUM
        rpool                      ONLINE       0     0     0
          c0t5000C50039BD744Bd0s6  ONLINE       0     0     0

errors: No known data errors

檢示磁區狀態  (變成300GB大小了)
# df -h
Filesystem             Size   Used  Available Capacity  Mounted on
rpool/ROOT/solaris     275G   2.1G       202G     2%    /



沒有留言:

張貼留言