pavement

RAID1, Software, How to setup

From FreeBSDwiki
(Difference between revisions)
Jump to: navigation, search
(Reconfiguring the System)
(Reconfiguring the System)
Line 37: Line 37:
  
 
  # '''echo geom_mirror_load=\"YES\" >> /mnt/boot/loader.conf'''
 
  # '''echo geom_mirror_load=\"YES\" >> /mnt/boot/loader.conf'''
# '''echo swapoff=\"YES\" >> /mnt/etc/rc.conf'''
 
  
 
Now we need to fix fstab to refer to the mirror, not to /dev/ad0 itself.  You can either manually edit it using [[ee]] or [[vi]] and change all references to /dev/ad0? to /dev/mirror/gm0? - ie /dev/ad0s1b becomes /dev/mirror/gm0s1b - or you can use a [[sed]] command to do it for you:
 
Now we need to fix fstab to refer to the mirror, not to /dev/ad0 itself.  You can either manually edit it using [[ee]] or [[vi]] and change all references to /dev/ad0? to /dev/mirror/gm0? - ie /dev/ad0s1b becomes /dev/mirror/gm0s1b - or you can use a [[sed]] command to do it for you:

Revision as of 16:01, 3 March 2006

Contents

Intro

This is a quick and dirty tutorial on setting up gmirror software-based RAID1 mirroring on an existing FreeBSD system. The goal is to convert all system partitions - including / and swap - from using the original system drive to running on a mirror consisting of the original drive and a physically identical mirror drive, safely and without losing any data. This will allow faster data read times as well as provide a measure of data and uptime security against individual drive failure.

Prerequisites

You MUST be running FreeBSD 5.3 or newer to use gmirror. For the purposes of this walkthrough, you will also need two IDENTICAL drives. We will be assuming that those drives are /dev/ad0 and /dev/ad2, with FreeBSD installed and working on /dev/ad0, and /dev/ad2 being either blank and brand-new or having data you no longer care about on it.

If you are using FreeBSD 5.3, you will also need a copy of Install CD Disc2.

Booting into the LiveCD filesystem

Reboot from the Install CD (FreeBSD 5.4 or above) or from Install CD disc2 (FreeBSD 5.3), and enter Fixit mode. Then get the root filesystem and devfs running:

# chroot /dist
# mount_devfs devfs /dev

Preparing to Create a Mirror

Make ABSOLUTELY CERTAIN that you don't have any pre-existing GEOM module labels written to either of your drives - because if you do (for instance from having futzed about with this before finding this article, or trying the article once and then trying it again) it will prevent other things from working. So, clean off any preexisting metadata from each drive:

# gmirror clear /dev/ad0
# gmirror clear /dev/ad2

Before we get started with the actual mirror procedures, we'll make sure the GEOM module is loaded:

# gmirror load

Creating and Initializing the Mirror

Now that we've got that sorted out, you've got a decision to make - do you want your new mirror to use round-robin device balancing, or load-based? (Split balancing is also available, but is beyond the scope of this article. man gmirror for details.)

Round-robin balancing simply makes each successive data access request to the next component in the mirror since the last one, whereas load-based tries to intelligently send data access requests to the least loaded component in the mirror. I'm going to assume you want load balancing, but if you prefer round-robin, simply substitute that in the label command below.

# gmirror label -v -b load gm0 /dev/ad0
# mount /dev/mirror/gm0s1a /mnt

And we've created and mounted our mirror filesystem, currently with a single physical drive in it - our existing system drive.

Reconfiguring the System

Now it's time to set things up so that we can boot the system to the GEOM mirror itself, not to /dev/ad0 directly. The next two commands will make sure that the GEOM module will load automatically at boot time, and tell the system that the swap file will be on a mirror, not a raw drive.

# echo geom_mirror_load=\"YES\" >> /mnt/boot/loader.conf

Now we need to fix fstab to refer to the mirror, not to /dev/ad0 itself. You can either manually edit it using ee or vi and change all references to /dev/ad0? to /dev/mirror/gm0? - ie /dev/ad0s1b becomes /dev/mirror/gm0s1b - or you can use a sed command to do it for you:

# sed "s%ad0%mirror/gm0%" /mnt/etc/fstab > /mnt/etc/fstab.new
# mv /mnt/etc/fstab /mnt/etc/fstab.old
# mv /mnt/etc/fstab.new /mnt/etc/fstab

And now we're ready to reboot! So pull the live CD out of the drive, issue a shutdown -r now, and you should come back up nicely with everything just as it was.

Adding the New Drive

The only thing left to do now is to add the physical /dev/ad2 device to your shiny new /dev/mirror/gm0 mirror.

# gmirror insert gm0 /dev/ad2

And that should be all she wrote - the system should automatically start synchronizing the new device into the mirror without any further prompting from you. You can issue a gmirror list to see both components and make sure everything looks good, and from here on out everything should get handled automagically by the system - monitor /var/log/messages for any errors or info as needed.

External links

http://people.freebsd.org/~rse/mirror/ a more complicated approach, involving possibly mismatched disks, etc. http://dannyman.toldme.com/2005/01/24/freebsd-howto-gmirror-system/ the original how-to this article was based upon.

Personal tools