• Pages

  • Categories

  • Archives

  • March 14, 2008

    gmirror – 1, 2, 3.

    Filed under: Computers, Misc — digital @ 1:20 pm

    gmirror is one of the ways in which you can setup software RAID under FreeBSD systems. It’s shit simple, but I don’t do it often enough to keep it fresh. I’m putting this here so I can refer back to it when I need it.

    db# dmesg |grep ad
    FreeBSD is a registered trademark of The FreeBSD Foundation.
    uhub0: on usb0
    uhub1: on usb1
    nfe0: Ethernet address: 00:e0:81:72:06:51
    bge0: mem 0xfe5f0000-0xfe5fffff irq 19 at device 0.0 on pci4
    bge0: Ethernet address: 00:e0:81:72:06:50
    ukbd0: on uhub0
    ums0: on uhub0
    ad4: 114473MB at ata2-master SATA150
    ad6: 114473MB at ata3-master SATA150
    ad8: 476940MB at ata4-master SATA300
    ad10: 476940MB at ata5-master SATA300
    Trying to mount root from ufs:/dev/ad4s1a

    That was to see where my drives are. I booted from ad4. ad4 and ad6 are two of the same drive so they will be my mirror.

    Next, I need to get the system to allow me to muck with the drive that is currently in use.

    db# sysctl kern.geom.debugflags=16
    kern.geom.debugflags: 0 -> 16

    After that I begin the real work. I’m going to load the gmirror driver, create the mirror and then add the second drive.

    db# gmirror load
    db# gmirror label -v -b round-robin gm0 /dev/ad4
    Metadata value stored on /dev/ad4.
    Done.
    db# gmirror insert gm0 ad6

    All that looks good, but I’d like this to function on a reboot. In order for that to happen, I need to tell the boot loader to get ready, and point fstab toward the gmirror device rather than either of the specific hard drives.

    db# echo geom_mirror_load=\”YES\” >> /boot/loader.conf
    db# sed s%ad4%mirror/gm0% /etc/fstab > /tmp/fstab

    Now, I check my work.

    db# cat /tmp/fstab
    # Device Mountpoint FStype Options Dump Pass#
    /dev/mirror/gm0s1b none swap sw 0 0
    /dev/mirror/gm0s1a / ufs rw 1 1
    /dev/mirror/gm0s1e /tmp ufs rw 2 2
    /dev/mirror/gm0s1f /usr ufs rw 2 2
    /dev/mirror/gm0s1d /var ufs rw 2 2
    /dev/acd0 /cdrom cd9660 ro,noauto 0 0

    Looks good. Let’s make it happen.

    db# mv /tmp/fstab /etc/fstab

    Now, for the moment of truth.

    db# reboot

    After logging in:

    db# df -h
    Filesystem Size Used Avail Capacity Mounted on
    /dev/mirror/gm0s1a 4.8G 197M 4.3G 4% /
    devfs 1.0K 1.0K 0B 100% /dev
    /dev/mirror/gm0s1e 1.9G 12K 1.8G 0% /tmp
    /dev/mirror/gm0s1f 54G 1.3G 48G 3% /usr
    /dev/mirror/gm0s1d 44G 372K 40G 0% /var
    db# swapinfo
    Device 1K-blocks Used Avail Capacity
    /dev/mirror/gm0s1b 4194304 0 4194304 0%

    Sweet. That wasn’t hard, right?

    The following is JUST the steps I took without any output.

    sysctl kern.geom.debugflags=16
    gmirror load
    gmirror label -v -b round-robin gm0 /dev/ad4
    gmirror insert gm0 ad6
    echo geom_mirror_load=\”YES\” >> /boot/loader.conf
    sed s%ad4%mirror/gm0% /etc/fstab > /tmp/fstab
    mv /tmp/fstab /etc/fstab
    reboot

    There you have it. Plain and simple. Next comes my ZFS games.

    digg:gmirror - 1, 2, 3. blinklist:gmirror - 1, 2, 3. furl:gmirror - 1, 2, 3. reddit:gmirror - 1, 2, 3.


    Leave a Reply

    You must be logged in to post a comment.

    Proudly powered by wordpress 2.9.2 - Theme by neuro

  • Friends

  • Misc

  • Shopping

  • Meta