Using Software RAID-1 with FreeBSD
Pages: 1, 2
Booting into the Mirror/Duplex
If you watch your boot-up messages, you should see this in bold white text right after the disks are probed:
GEOM_MIRROR: Device gm0 created (id=2125638583). GEOM_MIRROR: Device gm0: provider ad0 detected. GEOM_MIRROR: Device gm0: provider ad0 activated. GEOM_MIRROR: Device gm0: provider mirror/gm0 launched. GEOM_MIRROR: Device gm0 already configured. Mounting root from ufs:/dev/mirror/gm0s1a
and the system will continue to boot. However, if you have a typo in /etc/fstab, the boot will stop at this point and wait for you to type something meaningful. In this example, I forgot to insert
mirror when I edited /etc/fstab, meaning
/dev/gm0s1a should have been
/dev/mirror/gm0s1a so that FreeBSD could find my root filesystem:
Mounting root from ufs:/dev/gm0s1a setrootbyname failed ffs_mountroot: can't find rootvp Root mount failed: 6 Manual root filesystem specification: <fstype>:<device> Mount <device> using filesystem <fstype> e.g. ufs:da0s1a ? List valid disk boot devices <empty line> Abort manual input mountroot>
Fortunately, that's not as scary as it looks. Start by listing your valid disk boot devices:
mountroot> ? List of GEOM managed disk devices: mirror/gm0s1f mirror/gm0s1e mirror/gm0s1d mirror/gm0s1c mirror/gm0s1b mirror/gm0s1a mirror/gm0s1 ad2s1 mirror/gm0 ad0s1 ad2 acd0 ad0 fd0
If you type in the correct location of the / filesystem, the system will continue to reboot:
mountroot> ufs:/dev/mirror/gm0s1a Mounting root from /dev/mirror/gm0s1a
After logging in, be sure to edit the offending line in /etc/fstab and try rebooting again. When you can boot up and log in successfully, verify that each partition on the mirror mounted successfully with:
% df -h Filesystem Size Used Avail Capacity Mounted on /dev/mirror/gm0s1a 248M 35M 193M 15% / devfs 1.0K 1.0K 0B 100% /dev /dev/mirror/gm0s1e 248M 12K 228M 0% /tmp /dev/mirror/gm0s1f 7.3G 99M 6.7G 1% /usr /dev/mirror/gm0s1d 248M 196K 228M 0% /var
df won't show your swap partition; you can verify it with:
% swapinfo Device 1K-blocks Used Avail Capacity /dev/mirror/gm0s1b 629544 0 629544 0%
Synchronizing the Mirror/Duplex
The only thing left to do is to synchronize the data on both hard drives. This will happen automatically as soon as you issue the command to insert the second drive into the mirror:
# gmirror insert gm0 /dev/ad2 GEOM_MIRROR: Device gm0: provider ad2 detected. GEOM_MIRROR: Device gm0: rebuilding provider ad2.
To see what's happening:
# gmirror list | more Geom name: gm0 State: DEGRADED Components: 2 Balance: round-robin Slice: 4096 Flags: NONE GenID: 0 SyncID: 1 ID: 2125638583 Providers: 1. Name: mirror/gm0 Mediasize: 10262568448 (9.6G) Sectorsize: 512 Mode: r6w5e2 Consumers: 1. Name: ad0 Mediasize: 10262568448 (9.6G) Sectorsize: 512 Mode: r1w1e1 State: ACTIVE Priority: 0 Flags: DIRTY GenID: 0 SyncID: 1 ID: 3986018406 2. Name: ad2 Mediasize: 10262568448 (9.6G) Sectorsize: 512 Mode: r1w1e1 State: SYNCHRONIZING Priority: 0 Flags: DIRTY, SYNCHRONIZING GenID: 0 SyncID: 1 Synchronized: 1% ID: 1946262342
SYNCHRONIZING on the
Flags line. It will take a while for these two drives to synchronize, as it is currently at 1 percent. I've seen times ranging from about 30 minutes for a 10GB drive to about two and a half hours for a 75GB drive. If you're curious, check the progress with:
# gmirror status Name Status Components mirror/gm0 DEGRADED ad0 ad2 (2%)
You'll see a status message in bold white text when the synchronization finishes:
GEOM_MIRROR: Device gm0: rebuilding provider ad2 finished. GEOM_MIRROR: Device gm0: provider ad2 activated.
If you repeat
gmirror list, you'll note that the
State has changed from
COMPLETE and the
Synchronized line is now gone. Don't worry if you see
DIRTY on the
Flags line, as it simply indicates that the system has written new data to the disk but hasn't mirrored it yet. If you were to wait a few seconds on a quiet disk, you would see the
Flags line change to
For the final test,
reboot the system.
This time your startup messages should include:
GEOM_MIRROR: Device gm0 created (id=2125638583). GEOM_MIRROR: Device gm0: provider ad0 detected. GEOM_MIRROR: Device gm0: provider ad2 detected. GEOM_MIRROR: Device gm0: provider ad0 activated. GEOM_MIRROR: Device gm0: provider ad2 activated. GEOM_MIRROR: Device gm0: provider mirror/gm0 launched. Mounting root from ufs:/dev/mirror/gm0s1a
GEOM utilities are works in progress, and the developers constantly add new features and updates to the man pages. It's well worth your while to keep your favorite version of FreeBSD up-to-date using
cvsup or to choose a newer release when deciding which version of FreeBSD to install.
If you wish to gather performance statistics on your mirror/duplex, try
gstat(8). A good read through
gmirror(8) is also in order, especially if you want an overview of the procedure for replacing a failed disk.
Dru Lavigne is a network and systems administrator, IT instructor, author and international speaker. She has over a decade of experience administering and teaching Netware, Microsoft, Cisco, Checkpoint, SCO, Solaris, Linux, and BSD systems. A prolific author, she pens the popular FreeBSD Basics column for O'Reilly and is author of BSD Hacks and The Best of FreeBSD Basics.
Read more FreeBSD Basics columns.
Return to theBSD DevCenter
Provider ad2 too small.
2008-08-06 21:15:42 linuse [View]
2008-07-16 13:26:44 pu239 [View]
Remaining Disk Space wrong
2007-12-21 14:29:27 wsoeldner [View]
URL with a mirror status script.
2007-08-10 18:47:25 DrkShdw [View]
2007-05-24 23:01:41 ttschn [View]
2006-07-11 18:21:37 alvinph [View]
fstab error solved
2006-07-18 23:53:15 alvinph [View]
2006-07-12 11:06:13 Dru Lavigne | [View]
2007-03-18 19:05:41 fraggle.rok [View]
2006-04-01 16:48:13 bsdnoob [View]
2006-03-22 10:58:49 n4hhe [View]
2006-01-28 21:15:30 ayam666 [View]
2006-01-13 00:51:48 logza [View]
2005-12-28 14:59:44 corbesero [View]
2006-03-30 12:20:47 ragnar_spain [View]
2005-12-11 15:12:50 aboyz [View]
2005-12-08 20:38:34 molivier [View]
small change required if drives not ad0 & ad2
2006-09-12 06:21:59 gein [View]
2005-12-07 13:53:33 scrib [View]
2005-11-14 08:02:34 fak3r.com [View]
RAID card suggestion?
2005-11-29 11:55:51 Carnavour [View]