Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 26 Mar 2005 12:48:35 +0000
From:      Josef Karthauser <joe@tao.org.uk>
To:        stable@freebsd.org
Subject:   geom mirror
Message-ID:  <20050326124835.GA60924@genius.tao.org.uk>

next in thread | raw e-mail | index | archive | help

--bp/iNruPH9dso1Pn
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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=20

    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=20
      b:  6291456  2097152      swap                   =20
      c: 240121664        0    unused        0     0         # "raw" part,
    don't edit
      d: 41943040  8388608    4.2BSD     2048 16384 28552=20
      e: 41943040 50331648    4.2BSD     2048 16384 28552=20
      f: 20971520 92274688    4.2BSD     2048 16384 28552=20
      g: 84932416 113246208    4.2BSD     2048 16384 28552=20
      h: 41943040 198178624    4.2BSD     2048 16384 28552=20

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=20
      b:  6291456  2097152      swap                   =20
      c: 240121664        0    unused        0     0         # "raw" part,
    don't edit
      d: 41943040  8388608    4.2BSD     2048 16384 28552=20
      e: 41943040 50331648    4.2BSD     2048 16384 28552=20
      f: 20971520 92274688    4.2BSD     2048 16384 28552=20
      g: 84932416 113246208    4.2BSD     2048 16384 28552=20
      h: 41943040 198178624    4.2BSD     2048 16384 28552=20
    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=3D/dev/zero of=3D/dev/ad1 bs=3D512 count=3D79

    # 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=3D`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=3D`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=3D"YES"' >>/mnt/etc/rc.conf # for 5.3-RELEASE only
    echo 'geom_mirror_load=3D"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=3D/dev/zero of=3D/dev/ad0 bs=3D512 count=3D79

    # place a new PC MBR onto the first disk
    # (with a single FreeBSD slice /dev/ad0s1 _exactly_ as large as the
    # /dev/ad1s1)
    size=3D`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`" !=3D . ]; 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

--=20
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/
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D An eclectic mix of fact an=
d theory. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

--bp/iNruPH9dso1Pn
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (FreeBSD)

iEYEARECAAYFAkJFWiIACgkQXVIcjOaxUBY6HACguDp6SncIvqdPhAkj6uQKw9gA
gd8AnitNp0vUOG+yBW7uJsxT1qg1Gsc+
=BZUS
-----END PGP SIGNATURE-----

--bp/iNruPH9dso1Pn--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050326124835.GA60924>