Ignore:
Timestamp:
09/09/13 11:51:53 (12 months ago)
Author:
Kris Moore <kris@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1, releng/10.0.2
Children:
d15dbfc, 4f9718b
Parents:
26599e2
Message:

Add bunch of new functionality to lpreserver

Replace "mirror" with "zpool" sub-cmd, which will allow you to
attach / detach / online / offline / list various zpool drives

  • Important notes *

When attaching a new disk to a zpool, the drive will
be wiped and re-formatted with a 'freebsd-zfs' file-system of the same
size as the first-disk in th zpool array.

If the first disk has a swap partition it will be created also,
but not activated, since advanced users can handle that as the see fit.

Last but not least, GRUB will be stamped on the new disk, making it
bootable should another drive in the array go bad.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src-sh/lpreserver/lpreserver

    r5d99101 r59f367e  
    4747   listsnap - List snapshots of a zpool/dataset 
    4848     mksnap - Create a ZFS snapshot of a zpool/dataset 
    49      mirror - Enable / Disable ZFS mirroring to a local drive 
    5049  replicate - Enable / Disable ZFS replication to a remote system 
    5150 revertsnap - Revert zpool/dataset to a snapshot 
     
    5352        set - Set lpreserver options 
    5453     status - List datasets, along with last snapshot / replication date  
     54      zpool - Mange a zpool by attaching / detaching disks 
    5555__EOF__ 
    5656}; 
    5757 
    58 help_mirror() 
    59 { 
    60  title 
    61  echo "Help mirror 
    62  
    63 Life-Preserver mirror sub-system 
    64  
    65 Mirroring uses ZFS to create a exact copy of your target disk to a new drive, 
    66 such as an external USB disk. When first started the mirror will take a while 
    67 to sync or "resilver". Once this is finished your new disk will be kept in sync 
    68 with the target disk automatically, and can be used as a fall-back disk if the 
    69 primary begins to fail.  
    70  
    71 Should your primary disk fail the mirrored disk can then be used to restore 
    72 the system via the restore option of the PC-BSD installation media.  
    73  
    74 *NOTES*  
    75  
    76 * Mirroring will only work with a non-raidz ZFS pool. If you are using 
    77 raidz you will need to manage disks through the "zpool" command.  
    78  
    79 * The mirror disk must be the same size or larger than the target disk 
     58help_zpool() 
     59{ 
     60 title 
     61 echo "Help zpool 
     62 
     63Life-Preserver zpool sub-system 
     64 
     65The 'zpool' sub-command allows you to attach / detach drives to a zpool,  
     66as well as get status and more.  
     67 
     68When a drive is first attached to a zpool, it will be re-formatted with 
     69a new gpart layout and made bootable with GRUB. For this reason the disk 
     70must be the same size, or larger, than the first array disk SWAP + ZFS 
     71partition size.  
    8072 
    8173Available Flags: 
    82         list - List mirror disks 
    83          add - Add a new mirror disk 
    84       remove - Remove a mirror disk 
    85  
    86 Add Options: 
    87  
    88         add <zpool> <new disk> 
     74        list - List zpool disks 
     75      attach - Attach a new zpool disk 
     76      detach - Remove a zpool disk 
     77     offline - Mark a disk as offline 
     78      online - Mark a disk as being online again 
     79 
     80Attach Options: 
     81 
     82        attach <zpool> <new disk> 
    8983 
    9084        Example 1:  
    9185 
    92         add tank1 /dev/da0 
    93  
    94         Will enable mirroring of the tank1 pool to /dev/da0 
    95  
    96 Remove Options: 
    97  
    98         remove <zpool> <disk> 
     86        attach tank1 /dev/da0 
     87 
     88        Attach the disk /dev/da0 to tank1 pool. The disk will be  
     89        auto-partioned with a SWAP / ZFS partition and made bootable. 
     90 
     91Detach Options: 
     92 
     93        detach <zpool> <disk> 
    9994         
    100         Remove a mirrored disk from the zpool 
    101  
    102         Use 'mirror list' for a list of available disks  
     95        Detach a disk from the zpool 
     96 
     97        Use 'zpool list' for a list of available disks  
     98 
     99Offline Options: 
     100 
     101        offline <zpool> <disk>   
     102         
     103        Mark a disk in the zpool array as 'offline', should be when you 
     104        want to unplug a device, and anticipate plugging it back in later. 
     105 
     106Online Options: 
     107 
     108        online <zpool> <disk>    
     109         
     110        Mark an offline disk in the array as online again. The disk will begin 
     111        to resilver again automatically.  
    103112 
    104113List Options: 
     
    106115        list <zpool> 
    107116         
    108         Lists mirrored disks of a zpool 
    109  
    110 Usage: 
    111  
    112   lpreserver mirror <subcmd> <flags> 
    113  
    114 Example: 
    115  
    116   lpreserver mirror list tank1 
     117        Lists the connected disks of a zpool 
     118 
     119Usage: 
     120 
     121  lpreserver zpool <subcmd> <flags> 
     122 
     123Example: 
     124 
     125  lpreserver zpool list tank1 
    117126" 
    118127}; 
     
    388397           listsnap) help_listsnap ;; 
    389398           revertsnap) help_revertsnap ;; 
    390            mirror) help_mirror ;; 
     399           zpool) help_zpol ;; 
    391400           replicate) help_replicate ;; 
    392401           cronsnap) help_cronsnap ;; 
     
    489498            esac 
    490499         ;; 
    491     mirror) require_root 
     500    zpool) require_root 
    492501            shift 
    493502            case ${1} in 
    494                 add) add_mirror_disk "$2" "$3" ;; 
    495                 list) list_mirror_disks "$2" ;; 
    496                 remove) rem_mirror_disk "$2" "$3" ;; 
    497                 *) help_mirror ;; 
     503                attach) add_zpool_disk "$2" "$3" ;; 
     504                detach) rem_zpool_disk "$2" "$3" ;; 
     505                online) online_zpool_disk "$2" "$3" ;; 
     506               offline) offline_zpool_disk "$2" "$3" ;; 
     507                list) list_zpool_disks "$2" ;; 
     508                *) help_zpool ;; 
    498509            esac 
    499510         ;; 
Note: See TracChangeset for help on using the changeset viewer.