Create software RAID1 volume with FreeBSD


Posted by shroman

Create mirror volume using standart FreeBSD 5.4 and later tools (gmirror).

Before we start use the following command to initialize disks, sometimes system is unable to use disk until you zero the contents.

So to perform a kind of format execute the following code:

 

#> dd if=/dev/zero of=/dev/da0 zero disks (da0, da1 - disks used in mirrored volume)

#> sysinstall Use sysinstall to initialize FreeBSD partition and single slice on da0

#> gmirror load Load GEOM module

#> gmirror label -v -b round-robin gm0 /dev/da0s1d Create first member of RAID1

#> gmirror insert gm0 /dev/da1s1d Add RAID1 mirror volume

#> mkdir /mirror Create mount point

#> mount /dev/mirror/gm0d /mirror Mount RAID1 partition to test functionality

#> gmirror list Check mirror status, wait for synch flags to complete

#> echo 'geom_mirror_load="YES"' >> /boot/loader.conf Enable loading GEOM at boot time

/etc/fstab /dev/mirror/gm0d /mirror ufs rw 2 2

Add mounting line to fstab, make a copy of fstab ....

#> umount /mirror Test fstab changes

#> mount -a Mount everything from /etc/fstab

#> mount Check status

#> shutdown -r now reboot system to test fstab config

Additional note!!!

In case you recieve "Not all disks connected." error it means that you misconfigured gmirror device, so to forget about your misconfiguration issue the following command: gmirror forget