Introduction

Vinum is the FreeBSD Volume Manager wrttien by Gregy Lehey. It supports RAID 0,1 and 5.

Contributed by Chris Watson

Setting up the disks to be used in Vinum

Partitioning the disks

The easiest way to configure disks to be used with Vinum is to use syinstall. As root "cd /stand". "./sysinstall". When sysinstall loads proceed to the "Custom" option for experts. Relax even if your not an expert the directions here should be crystal clear. Once inside the custom menu you will see another menu come up. Select "Partition" (allocate disk space for FreeBSD). When you select that another menu will show up listing the disk drive's that FreeBSD currently recognizes as useable. Select the first disk that you wish to use in your Vinum configuration. Order of choice is not important as long as the drive has no valueable data that has not been already backed up because this process will destroy data on the drives. So please make sure you select the correct drives that are to be used for Vinum. Once you select the first drive to be used with Vinum you will notice the FDISK parition editor is displayed now. You now want to delete any partitions listed here. Using the 'd' key on each one until there is only one. Now that there is only one make sure it is highlighted and hit the 'a' key to select "use entire disk". Since that is what we want to do. When it asks if you wish to make this dangerously dedicated or remain compatible with other OS's choose whichever you like. It doesnt really matter in this case because Vinum is the only thing using this disk. Once you have completed that you must write the change to disk. So hit 'w' to write the choices to disk. Once it is written to disk hit 'q' to quit this menu. Another menu will pop up asking you if you wish to install a boot manager. Select none and make sure the '*' is next to none before slecting ok or you could really break your bootable system. After you select none the menu that displays the disks FreeBSD knows about should pop back up. Now repeat the above procedure for EACH disk you want to use in your Vinum setup. Then proceed to the next section.

Labeling the disks

Once you have partitioned the disks as outlined above. We now need to label them. Select "Label" (Label allocated disk partitions) from the Custom installation menu. A menu should pop up listing the known drives again. If it doesn't it should drop you into the label editor using the last drive you selected during the partition phase. You will now see the FreeBSD Disklabel Editor. You should also see one partition. Since we used the entire disk above it should only have one partition on it. Make sure this partition is highlighted. Then select 'c' to create a filesystem. Make sure it's a filesystem and not swap space. Use the entire free space available. It will then ask you where to mount it. It is not important where you mount it as long as it is not a currently existing mount point such as /usr or /. For this example the first disk we will mount on "/a". When this is done hit 'w' to write the changes out. It should now begin to newfs this drive and setup a FFS on it. When this completes do this for each drive you wish to use in your Vinum configuration. Remember to give each disk a unique mountpoint. When you have finished labeling all the Vinum drives and newfs'ing them exit out of sysinstall. You are now ready to proceed to creating your vinum.conf outlined in the steps below. We are halfway there!

Editing the disklabel

Even though we labeled the disks above in the second section of this guide they were newfs'ed with a FFS filesystem. Vinum won't use that. So now we need to real easily we need to edit the disklabel on each disk we want in our Vinum configuration to use the 'vinum' FS type. So for each disk run 'disklabel -e disk' where disk is the device name of the disk you wish to use. For instance if we configured 3 disks above, SCSI disks da0, da1, and da2 we need to disklabel -e da1, disklabel -e da2, and disklabel -e da3. When you disklabel each one you only make one change. Change the fstype from "4.2BSD" to "vinum". Make sure vinum is lower case. Make sure you do this for each disk in your configuration. Then proceed to the next section.

Vinum configuration example for striping (RAID-0)

Before we begin it is important to note that your Vinum configuration needs to be indented similiar to the example below. Or Vinum will moan.

drive ibm1 device /dev/da1s1e
drive ibm2 device /dev/da2s1e
drive ibm3 device /dev/da3s1e
volume stripe
  plex org striped 256k
    sd length 2164m drive ibm1
    sd length 2164m drive ibm2
    sd length 2164m drive ibm3

The first lines of our configuration have to tell Vinum what we choose to name each of the disks and what disk corresponds to what disk name. The syntax is: drive "drivename" device "disk device". Where drivename is any name you wish the given disk to be known as. And disk device is the phsyical disk you want associated with that name.

The next section tells Vinum we are creating a volume named "stripe". You can name a volume anything. Since this is for a stripe configuration the name stripe is pretty easy to remember.

The next line defines our plex. Our group of disks that make up our volume. In our example above the plex is organized "org" as striped. As opposed to mirrored or another type of volume. Using a 256K stripe across all the disks. 256K appears to be the commonly used "sweet spot" for striping. Anything higher or lower many say is suboptimal.

The last 3 lines define how much space of each disk to use using the length word. In our case since we setup our drives to use the entire disk. A simple "fdisk da0" where da0 is your disk device name will display several lines the line similiar to this one: "start 63, size 4433877 (2164 Meg), flag 0" is the one that interest us. The size of the disk is in ( ). This disk is 2,164MB in size or 2.1GB. So once you know the size of each disk make sure you use the correct size for the length of the disk. After the length keywork next is the diskname. We use "drive ibm1" in the first sd line to show that our first disk is ibm1 and has a length of 2164MB's. The names you give in this section for each disk has to match the names you defined in the "drive" section at the begining of your configuration file. Now you are done with your Vinum config. Save this to /etc/vinum.conf and continue to the next section.

Creating our volume

Now that we have our disks ready to go and have created our configuration file it's time for Vinum to create our volume. Load the Vinum kld as follows: "kldload /modules/vinum.ko". This will load the vinum kernel module into the kernel. Next, as root, type "vinum". You will be dropped to a "vinum->" prompt. At this prompt we need to tell vinum to create our plex using our config file we just created. At the prompt enter "create -f vinum.conf". If all goes well and your config file has no errors it should work correctly. Once that is done hit control-d to quit Vinum. Now proceed to the next section.

Newfs'ing our new volume

Now we need to newfs our new volume. Even though we did it in sysinstall that was using a FFS. We need to do it with a vinum fs. This part is easy. As root type: "newfs -v /dev/vinum/stripe". In our configuration file we named our volume "stripe". That is the device that you will need to newfs. Whatever you named your volume you will need to use that name as the device to newfs'ed. When this is finished proceed to the next section.

Pre-Reboot configuration

We have finished with our vinum setup. Now we need to make sure it loads when we reboot. To do this we need to first edit /etc/rc.conf and add the following options in:
start_vinum="YES"

Now we need to edit our /etc/fstab to tell FreeBSD where to mount our new Vinum striped volume. Edit /etc/fstab. And add an entry similiar to this: /dev/vinum/stripe    /usr   ufs   rw   2   2
Mount it wherever you wish to. Remember we use "/dev/vinum/stripe" in our example because our volume was named stripe. Change it to whatever you named your volume.
This is optional step that you do not need to take but many people do. Turn on softupdates on the new volume. By doing "tunefs -n enable /dev/vinum/stripe". That will enable softupdates on your vinum volume for better speed and reliability. Now that we have finished all we need to do is reboot your server and enjoy your new Vinum volume!

Example config for mirroring from wca.

drive drive1 device /dev/ad4s1e
drive drive2 device /dev/ad6s1e
 volume mirror setupstate
  plex name mymirror.drive1 org concat
    sd length 29314m drive drive1
  plex name mymirror.drive2 org concat
    sd length 29314m drive drive2