ZFS: replace a dead disk in a pool

[root@pr0nserv ~]# zpool status
  pool: pr0nserv
 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://www.sun.com/msg/ZFS-8000-D3
 scrub: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        pr0nserv    DEGRADED     0     0     0
          mirror    ONLINE       0     0     0
            ad4     ONLINE       0     0     0
            ad6     ONLINE       0     0     0
          mirror    DEGRADED     0     0     0
            ad8     UNAVAIL      0     0     0  cannot open
            ad10    ONLINE       0     0     0

errors: No known data errors

Put the disk offline:

[root@pr0nserv ~]# zpool offline pr0nserv ad8
[root@pr0nserv ~]# zpool status
  pool: pr0nserv
 state: DEGRADED
status: One or more devices has been taken offline by the administrator.
        Sufficient replicas exist for the pool to continue functioning in a
        degraded state.
action: Online the device using 'zpool online' or replace the device with
        'zpool replace'.
 scrub: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        pr0nserv    DEGRADED     0     0     0
          mirror    ONLINE       0     0     0
            ad4     ONLINE       0     0     0
            ad6     ONLINE       0     0     0
          mirror    DEGRADED     0     0     0
            ad8     OFFLINE      0     0     0
            ad10    ONLINE       0     0     0

errors: No known data errors

Power off, replace the faulty disk (i use to put a small label on disks so i know immediately which one is dead).
Restart and “replace” the disk in the ZFS pool:

[root@pr0nserv ~]# zpool replace pr0nserv ad8
[root@pr0nserv ~]# zpool status
  pool: pr0nserv
 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.
 scrub: resilver in progress for 0h0m, 0.00% done, 5h18m to go
config:

        NAME           STATE     READ WRITE CKSUM
        pr0nserv       DEGRADED     0     0     0
          mirror       ONLINE       0     0     0
            ad4        ONLINE       0     0     0
            ad6        ONLINE       0     0     0
          mirror       DEGRADED     0     0     0
            replacing  DEGRADED     0     0     0
              ad8/old  OFFLINE      0     0     0
              ad8      ONLINE       0     0     0  4.62M resilvered
            ad10       ONLINE       0     0     0

errors: No known data errors

FreeBSD: add or remove an user to a group

If you need to add an user to an existing group, or more than one, do:

pw usermod username -G group1,group2,group3

Remember that the user will be inserted ONLY in the groups that you have specified in the grouplist. If your user is in the wheel group and you do a -G ftp,games he’ll be removed from wheel and you’ll not be able to su- to root.

If you need to create a group:

pw groupadd groupname

If you need to see the users of a group:

pw groupshow groupname

If you need to remove an user from a group (for example, group2) you have to set a new list of groups and you’ve to know in which groups the user is currently:

id -Gn username
pw usermod username -G group1,group3