From owner-freebsd-doc@FreeBSD.ORG Fri Aug 14 11:00:15 2009 Return-Path: Delivered-To: freebsd-doc@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3C57F106568D for ; Fri, 14 Aug 2009 11:00:15 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 1981B8FC66 for ; Fri, 14 Aug 2009 11:00:15 +0000 (UTC) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n7EB0EcO017759 for ; Fri, 14 Aug 2009 11:00:14 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n7EB0E7o017758; Fri, 14 Aug 2009 11:00:14 GMT (envelope-from gnats) Date: Fri, 14 Aug 2009 11:00:14 GMT Message-Id: <200908141100.n7EB0E7o017758@freefall.freebsd.org> To: freebsd-doc@FreeBSD.org From: Anton Shterenlikht Cc: Subject: RE: docs/136712: [handbook] [patch] draft new section on gmirror per partition X-BeenThere: freebsd-doc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Anton Shterenlikht List-Id: Documentation project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Aug 2009 11:00:15 -0000 The following reply was made to PR docs/136712; it has been noted by GNATS. From: Anton Shterenlikht To: bug-followup@FreeBSD.org Cc: Subject: RE: docs/136712: [handbook] [patch] draft new section on gmirror per partition Date: Fri, 14 Aug 2009 11:58:53 +0100 below is the proposed patch ############ --- /usr/build/doc/en_US.ISO8859-1/books/handbook/geom/chapter.sgml 2009-05-06 15:12:13.000000000 +0100 +++ ./chapter.sgml 2009-08-14 11:31:05.000000000 +0100 @@ -220,10 +220,10 @@ &prompt.root; echo 'geom_stripe_load="YES"' >> /boot/loader.conf - - RAID1 - Mirroring + RAID1 - Mirroring + GEOM @@ -375,6 +375,295 @@ + + + + + Anton + Shterenlikht + With contributions from + + + + + + Mirroring individual partitions + + + in some partitioning schemes mirroring a whole disk + is not possible at all. The most notable + example is GPT, + used in ia64 architecture. Secondary GPT + header is stored in the last sector on disk. Since + gmirror writes its data in the last sector, + it destroys secondary GPT. + A very good introduction to + GPT + (GUID Partition Table) can be found on Wikipedia. + + + Mirroring individual partitions is a more + flexible way of achieving RAID1 compared to + mirroring a whole disk. Below is a step by step guide. + + + + Check partition of the boot disk using &man.gpart.8;: +&prompt.root; gpart show +=> 34 143374671 da0 GPT (68G) + 34 819200 1 efi (400M) + 819234 1048576 2 freebsd-ufs (512M) + 1867810 4194304 3 freebsd-swap (2.0G) + 6062114 2097152 4 freebsd-ufs (1.0G) + 8159266 2097152 5 freebsd-ufs (1.0G) + 10256418 133118287 6 freebsd-ufs (63G) + + this example is taken from ia64 architecture, + which includes EFI boot partition. Depending on the + architecture of your system you might or might not have + this partition present. + + + + + Partition a spare disk, da1, + exactly as the boot disk. First create a partitioning + scheme on da1, identical to + that on da0, in this example + this is GPT: +&prompt.root; gpart create -s gpt da1 + Add partitions exactly as on + da0: +&prompt.root; gpart add -b 34 -s 819200 -t freebsd-efi da1 +&prompt.root; gpart add -b 819234 -s 1048576 -t freebsd-ufs da1 +&prompt.root; gpart add -b 1867810 -s 4194304 -t freebsd-swap da1 +&prompt.root; gpart add -b 6062114 -s 2097152 -t freebsd-ufs da1 +&prompt.root; gpart add -b 8159266 -s 2097152 -t freebsd-ufs da1 +&prompt.root; gpart add -b 10256418 -s 133118287 -t freebsd-ufs da1 + + -b sets the starting block of + a new partition, -s specifies partition + size, in blocks, and -t is partition + type. On ia64 systems the boot partition is of EFI type, + hence the first partition added with gpart + is freebsd-efi. Likewise, + freebsd-swap is used to add a + swap partition. + + + + do gpart show before each + gpart add. This will tell you the + starting block. + + When you are done both disks should be partitioned + identically: +&prompt.root; gpart show +=> 34 143374671 da0 GPT (68G) + 34 819200 1 efi (400M) + 819234 1048576 2 freebsd-ufs (512M) + 1867810 4194304 3 freebsd-swap (2.0G) + 6062114 2097152 4 freebsd-ufs (1.0G) + 8159266 2097152 5 freebsd-ufs (1.0G) + 10256418 133118287 6 freebsd-ufs (63G) + +=> 34 143374671 da1 GPT (68G) + 34 819200 1 efi (400M) + 819234 1048576 2 freebsd-ufs (512M) + 1867810 4194304 3 freebsd-swap (2.0G) + 6062114 2097152 4 freebsd-ufs (1.0G) + 8159266 2097152 5 freebsd-ufs (1.0G) + 10256418 133118287 6 freebsd-ufs (63G) + + + + load gmirror kernel module: +&prompt.root; gmirror load + + + + Create mirror for EFI partition. + + If you do not have an EFI partition, skip this step. + + Unmount /efi because GEOM + manipulations can be performed only on unmounted, + not in use, partition: +&prompt.root; umount /efi + create EFI mirror on the boot disk, + da0, in our example: +&prompt.root; gmirror label -vb round-robin efi da0p1 + This would create /dev/mirror/efi + device. + Add EFI partition of the spare disk, + da1 to the mirror: +&prompt.root; gmirror insert efi da1p1 + The EFI partition in this example is only 400MB, so it + rebuilds quickly: +&prompt.root; gmirror status + Name Status Components +mirror/efi COMPLETE da0p1 + da1p1 + mount EFI mirror and check: +&prompt.root; mount -t msdosfs /dev/mirror/efi /efi +&prompt.root; df +Filesystem 512-blocks Used Avail Capacity Mounted on +... +/dev/mirror/efi 819008 141728 677280 17% /efi + + + + Create mirror for root (/) partition. + This involves extra steps since / + cannot be unmounted. + Create mirror on the spare disk, + da1: +&prompt.root; gmirror label -vb round-robin root da1p2 + Create ufs filesystem on this mirror: +&prompt.root; newfs /dev/mirror/root + Mount root mirror temporarily, say under + /mnt: +&prompt.root; mount /dev/mirror/root /mnt + Copy / onto /mnt + (which is the root mirror, + /dev/mirror/root), using a + combination of &man.dump.8; and &man.restore.8;: +&prompt.root; cd /mnt +&prompt.root; dump 0aLf - / | restore rf - + + &man.dump.8; is the only safe way to copy root + partition. Any other copying tool is not guaranteed + to do it right. + + + + + Update fstab on the + mirror. Edit + /mnt/etc/fstab and change + da0p1 into + mirror/efi and + da0p2 into + mirror/root: +&prompt.root; cat /mnt/etc/fstab +# Device Mountpoint FStype Options Dump Pass# +/dev/da0p3 none swap sw 0 0 +/dev/mirror/root / ufs rw 1 1 +/dev/mirror/efi /efi msdosfs rw 0 0 +/dev/da0p5 /tmp ufs rw 2 2 +/dev/da0p6 /usr ufs rw 2 2 +/dev/da0p4 /var ufs rw 2 2 +/dev/acd0 /cdrom cd9660 ro,noauto 0 0 + + + + Enable loading of the geom_mirror.ko + kernel module during system initialization. For this do + either: +&prompt.root; echo 'geom_mirror_load="YES"' >> /boot/loader.conf + or add + options GEOM_MIRROR + to your kernel configuration file. + + + + Change the root device in + /boot/loader.conf. The root + device is specified with vfs.root.mountfrom + option. It should point to the root mirror. For example, change +vfs.root.mountfrom="ufs:/dev/da0p2" + into +vfs.root.mountfrom="ufs:/dev/mirror/root" + + + + + Reboot into single user mode. + + On ia64 type boot -s on the + boot prompt. + + + + + At boot you should see gmirror loaded, + and then these lines: +GEOM_MIRROR: Device mirror/efi launched (2/2). +GEOM_MIRROR: Device mirror/root launched (1/1). +Trying to mount root from ufs:/dev/mirror/root + + + + Now that da0p2 is not + mounted, it can be inserted into root mirror: +&prompt.root; gmirror insert root da0p2 + and after mirror rebuild is complete you should see: +&prompt.root; gmirror status + Name Status Components + mirror/efi COMPLETE da0p1 + da1p1 +mirror/root COMPLETE da1p2 + da0p2 + + + + + Create mirrors for all other partitions of + da0, which are now not mounted: +&prompt.root; gmirror label -vb round-robin swap da0p3 +&prompt.root; gmirror label -vb round-robin var da0p4 +&prompt.root; gmirror label -vb round-robin tmp da0p5 +&prompt.root; gmirror label -vb round-robin usr da0p6 + + + + Edit /etc/fstab and change each remaining + da0 partition into its mirror: +&prompt.root; cat /etc/fstab +# Device Mountpoint FStype Options Dump Pass# +/dev/mirror/swap none swap sw 0 0 +/dev/mirror/root / ufs rw 1 1 +/dev/mirror/efi /efi msdosfs rw 0 0 +/dev/mirror/tmp /tmp ufs rw 2 2 +/dev/mirror/usr /usr ufs rw 2 2 +/dev/mirror/var /var ufs rw 2 2 +/dev/acd0 /cdrom cd9660 ro,noauto 0 0 + + + + Reboot. + + + + Add remaining da1 partitions + to mirrors: +&prompt.root; gmirror insert swap da1p3 +&prompt.root; gmirror insert var da1p4 +&prompt.root; gmirror insert tmp da1p5 +&prompt.root; gmirror insert usr da1p6 + + + + Done!: +&prompt.root; gmirror status + Name Status Components + mirror/efi COMPLETE da0p1 + da1p1 +mirror/root COMPLETE da0p2 + da1p2 +mirror/swap COMPLETE da0p3 + da1p3 + mirror/var COMPLETE da0p4 + da1p4 + mirror/tmp COMPLETE da0p5 + da1p5 + mirror/usr COMPLETE da0p6 + da1p6 + + + + + Troubleshooting @@ -382,9 +671,9 @@ If the system boots up to a prompt similar to: - ffs_mountroot: can't find rootvp + ffs_mountroot: can't find rootvp Root mount failed: 6 -mountroot> +mountroot> Reboot the machine using the power or reset button. At the boot menu, select option six (6). This will drop the @@ -404,6 +693,45 @@ in the kernel configuration file, rebuild and reinstall. That should remedy this issue. + + + System cannot find the boot device + + In that case the system boot process would stop with a + prompt similar to: + +: Mount using filesystem + eg. ufs:/dev/da0s1a + eg. cd9660:/dev/acd0 + This is equivalent to: mount -t cd9660 /dev/acd0 / + + ? List valid disk boot devices + Abort manual input + +mountroot>]]> + + You would get this message most probably if you forget + to add the correct boot device in + /boot/loader.conf. The hints given by the + system are clear. If your root device is + /dev/mirror/root, and the filesystem is + ufs, enter: + +mountroot> ufs:/dev/mirror/root + + The boot process would then continue: + +Trying to mount root from ufs:/dev/mirror/root + + When the system is up remember to edit your root device + in /boot/loader.conf. + + -- Anton Shterenlikht Room 2.6, Queen's Building Mech Eng Dept Bristol University University Walk, Bristol BS8 1TR, UK Tel: +44 (0)117 928 8233 Fax: +44 (0)117 929 4423