歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Solaris zfs 更換根池磁盤 (Replace a Disk in the ZFS Root Pool)

Solaris zfs 更換根池磁盤 (Replace a Disk in the ZFS Root Pool)

日期:2017/2/28 14:36:42   编辑:Linux教程
某些時候,由於空間不足或是硬件故障等原因,我們需要更換啟動磁盤。

冗余池(mirrored pool)

在一個鏡像池裡面更遠硬盤相對簡單一些,只需要用replace命令直接更換硬盤即可。
  1. # zpool offline rpool c1t0d0s0
  2. # cfgadm -c unconfigure c1::dsk/c1t0d0
  3. <Physically remove failed disk c1t0d0>
  4. <Physically insert replacement disk c1t0d0>
  5. # cfgadm -c configure c1::dsk/c1t0d0
  6. # zpool replace rpool c1t0d0s0
  7. # zpool online rpool c1t0d0s0
  8. # zpool status rpool
  9. <Let disk resilver before installing the boot blocks>
  10. SPARC# installboot -F zfs /usr/platform/`uname -i`/lib/fs/zfs/bootblk /dev/rdsk/c1t0d0s0
  11. x86# installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c1t9d0s0

非冗余池

如果根池不是mirrored,那麼就需要先把新磁盤分區好,加入根池形成mirrored類型的池。

加入新盤並檢測

# devfsadm

分區並打標簽

  1. # format -e c8t1d0
  2. format> partition
  3. SELECT ONE OF THE FOLLOWING:
  4. 1. Create a partition
  5. ...
  6. partition> print
  7. Current partition table (original):
  8. Total disk cylinders available: 30398 + 2 (reserved cylinders)
  9. Part Tag Flag Cylinders Size Blocks
  10. 0 root wm 1 - 30396 232.85GB (30396/0/0) 488311740
  11. 1 unassigned wu 0 0 (0/0/0) 0
  12. 2 backup wu 0 - 30396 232.85GB (30397/0/0) 488327805
  13. 3 unassigned wu 0 0 (0/0/0) 0
  14. 4 unassigned wu 0 0 (0/0/0) 0
  15. 5 unassigned wu 0 0 (0/0/0) 0
  16. 6 unassigned wu 0 0 (0/0/0) 0
  17. 7 unassigned wu 0 0 (0/0/0) 0
  18. 8 boot wu 0 - 0 7.84MB (1/0/0) 16065
  19. 9 unassigned wu 0 0 (0/0/0) 0
  20. partition>quit
  21. format> label
  22. [0] SMI Label
  23. [1] EFI Label
  24. Specify Label type[0]: 0
  25. Ready to label disk, continue? y

添加磁盤

現在把做好的新磁盤分區加入根池形成鏡像池,這一步裡數據的同步可能會花費比較長的時間
  1. # zpool attach rpool c0d0s0 c0d2s0
  2. Make sure to wait until resilver is done before rebooting.
  3. # zpool status
  4. pool: rpool
  5. state: ONLINE
  6. status: One or more devices is currently being resilvered. The pool will
  7. continue to function, possibly in a degraded state.
  8. action: Wait for the resilver to complete.
  9. scan: resilver in progress since Wed Jul 24 15:39:51 2013
  10. 302M scanned out of 7.47G at 11.2M/s, 0h10m to go
  11. 269M resilvered, 3.95% done
  12. config:
  13. NAME STATE READ WRITE CKSUM
  14. rpool ONLINE 0 0 0
  15. mirror-0 ONLINE 0 0 0
  16. c0d0s0 ONLINE 0 0 0
  17. c0d2s0 ONLINE 0 0 0 (resilvering)
  18. errors: No known data errors

安裝啟動塊

On a SPARC based system:
# installboot -F zfs /usr/platform/`uname -i`/lib/fs/zfs/bootblk /dev/rdsk/c1t9d0s0
On an x86 based system:
# installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c1t9d0s0

驗證boot

首先查看boot path
  1. # prtconf -vp|grep -i bootpath
  2. bootpath: '/virtual-devices@100/channel-devices@200/disk@0:a'
可以推斷出新盤path的末尾是disk@2:a,然後啟動
  1. {0} ok setenv boot-device /virtual-devices@100/channel-devices@200/disk@2:a
    boot-device = /virtual-devices@100/channel-devices@200/disk@2:a
    {0} ok printenv boot-device
    boot-device = /virtual-devices@100/channel-devices@200/disk@2:a
  2. ok boot /virtual-devices@100/channel-devices@200/disk@2:a

移除老磁盤

  1. # zpool detach rpool c0d0s0

擴展池空間

由於之前的磁盤空間小於新盤,所以現在的空間是和之前一樣的,需要擴展一下。
  1. # zpool set autoexpand=on rpool
至此為止,大功告成。
Copyright © Linux教程網 All Rights Reserved