geom mirror

From: Josef Karthauser (joe_at_tao.org.uk)
Date: 03/26/05

  • Next message: Josef Karthauser: "Re: geom mirror"
    Date: Sat, 26 Mar 2005 12:48:35 +0000
    To: stable@freebsd.org
    
    
    

    I'm trying to get a geom mirror up and running on a remote server across
    two ide drives using the recipe below. I get as far as booting onto
    the second ide drive using

        1:ad(1,a)/boot/loader

    at the boot block. The boot block complains that ad1 doesn't contain a
    valid label however and refuses to boot.

    There appears to be a valid label on the gm0 device:

        jonah# disklabel mirror/gm0s1
        # /dev/mirror/gm0s1:
        8 partitions:
        # size offset fstype [fsize bsize bps/cpg]
          a: 2097152 0 4.2BSD 2048 16384 28552
          b: 6291456 2097152 swap
          c: 240121664 0 unused 0 0 # "raw" part,
        don't edit
          d: 41943040 8388608 4.2BSD 2048 16384 28552
          e: 41943040 50331648 4.2BSD 2048 16384 28552
          f: 20971520 92274688 4.2BSD 2048 16384 28552
          g: 84932416 113246208 4.2BSD 2048 16384 28552
          h: 41943040 198178624 4.2BSD 2048 16384 28552

    and there does appear to be an error on the ad1s1:

        jonah# disklabel ad1s1
        # /dev/ad1s1:
        8 partitions:
        # size offset fstype [fsize bsize bps/cpg]
          a: 2097152 0 4.2BSD 2048 16384 28552
          b: 6291456 2097152 swap
          c: 240121664 0 unused 0 0 # "raw" part,
        don't edit
          d: 41943040 8388608 4.2BSD 2048 16384 28552
          e: 41943040 50331648 4.2BSD 2048 16384 28552
          f: 20971520 92274688 4.2BSD 2048 16384 28552
          g: 84932416 113246208 4.2BSD 2048 16384 28552
          h: 41943040 198178624 4.2BSD 2048 16384 28552
        disklabel: partition c doesn't cover the whole unit!
        disklabel: An incorrect partition c may cause problems for standard
        system utilities

    Is this to be expected? What have I done wrong?

    Regards,
    Joe

    vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
        # make sure the second disk is treated as a really fresh one
        # (not really necessary, but makes procedure more deterministically ;-)
        dd if=/dev/zero of=/dev/ad1 bs=512 count=79

        # place a PC MBR onto the second disk
        # (with a single FreeBSD slice /dev/mirror/gm0s1 as large as the
        # /dev/ad0s1)
        # either automatically if sizes fit...
        fdisk -v -B -I /dev/ad1
        # ...or manually to make sure the sizes fit:
        size=`fdisk ad0 | grep ', size ' | head -1 | sed -e 's;^.*size
        \([0-9]*\).*$;\1;'`
        # ...and reduce the size by one block because ad0 and ad0s1 else would
        # share the same last sector which could lead to ad0 be recognized as
        # the GEOM provider instead of ad0s1. Alternatively, you can keep ad0
        # and ad0s1 of the same size and hard-code the ad0s1 GEOM provider by
        # adding the -h option to the "gmirror label" command below.
        size=`expr $size - 1`
        (echo "p 1 165 63 $size"; echo "a 1") | fdisk -v -B -f- -i /dev/ad1

        # place a GEOM mirror label onto first slice of second disk
        # (actually on the last block of the disk slice)
        gmirror label -v -n -b round-robin gm0s1 /dev/ad1s1

        # activate GEOM mirror kernel layer
        # (makes the /dev/mirror/gm0s1 device available)
        gmirror load

        # place a BSD disklabel onto /dev/mirror/gm0s1
        # (ATTENTION: in FreeBSD 5-STABLE before 14-Jan-2005 the
        # /dev/mirror/gm0s1 device has to be specified as just "mirror/gm0s1" or
        # the bsdlabel(8) will use the incorrect GEOM name "gm0s1" instead!)
        # (NOTICE: figure out what partitions you want with "bsdlabel /dev/ad0"
        # before)
        # (NOTICE: start "a" partition at offset 16, "c" partition at offset 0)
        bsdlabel -w -B /dev/mirror/gm0s1 # initialize
        bsdlabel -e /dev/mirror/gm0s1 # create custom partitions

        # manually copy filesystem data from first to to second disk
        # (same procedure for partitions "g", etc)
        newfs -U /dev/mirror/gm0s1a
        mount /dev/mirror/gm0s1a /mnt
        dump -L -0 -f- / | (cd /mnt; restore -r -v -f-)
        newfs -U /dev/mirror/gm0s1d
        mount /dev/mirror/gm0s1d /mnt/var
        dump -L -0 -f- /var | (cd /mnt/var; restore -r -v -f-)
        newfs -U /dev/mirror/gm0s1e
        mount /dev/mirror/gm0s1e /mnt/usr
        dump -L -0 -f- /usr | (cd /mnt/usr; restore -r -v -f-)

        # adjust new system configuration for GEOM mirror based setup
        cp -p /mnt/etc/fstab /mnt/etc/fstab.orig
        sed -e 's/dev\/ad0s1/dev\/mirror\/gm0s1/g' </mnt/etc/fstab.orig
    >/mnt/etc/fstab
        echo 'swapoff="YES"' >>/mnt/etc/rc.conf # for 5.3-RELEASE only
        echo 'geom_mirror_load="YES"' >>/mnt/boot/loader.conf

        # instruct boot stage 2 loader on first disk to boot
        # with the boot stage 3 loader from the second disk
        # (mainly because BIOS might not allow easy booting from second ATA disk
        # or at least requires manual intervention on the console)
        echo "1:ad(1,a)/boot/loader" >/boot.config

        # reboot system
        # (for running system with GEOM mirror on second disk)
        shutdown -r now

        # make sure the first disk is treated as a really fresh one
        # (also not really necessary, but makes procedure more deterministically
        # ;-)
        dd if=/dev/zero of=/dev/ad0 bs=512 count=79

        # place a new PC MBR onto the first disk
        # (with a single FreeBSD slice /dev/ad0s1 _exactly_ as large as the
        # /dev/ad1s1)
        size=`fdisk ad1 | grep ', size ' | head -1 | sed -e 's;^.*size
        \([0-9]*\).*$;\1;'`
        (echo "p 1 165 63 $size"; echo "a 1") | fdisk -v -B -f- -i /dev/ad0

        # switch GEOM mirror to auto-synchronization and add first disk
        # (first disk is now immediately synchronized with the second disk
        # content)
        gmirror configure -a gm0s1
        gmirror insert gm0s1 /dev/ad0s1

        # wait for the GEOM mirror synchronization to complete
        sh -c 'while [ ".`gmirror list | grep SYNCHRONIZING`" != . ]; do sleep
        1; done'

        # reboot into the final two-disk GEOM mirror setup
        # (now actually boots with the MBR and boot stages on first disk
        # as it was synchronized from second disk)
        shutdown -r now

    -- 
    Josef Karthauser (joe@tao.org.uk)	       http://www.josef-k.net/
    FreeBSD (cvs meister, admin and hacker)     http://www.uk.FreeBSD.org/
    Physics Particle Theory (student)   http://www.pact.cpes.sussex.ac.uk/
    ================ An eclectic mix of fact and theory. =================
    
    



  • Next message: Josef Karthauser: "Re: geom mirror"

    Relevant Pages

    • RE: Fedora on the second disk
      ... What I remember is in total 3 partitions. ... Hdb1 is the boot. ... Fedora on the second disk ...
      (Fedora)
    • Re: Lost access after cloning disk.
      ... bought a much larger one and added it to the second SATA channel. ... The only real difference is the size of the partitions. ... I do have a second disk which contains data. ... problem is usually fixed by restoring the correct drive letters in the ...
      (microsoft.public.windows.file_system)
    • Summary: Alternate boot disk on U10
      ... Thanks to the following for pointing out the out mistake in the devalias. ... Paul Richards ... I can boot from the second disk now. ...
      (SunManagers)
    • Re: dual boot two disk
      ... >>also needs to have an MBR for it to work right. ... the second disk has a MBR on it. ... > to boot from the second disk. ... > don't feel very brave:P I think that will most defenetly remove WinXP ...
      (freebsd-questions)
    • Re: how to boot from second disk
      ... Your best bet is to try and get a working RAID1 for your boot drive and prey that both disks don't die before the server is retired. ... test and tried to boot from second disk (which use dump to sync first disk). ... reboot server and go CTL-M on PERC 4e/dc firmware menu. ...
      (RedHat)

    Loading