Vinum HOWTO for two mirrored disks

with focus on installation/setup


Vinum is a Logical Volume Manager for FreeBSD. It is able to do RAID-0, RAID-1, RAID-4 and RAID-5. This document took a lot of information from a good page written by scanner at jurai dot net and of course the man-pages. Thanks to scanner and the freebsd-isp at freebsd dot org mailing-list for information and documentation.
Special thanks to Greg Lehey who made Vinum available and corrected some errors in this Howto.

Why this Howto? Well, there is really a lot of documentation, but I did not find any step by step document which describes in a simple way how to get Vinum with two disks and RAID-1 working. Remember that this document goes not go that far in the depth as the manpages do - if you want to understand how Vinum works read them and the documents at!

There is a good HOWTO at It is especially useful if something goes wrong.

Foreword for RAID-1, mirrored disks

Keep in mind, that currently (RELENG_4) FreeBSD does not boot off a Vinum volume - it's like the chicken and the egg: first you have to load the kernel in order to initialize the Vinum mirrored disks, so you cannot boot off Vinum volumes.
Case 1: One small disk for your FreeBSD system, which means for /. Two big disks for your mirrored disks. This can be an option for you, if you want to keep an exact copy of / on another 4. hard disk.
Case 2: The much more convenient one: 2 disks with the following layout: on one disk the root-file-system from which you boot from and on the other in the same size as a dump(8) of the root-file-system. The rest of the two disks will be used for Vinum.

I have written this document for a fresh installation of the system. Please keep in mind, that partitioning can mean you destroy data. Take a backup first. Well, let's start: First you have to install your system to the FreeBSD system disk. Don't install Ports and Linux Compatibility, because they use lot's of space in /usr and the tar command which we are going to use below in this page will take that longer regarding how much you install in /usr. You can do it afterwards with /stand/sysinstall. If you want to do it anyway no one will stop you - the whole procedure will just take slightly longer...

Fresh installation of FreeBSD

Good, choose whatever install method you like (let's assume we've choosen "Standard"). Partition your first disk (e.g. the FreeBSD System disk) and use the entire disk by pressing "a" and write your data to disk by pressing "w". Choosse the next disk and do the same and also for the last one (for Case 1). Then install the bootmanager only for the first disk (your FreeBSD system disk). After that you have to label your disk and put slices on it. The two cases discussed are examples, adjust them to your needs.

Case 1:
For the first disk take the following layout:

Part		Mount		Size
da0s1a		/		[Nearly the full disk]
da0s1b		swap		[The rest]

The two disks left are completely used for Vinum. Don't define already used mountpoints here, but rather choose dummy mountpoints like /a or /b! Take the whole diskspace.

da1s1e		/a		[e.g.20000MB]
da2s1e		/b		[e.g.20000MB]

Case 2:
For the first disk take the following layout:

Part Mount Size

da0s1a		/		[e.g. 500 MB, size depends on what you want to
				put in your Vinum volume, if you choose /usr 
				(and assuming home is in there) and /var it can 
				be quite small]
da0s1b		swap		[depending of how much swap you need]
da0s1e		/a		[e.g. 19500 MB for the Vinum disk]

For the second disk take the following layout:

da1s1e		/c		e.g. 500 MB, Exactly as your / on the first 
da1s1b		swap
da1s1f		/b		[e.g. 19500 MB for the Vinum disk]

Install your FreeBSD system.

Vinum Configuration

When the system is up we get into the Vinum configuration. First of all comes the disklabeling procedure. FreeBSD slices are labeled 4.2BSD which is not suitable for Vinum. Use the following command to change this:

# disklabel -e [name of the partition of the first to be mirrored partition, e.g. da1 for Case 1 (of course for da1s1e), or da0 for Case 2 (da0s1e)]

Do this for every disk you want to use for Vinum (Case 1: da2s1e, Case 2: da1s1e).

Depending on your $EDITOR variable an editor will be started, you should know about how to use it. Change 4.2BSD to vinum (pay attention: vinum should be written in small letters!)

Do the same for your second to be mirrored paritition.

For Case 2 it would be good to rename your slices on the second disk in order to eventually boot from it if the first disk fails, e.g.:

# disklabel da0
#        size   offset    fstype   [fsize bsize bps/cpg]
  a:  1024000  1024000    4.2BSD     2048 16384    90   # (Cyl.   63*- 127*)
  b:  1024000        0      swap                        # (Cyl.    0 - 63*)
  c: 17912412        0    unused        0     0         # (Cyl.    0 - 1114*)
  e: 15864412  2048000     vinum                        # (Cyl.  127*- 1114*)
# disklabel da1
#        size   offset    fstype   [fsize bsize bps/cpg]
  a:  1024000  1024000    4.2BSD     2048 16384    90   # (Cyl.   63*- 127*)
  b:  1024000        0      swap                        # (Cyl.    0 - 63*)
  c: 17912412        0    unused        0     0         # (Cyl.    0 - 1114*)
  e: 15864412  2048000     vinum                        # (Cyl.  127*- 1114*)

The next step is to create a Vinum configuration file. The name and its location are irrelevant. I did it by creating it in /etc:

# vi /etc/vinum.conf

The layout I have choosen is very simple. This is an example, adjust it to your needs:

Case 1:

I have /usr (app. 6,5 gig), /usr/home (app. 5 gig) and /var (the rest) choosen to be mirrored volumes. The command df gives the following layout:

/dev/da0s1a	49583		24678		20939		54%	/
/dev/da1s1e	19772182	1		19772182	0%	/a
/dev/da2s1e	19772182	1		19772182	0%	/b

So my configuration file looks like that:

drive drive1 device /dev/da1s1e
drive drive2 device /dev/da2s1e
 volume usr setupstate
  plex org concat
    sd length 6500m drive drive1
  plex org concat
    sd length 6500m drive drive2
 volume home setupstate
  plex org concat
    sd length 5000m drive drive1
  plex org concat
    sd length 5000m drive drive2
 volume var setupstate
  plex org concat
    sd length 0 drive drive1
  plex org concat
    sd length 0 drive drive2

Case 2:

df gives the following output:

/dev/da0s1a	503966		42012		421638		9%	/
/dev/da1s1a	503966		1		503966		0%	/c
/dev/da0s1e	19387098	1		19387098	0%	/a
/dev/da1s1e	19387098	1		19387098	0%	/b

The configuration file looks that way (assuming for this example just /usr (app. 14 gig) and /var (the rest) as to be mirrored volumes):

drive drive1 device /dev/da0s1e
drive drive2 device /dev/da1s1e
 volume usr setupstate
  plex org concat
    sd length 13887091s drive drive1
  plex org concat
    sd length 13887091s drive drive2
 volume var setupstate
  plex org concat
    sd length 0 drive drive1
  plex org concat
    sd length 0 drive drive2

The names drive1,2 are optional as the volume name is (usr, home and var). For me it was easier that way, adjust it to your needs.
Then copy tar to the root file system, just to be sure if something goes wrong:

# cp /usr/bin/tar /bin/tar

Copying vi to /bin will not help, because it's dynamically linked. Either compile a statically vi or learn about ed which is already in the /bin directory: you have to learn it before using vinum, because if something really goes wrong, your man-pages may not be accessible.

I first unmountet the two currently mounted slices:

# umount /a
# umount /b

Then start the Vinum program (man [4|8] vinum for further information!)

# vinum [This leads to the Vinum prompt in the next line:]
vinum -> create -f [name of your configuration, in my case /etc/vinum.conf]

If you wish to see your configuration, type list within the Vinum prompt. Use list -V to get a more verbose output. If you want to discard parts of your configuration use rm within the Vinum prompt (for volumes, plexes or subdisks). The more drastic way which should be used in an emergency is resetconfig: This discards your currently loaded configuration completely! Device names are lost.
For Case 1 we have achieved 3 Volumes (usr, home and var), 6 Plexes (usr.p0, usr.p1, home.p0, home.p1, var.p0 and var.p1) and 6 Subdisks (usr.p0.s0, usr.p1.s0, home.p0.s0, home.p1.s0, var.p0.s0 and var.p1.s0).
For Case 2 we have achieved 2 Volumes (usr and var), 4 Plexes (usr.p0, usr.p1, var.p0 and var.p1) and 4 Subdisks (usr.p0.s0, usr.p1.s0, var.p0.s0 and var.p1.s0).
All volumes, plexes and subdisks should be in the up state, else something is wrong (except you did not specify setupstate for your volumes in your configuration-file and want to initialize these with the init command from within the vinum-shell).
If your configuration suits your needs, hit "control + d" to finish.

After that newfs your slice with the following command:

# newfs -v /dev/vinum/[name name of your mirror, e.g. usr]

Do this for all of your subdisks you have configured for Vinum! (e.g. var, home etc.)

After that put your system into single user mode:

# init 1

Then mount your new Vinum slices lets say to /mnt/[name of the slice you want to clone]:

# mkdir /mnt/usr
# mount /dev/vinum/usr /mnt/usr

Do this for every slice you want to clone.

Copying your old directories to the Vinum slices

Then you have to copy the files in your old directory to the new slice:

# cd /
# tar cfv /mnt/usr.tar usr
# tar xfv usr.tar

Do this for every slice you want to clone.

Edit /etc/fstab

If this and the previous steps were successful, edit your fstab:

# vi /etc/fstab

Add the following line:

/dev/vinum/[name of your mirror, e.g. usr] /[name of your mountpoint, e.g. /usr] ufs rw 2 2

Repeat these steps for all of your mirror sets, like /var etc.

Don't forget /etc/rc.conf!

Now we are nearly finished! Add the following line to your /etc/rc.conf:


and reboot:

# reboot

After the System has come up make a df in order to see your mirrored disks!

For Case 2 you could dump your root-file-system to the second disk:

# mount /dev/da1s1a /c
# cd /c
# dump 0f - / | restore -rf -
# rm restoresymtable
# umount /c

If something goes wrong after reboot

If something goes wrong, e.g. you have not specified the right mountpoint etc.: you have ed in /bin, which means you can edit /etc/fstab, you have Vinum in single user and you have still the copy of /usr and /var! You can repair everything like you want and repeat this steps by debbuging your configuration!

After-Vinum configuration

If all went smooth, boot into single user mode init 1 and mount /. Remove your old /usr, /var and other directories you don't need anymore (like /a, /b and for Case 2 /c. Reboot in order to be sure everything's o.k. The system should come up into multiuser. Now delete your *.tar files in /mnt and finish your installation (e.g. install Ports, Linux Compatibility, upgrade your system to RELENG_4 or whatever). At this stage the Vinum part should be finished.

For any comments please feel free to write to mic at netbase dot org.

$Id: vinum-mirrored.html,v 1.6 2002/03/19 01:22:25 mic Exp $

| Valid HTML 4.01! | | Coded with vi |