Welcome 微信登录

首页 / 操作系统 / Linux / Solaris zfs 更换根池磁盘 (Replace a Disk in the ZFS Root Pool)

某些时候,由于空间不足或是硬件故障等原因,我们需要更换启动磁盘。

冗余池(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.  
  4. # zpool status
  5. pool: rpool
  6. state: ONLINE
  7. status: One or more devices is currently being resilvered. The pool will
  8. continue to function, possibly in a degraded state.
  9. action: Wait for the resilver to complete.
  10. scan: resilver in progress since Wed Jul 24 15:39:51 2013
  11. 302M scanned out of 7.47G at 11.2M/s, 0h10m to go
  12. 269M resilvered, 3.95% done
  13. config:
  14. NAME STATE READ WRITE CKSUM
  15. rpool ONLINE 0 0 0
  16. mirror-0 ONLINE 0 0 0
  17. c0d0s0 ONLINE 0 0 0
  18. c0d2s0 ONLINE 0 0 0 (resilvering)
  19. 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
至此为止,大功告成。<!-- 管理员在2009年8月13日编辑了该文章文章。 -->如何在Linux Mint 16中正确安装Ubuntu OneLinux系统使用yum仓库出现的错误总结相关资讯      Solaris  Solaris ZFS 
  • VMware虚拟机安装x86架构的Solaris  (今 14:25)
  • Oracle Solaris本地安全漏洞(CVE-  (07/17/2015 08:32:02)
  • Oracle Solaris 远程安全漏洞(CVE-  (10/17/2014 17:12:43)
  • Oracle Sun Solaris 本地安全漏洞(  (04月22日)
  • Solaris系统配置IPMP教程(基于IP  (12/04/2014 13:40:32)
  • Oracle Solaris 11.2 正式发布下载  (08/06/2014 12:03:33)
本文评论 查看全部评论 (0)
表情: 姓名: 字数