June 1999 · Featured article
Vinum
A Tutorial
Configuring Vinum
As with any article that deals with major modification of filesystems,
I think it is necessary to stress that you take a backup before
beginning. You must be root to do any of this.
What is Vinum?
Well, to quote the author's web page:
The Vinum Volume Manager is a block device driver which
implements virtual disk drives. It isolates disk hardware from
the block device interface and maps data in ways which result
in an increase in flexibility, performance and reliability
compared to the traditional slice view of disk storage. Vinum
implements the RAID 0, RAID 1 and RAID 5 models, both
individually and in combination.
Further information is available at http://www.lemis.com/vinum.html,
including a very interesting paper that describes vinum's operation
in great detail. Highly recommended further reading for those
interested in the theory behind it all.
The thing to remember with vinum, is that you now rely on a module,
separate from the kernel to access the given filesystem. If you
upgrade your system, it is possible for the vinum module to get out of
sync with the kernel, in which case it will not load. Be sure to
upgrade your kernel along with your modules.
Making it work
First of all, in this installment at least, I'll assume you'll be
configuring your volume as an auxiliary filesystem; to house an ftp
site, or source tree, etc. Using vinum for a system slice, like /usr,
is not that much different, but there are some boot strapping issues
that can be difficult to resolve. It is much easier to render your
system non functional.
If you have not already done so, you should configure your disks for
use with FreeBSD, and be sure you can mount them normally.
Instructions on doing this are available at
http://www.freebsd.org/tutorials/diskformat/diskformat.html. The
tutorial was written for 2.2 RELEASE, but the steps should be
identical.
For vinum to recognize a slice as a candidate for a vinum subdisk, its
type must be set accordingly. To find get this information, run
disklabel r <drive>; in my case, this is wd0, so I type disklabel r
wd0. This prints out the disklabel for the given drive; we're
interested in the slice table, which is at the bottom:
a: 81920 0 4.2BSD 0 0 0 # (Cyl. 0 5*)
b: 133120 81920 swap # (Cyl. 5* 13*)
c: 2313297 0 unused 0 0 # (Cyl. 0 143*)
e: 2098257 215040 4.2BSD # (Cyl. 13* 143*)
To use it with vinum, the type of the slice must be changed from
4.2BSD to vinum. To do this, use the disklabel e command on the
drive we just looked at, disklabel e wd0 in my case. This will start
an editor, with the disklabel info open; I believe the EDITOR
environment variable is respected, but it may be that vi is always
used. If you are not familiar with vi, I suggest reading the man
page. I mention this because using a vinum volume as a system
partition usually requires editing the disklabel in single user mode,
when vi is not available. Change the type for the slice you're
interested in from 4.2BSD to vinum. In my case, I'm using I'm using
the e: slice as part of my volume, so it looks like this:
e: 2098257 215040 vinum # (Cyl. 13* 143*)
When you're done, write the file and quit vi, disklabel takes care of
writing it to disk. Do that for the other drives you plan to use with
this volume; I'll be using slice e: of wd0 and slice f: of wd1, so my
entry for the other drive looks like this:
f: 2098257 215040 vinum # (Cyl. 13* 143*)
The Config File
Now we'll create a file describing the layout of your volume. If you
haven't already, now is a good time to read over the man page for
vinum, which gives a good description of the possible configurations.
Mine looks like this:
drive drive1 device /dev/wd0s1e
drive drive2 device /dev/wd1s1f
volume usrc
plex org striped 512b
sd length 1g drive drive1
sd length 1g drive drive2
This lists my two slices, wd0s1e and wd1s1f, which I'll call drive1
and drive2; my single volume, called usrc; a single striped plex, with
a stripe size of 512 blocks, or 256K; and two subdisks that make up
the plex. The terminology is described in the man page. For
historical reasons, it is suggested that volume names should end in
the letters a to h, so that fsck doesn't complain. For a striped
plex, Greg suggests that 256K is the optimum stripe size. I took his
advice and feel like I get good performance, but I haven't tried
anything different. It is required that you specify the length of
subdisks; 1g denotes 1 gigabyte, or 1024 megabytes. The man page
describes abbreviations available for listing the size of your
subdisks. Although it is not required, it is a good idea to keep your
config file around, in the case that you need to recreate your volume;
I keep mine in /etc/vinum.conf.
Create Your Volume
Barring catastrophic failure, you should now be ready to start up
vinum and initialize your volume. The man page describes how to do
this; in my case I type vinum create /etc/vinum.conf. This will
create a directory under /dev which holds the devices for the volume,
and various control structures used by vinum. You will get a listing
of the configured volume, plex and subdisks, like so:
Configuration summary
Drives: 2 (4 configured)
Volumes: 1 (4 configured)
Plexes: 1 (8 configured)
Subdisks: 2 (16 configured)
D drive1 State: up Device /dev/wd0e Avail: 0/1024 MB (0%)
D drive2 State: up Device /dev/wd1f Avail: 0/1024 MB (0%)
V usrc State: up Plexes: 1 Size: 2048 MB
P usrc.p0 S State: up Subdisks: 2 Size: 2048 MB
S usrc.p0.s0 State: up PO: 0 B Size: 1024 MB
S usrc.p0.s1 State: up PO: 256 kB Size: 1024 MB
Here you can see my two drives, 1 gigabyte each; my single volume,
usrc; my striped plex; and my two subdisks. Everything should be in
the up state. Don't worry if something goes wrong. There's no data
on the line right now, since we haven't mounted anything yet. In the
case that it doesn't work the first time, consult the man page about
the syntax of the config file, make sure the type for all the slices
you want to use is correctly set to vinum, etc. Before trying again
to initialize it, you should run vinum resetconfig, which resets the
configuration, and ensures that you're starting over with a clean
slate.
Wrapping Up
Now that we've got it configured, and vinum is ready to let us use
the volume, we need to create a filesystem on it using the newfs
command. My volume is called usrc, so I type newfs /dev/vinum/usrc.
Then, to mount it I type mount /dev/vinum/usrc /mnt, mostly just to
test things out; insert your favorite mount point appropriately.
Typing mount is generally a good idea at this point, just to see that
everything went ok, you should see something like:
/dev/vinum/usrc on /mnt (local, soft updates, writes: sync 489 async 24000)
Plus your other filesystems of course.
Having It Mounted Automagically
Now that your volume is all setup, you'll probably want to have it
mounted for you on startup; this requires modifying rc.conf. If
you're running a recent version of FreeBSD, you'll probably have
/etc/defaults/rc.conf, which contains all the system defaults. The
options to start vinum are at the bottom of this file, and should be
copied to your local config file, probably /etc/rc.conf. Mine looks
like:
vinum_drives="/dev/wd0 /dev/wd1"
This starts vinum, and initializes all volumes on wd0 and wd1. There
is also the option vinum_start, which will initializes all volumes.
You'll also want to add fstab entries for your new filesystem, so it
is mounted and unmounted properly. Mine look like:
/dev/vinum/usrc /mnt ufs rw 2 2
Its just like any other filesystem, except the device is in
/dev/vinum. Since the preferred way to use vinum is to load the kld
module, vinum will do this for you if it is not already loaded.
Another option is to have it loaded from /boot/loader, before your
system boots. I have added the option vinum_load="YES" to
/boot/loader.conf, which takes care of this for me. Either approach
should work fine. A friend I helped recently found that vinum didn't
start fast enough if he relied on the module loading itself; adding
the above solved his problem.
Cheers, Happy Hacking
$Id: vinum.txt,v 1.1 2000/02/16 08:07:52 jim Exp $
On the web
Further reading from the FreeBSD community and the projects named in this article.