Disk Mirroring Tutorial

The steps for disk mirrorming include intializing, mirroring, unmirroring, remirroring, disabling, and then removing a test device.

  1. Initialize a new test device using:
    disk init name = "test",
    physname = "/usr/new_user/test.dat",
    size=5120

    This inserts the following values into columns of master..sysdevices:

    name  phyname              mirrorname          status
    test  /usr/new_user/test.dat   NULL                  16386

    Status 16386 indicates that the device is a physical device (2, 0x00000002), and any writes are to a UNIX file (16384, 0x00004000). Since the mirrorname column is null, mirroring is not enabled on this device.

  2. Mirror the test device using:
    disk mirror name = "test",
    mirror = "/usr/new_user/test.mir"

    This changes the master..sysdevices columns to:

    name  phyname              mirrorname          status
    test  /usr/new_user/test.dat   /usr/new_user/test.mir  17122

    Status 17122 indicates that mirroring is currently enabled (512, 0x00000200) on this device. Reads are mirrored (128, 0x00000080), and writes are mirrored to a UNIX file device (16384, 0x00004000), the device is mirrored (64, 0x00000040), and serial (32, 0x00000020). The device is a physical disk (2, 0x00000002).

  3. Disable the mirror device (the secondary side), but retain that mirror:
    disk unmirror name = "test",
    side = secondary, mode = retain
    name  phyname              mirrorname          status
    test  /usr/new_user/test.dat   /usr/new_user/test.mir  18658

    Status 18658 indicates that the device is mirrored (64, 0x00000040), and the mirror device has been retained (2048, 0x00000800), but mirroring has been disabled (512 bit off), and only the primary device is used (256 bit off). Reads are mirrored (128, 0x00000080), and writes are mirrored to a UNIX file (16384, 0x00004000) and are in serial (32, 0x00000020). The device is a physical disk (2, 0x00000002).

  4. Remirror the test device:
    disk remirror name = "test"

    This resets the master..sysdevices columns to:

    name  phyname              mirrorname          status
    test  /usr/new_user/test.dat   /usr/new_user/test.mir  17122

    Status 17122 indicates that mirroring is currently enabled (512, 0x00000200) on this device. Reads are mirrored (128, 0x00000080), and writes are mirrored to a UNIX file device (16384, 0x00004000), the device is mirrored (64, 0x00000040), and serial (32, 0x00000020). The device is a physical disk (2, 0x00000002).

  5. Disable the test device (the primary side), but retain that mirror:
    disk unmirror name = "test",
    side = "primary", mode = retain

    This changes the master..sysdevices columns to:

    name  phyname              mirrorname          status
    test  /usr/new_user/test.dat   /usr/new_user/test.mir  16866

    Status 16866 indicates that the device is mirrored (64, 0x00000040), but mirroring has been disabled (512 bit off) and that only the secondary device is used (256, 0x00000100). Reads are mirrored (128, 0x00000080), and writes are mirrored to a UNIX file (16384, 0x00004000), and are in serial (32, 0x00000020). The device is a physical disk (2, 0x00000002).

  6. Remirror the test device:
    disk remirror name = "test"

    This resets the master..sysdevices columns to:

    name  phyname              mirrorname          status
    test  /usr/new_user/test.dat   /usr/new_user/test.mir  17122

    Status 17122 indicates that mirroring is currently enabled (512, 0x00000200) on this device. Reads are mirrored (128, 0x00000080), and writes are mirrored to a UNIX file device (16384, 0x00004000), the device is mirrored (64, 0x00000040), and serial (32, 0x00000020). The device is a physical disk (2, 0x00000002).

  7. Disable the test device (the primary side), and remove that mirror:
    disk unmirror name = "test", side = "primary",
    mode = remove

    This changes the master..sysdevices columns to:

    name  phyname              mirrorname          status
    test  /usr/new_user/test.dat   NULL                   16386

    Status 16386 indicates that the device is a physical device (2, 0x00000002), and any writes are to a UNIX file (16384, 0x00004000). Since the mirrorname column is null, mirroring is not enabled on this device.

  8. Remove the test device to complete the tutorial:
    sp_dropdevice test

    This removes all entries for the test device from master..sysdevices.