Solaris zfs更換根池磁碟(Replace a Disk in the ZFS Root Pool) 某些時候,由於空間不足或是硬體故障等原因,我們需要更換啟動磁碟。 冗餘池(mirrored pool)在一個鏡像池裡面更遠硬碟相對簡單一些,只需要用replace命令直接更換硬碟即可。# zpool offline rpool c1t0d0s0# cfgadm -c unconfigure c1::dsk/c1t0d0<Physically remove failed disk c1t0d0><Physically insert replacement disk c1t0d0># cfgadm -c configure c1::dsk/c1t0d0# zpool replace rpool c1t0d0s0# zpool online rpool c1t0d0s0# zpool status rpool<Let disk resilver before installing the boot blocks>SPARC# installboot -F zfs /usr/platform/`uname -i`/lib/fs/zfs/bootblk /dev/rdsk/c1t0d0s0x86# installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c1t9d0s0 非冗餘池如果根池不是mirrored,那麼就需要先把新磁碟分割好,加入根池形成mirrored類型的池。加入新盤並檢測# devfsadm 分區並打標籤# format -e c8t1d0 format> partitionSELECT ONE OF THE FOLLOWING: 1. Create a partition... partition> printCurrent partition table (original):Total disk cylinders available: 30398 + 2 (reserved cylinders) Part Tag Flag Cylinders Size Blocks 0 root wm 1 - 30396 232.85GB (30396/0/0) 488311740 1 unassigned wu 0 0 (0/0/0) 0 2 backup wu 0 - 30396 232.85GB (30397/0/0) 488327805 3 unassigned wu 0 0 (0/0/0) 0 4 unassigned wu 0 0 (0/0/0) 0 5 unassigned wu 0 0 (0/0/0) 0 6 unassigned wu 0 0 (0/0/0) 0 7 unassigned wu 0 0 (0/0/0) 0 8 boot wu 0 - 0 7.84MB (1/0/0) 16065 9 unassigned wu 0 0 (0/0/0) 0partition>quit format> label[0] SMI Label[1] EFI LabelSpecify Label type[0]: 0Ready to label disk, continue? y添加磁碟現在把做好的新磁碟分割加入根池形成鏡像池,這一步裡資料的同步可能會花費比較長的時間# zpool attach rpool c0d0s0 c0d2s0Make sure to wait until resilver is done before rebooting. # zpool status pool: rpool state: ONLINEstatus: 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. scan: resilver in progress since Wed Jul 24 15:39:51 2013 302M scanned out of 7.47G at 11.2M/s, 0h10m to go 269M resilvered, 3.95% doneconfig: NAME STATE READ WRITE CKSUM rpool ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 c0d0s0 ONLINE 0 0 0 c0d2s0 ONLINE 0 0 0 (resilvering) errors: No known data errors安裝啟動塊On a SPARC based system:# installboot -F zfs /usr/platform/`uname -i`/lib/fs/zfs/bootblk /dev/rdsk/c1t9d0s0On an x86 based system:# installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c1t9d0s0 驗證boot首先查看boot path# prtconf -vp|grep -i bootpath bootpath: '/virtual-devices@100/channel-devices@200/disk@0:a'可以推斷出新盤path的末尾是disk@2:a,然後啟動{0} ok setenv boot-device /virtual-devices@100/channel-devices@200/disk@2:aboot-device = /virtual-devices@100/channel-devices@200/disk@2:a{0} ok printenv boot-deviceboot-device = /virtual-devices@100/channel-devices@200/disk@2:a ok boot /virtual-devices@100/channel-devices@200/disk@2:a移除老磁碟# zpool detach rpool c0d0s0擴充池空間由於之前的磁碟空間小於新盤,所以現在的空間是和之前一樣的,需要擴充一下。# zpool set autoexpand=on rpool至此為止,大功告成。