Browse Ask a Question
 
Tools
Rss Categories

How to rebuild Geom mirror in FreeBSD

Reference Number: AA-00102 Views: 1949 Created: 2010-07-30 13:45 Last Updated: 2010-07-30 13:46 50 Rating/ 2 Voters

This article discusses how to rebuild a Geom mirror after a faulty drive has been replaced.

Root Privileges Required

All commands listed in this article need to be executed with root privileges.

Step 1 - Identify Replaced Drive

  1. Log in to your server and as root run the following command:
    # gmirror list
  2. This will produce output similar to the following
    Geom name: gm0
    State: DEGRADED
    Components: 2
    Balance: round-robin
    Slice: 4096
    Flags: NONE
    GenID: 0
    SyncID: 3
    ID: 3594034660
    Providers:
    1. Name: mirror/gm0
       Mediasize: 159999999488 (149G)
       Sectorsize: 512
       Mode: r2w2e5
    Consumers:
    1. Name: ad4
       Mediasize: 160000000000 (149G)
       Sectorsize: 512
       Mode: r1w1e1
       State: ACTIVE
       Priority: 0
       Flags: DIRTY
       GenID: 0
       SyncID: 3
       ID: 4064102945

    In this example we can see the status of the mirror is degraded and the only active drive is 'ad4'.

  3. To find out which drives are available and the corresponding device name run the atacontrol list command.
    # atacontrol list

    This will produce a list of drives with device names which are connected to your server.

    ATA channel 2:
        Master:  ad4 <WDC WD1602ABKS-18N8A0/02.03B04> SATA revision 2.x
        Slave:       no device present
    ATA channel 3:
        Master:  ad6 <WDC WD2502ABYS-02B7A0/02.03B03> SATA revision 2.x
        Slave:       no device present

    From this we can see that device '*ad6*' is the device name of the new drive we can use to rebuild the mirror. You should already be aware of the device name from alerts generated by your server when the drive failed; the replacement drive will show up with the same device name.

Step 2 - Rebuild Mirror

  1. Now that we have verified device name of the new drive we can easily rebuild the array using the following commands:
    # gmirror forget gm0
    # gmirror insert gm0 <device>

    Where <device> is the device name of the new drive we determined above. In the example above <device> would be 'ad6'.

  2. To verify the drive has been added to the mirror and the mirror is being rebuild run the '*gmirror list'* command.
    # gmirror list
    Geom name: gm0
    State: DEGRADED
    Components: 2
    Balance: round-robin
    Slice: 4096
    Flags: NONE
    GenID: 0
    SyncID: 3
    ID: 3594034660
    Providers:
    1. Name: mirror/gm0
       Mediasize: 159999999488 (149G)
       Sectorsize: 512
       Mode: r3w2e5
    Consumers:
    1. Name: ad4
       Mediasize: 160000000000 (149G)
       Sectorsize: 512
       Mode: r1w1e1
       State: ACTIVE
       Priority: 0
       Flags: NONE
       GenID: 0
       SyncID: 3
       ID: 4064102945
    2. Name: ad6
       Mediasize: 251059544064 (234G)
       Sectorsize: 512
       Mode: r1w1e1
       State: SYNCHRONIZING
       Priority: 0
       Flags: DIRTY, SYNCHRONIZING
       GenID: 0
       SyncID: 3
       Synchronized: 3%
       ID: 2247886846

    We can see here the new drive has been added and the mirror is being rebuilt (3% complete). Rebuild times can take anywhere from 20 minutes to a few hours depending on the size of the drives and the amount of application I/O on your system.

    The first few lines show that overall state of the mirror, once the state changes from 'DEGRADED' to 'COMPLETE' the rebuild is complete.

Info Ask a Question