Command to replace Disk

All your general support questions for OpenZFS on OS X.

Command to replace Disk

Postby simonpie » Sun Jul 10, 2016 7:20 am

Hello all,

One drive broke in a mirror and I need to replace it. As I have no other free bay in my macpro, I will shutdown the machine, replace the disk, and then replace it the pool. Only, I am a little bit confused on how to tell zfs to replace the disk. Here is the output of zpool status :

Code: Select all
[laposte:: 11:01] [~] % zpool status
  pool: tank
 state: DEGRADED
status: One or more devices could not be opened.  Sufficient replicas exist for
   the pool to continue functioning in a degraded state.
action: Attach the missing device and online it using 'zpool online'.
   see: http://zfsonlinux.org/msg/ZFS-8000-2Q
  scan: none requested
config:

   NAME                                            STATE     READ WRITE CKSUM
   tank                                            DEGRADED     0     0     0
     mirror-0                                      DEGRADED     0     0     0
       6734521404759107096                         UNAVAIL      0     0     0  was /private/var/run/disk/by-id/media-18B90BE0-2EC5-E540-A7CD-F16A413B49E6
       media-91DF301F-52AC-2947-9952-9BF2B32E7271  ONLINE       0     0     0

errors: No known data errors
[laposte:: 11:02] [~] %


Only, What would be the command to tell zfs to replace the unavailable disk with the new one I will put in the machine, assuming the drive becomes /dev/disk3 ? I find that oracle's page http://docs.oracle.com/cd/E19253-01/819-5461/gazgd/index.html is not helpful when I look at my output.
simonpie
 
Posts: 7
Joined: Thu Feb 04, 2016 9:17 am

Re: Command to replace Disk

Postby lundman » Sun Jul 10, 2016 4:50 pm

Essentially, replace disk, run

diskutil list

and find the new disk, run

zpool status -g
to list the devices by guid

zpool replace tank $GUID_OF_MISSING_DISK /dev/disk$NEWDISK

then export, import -d /var/run/disk/by-id/

would probably work
User avatar
lundman
 
Posts: 1337
Joined: Thu Mar 06, 2014 2:05 pm
Location: Tokyo, Japan

Re: Command to replace Disk

Postby simonpie » Sun Jul 10, 2016 5:03 pm

Thanks for answering.

When you dont need to export and reimport.

Here is the command that I ran :
Code: Select all
sudo zpool replace -f  -o ashift=12 tank 6734521404759107096 /dev/disk1


Where 6734521404759107096 is the guid of the disque that was unavailable and /dev/disk1 is the disk returned by diskutil. The replace command complained, hence I needed to use the -f option. Finally, the man page suggest to use -o ashift as it is not inherited by the pool. So I reused the same parameters that used when I created the pool.
Here some interesting output :

Code: Select all
[laposte:: 20:02] [~] % sudo zpool replace -o ashift=12 tank 6734521404759107096 /dev/disk1
Password:
invalid vdev specification
use '-f' to override the following errors:
/dev/disk1 does not contain an EFI label but it may contain partition
information in the MBR.
[laposte:: 20:06] [~] % sudo zpool replace -f  -o ashift=12 tank 6734521404759107096 /dev/disk1
[laposte:: 20:06] [~] % zpool status
  pool: tank
 state: DEGRADED
status: 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 Sun Jul 10 20:06:25 2016
    11,3M scanned out of 67,6G at 462K/s, 42h35m to go
    11,3M resilvered, 0,02% done
config:

   NAME                                            STATE     READ WRITE CKSUM
   tank                                            DEGRADED     0     0     0
     mirror-0                                      DEGRADED     0     0     0
       replacing-0                                 UNAVAIL      0     0     0
         6734521404759107096                       UNAVAIL      0     0     0  was /private/var/run/disk/by-id/media-18B90BE0-2EC5-E540-A7CD-F16A413B49E6
         disk1                                     ONLINE       0     0     0  (resilvering)
       media-91DF301F-52AC-2947-9952-9BF2B32E7271  ONLINE       0     0     0

errors: No known data errors
[laposte:: 20:06] [~] %


and at the end, without exporting or anything :

Code: Select all
[laposte:: 20:51] [~] % zpool status -v
  pool: tank
 state: ONLINE
  scan: resilvered 67,6G in 0h45m with 0 errors on Sun Jul 10 20:51:44 2016
config:

   NAME                                            STATE     READ WRITE CKSUM
   tank                                            ONLINE       0     0     0
     mirror-0                                      ONLINE       0     0     0
       disk1                                       ONLINE       0     0     0
       media-91DF301F-52AC-2947-9952-9BF2B32E7271  ONLINE       0     0     0

errors: No known data errors
[laposte:: 20:54] [~] %
simonpie
 
Posts: 7
Joined: Thu Feb 04, 2016 9:17 am


Return to General Help

Who is online

Users browsing this forum: No registered users and 25 guests