Vinum is a Volume Manager, a
From a user viewpoint, Vinum looks almost exactly the same as a disk, but in addition to the disks there is a
Vinum implements a four-level hierarchy of objects:
Plexes can include multiple subdisks spread overall drives in the Vinum configuration, so the size of an individual drive does not limit the size of a plex, and thus of a volume.
The way the data is shared across the drives has a strong influence on performance. It's
(рис 12.1) Concatenated organization
An alternative mapping is to divide the
(рис 12.2) Striped organization
Vinum offers two forms of redundant
Mirroring maintains two or more copies of the data on different
The most interesting of the
In the following figure, the numbers in the
(рис 12.3) RAID-5 organization
Compared to mirroring, RAID-5 has the advantage of requiring significantly less
Vinum also offers RAID-4, a simpler variant of RAID-5 which stores all the
Each plex organization has its unique advantages:
The following table
| Plex type | Minimum subdisks | Can add subdisks | Must be equal size | Application |
|---|---|---|---|---|
| concatenated | 1 | yes | no | Large |
| striped | 2 | no | yes | High performance in combination with highly |
| RAID-5 | 3 | no | yes | Highly reliable storage, primarily read access. |
Before you can do anything with Vinum, you need to reserve
8 partitions: # size offset fstype [fsize bsize bps/cpg] c: 6295133 0 unused 0 0 # (Cyl. 0 - 10302) b: 1048576 0 swap 0 0 # (Cyl. 0 - 10302) h: 5246557 1048576 vinum 0 0 # (Cyl. 0 - 10302)
Vinum comes with the base system as a kld. It gets loaded automatically when you run the vinum command. It's possible to build a special kernel that includes Vinum, but this is not recommended: in this case, you will not be able to stop Vinum.
FreeBSD Release 5 includes a new method of starting Vinum. Put the following lines in
/boot/loader.conf:
vinum_load="YES" vinum.autostart="YES"
The first line instructs the
Vinum maintains a configuration database that describes the objects known to an individual system. You create the
The configuration file describes individual Vinum objects. To define a simple volume, you might create a file called, say, configl, containing the following definitions:
drive a device /dev/da1s2h volume myvol plex org concat sd length 512m drive a
This file describes four Vinum objects:
drive line describes a disk partition (drive) and its location relative to the underlying hardware. It is given the symbolic name a. This separation of the symbolic names from the device names allows disks to be moved from one location to another without confusion.volume line describes a volume. The only myvol.plex line defines a plex. The only concat. No name is necessary: the system automatically generates a name from the volume name by adding the suffix .px, where x is the number of the plex in the volume. Thus this plex will be called myvol.p0.sd line describes a subdisk. The minimum specifications are the name of a drive on which to store it, and the length of the subdisk. As with plexes, no name is necessary: the system automatically assigns names derived from the plex name by adding the suffix .sx, where x is the number of the subdisk in the plex. Thus Vinum gives this subdisk the name myvol.p0.s0After processing this file, vinum(8) produces the following output:
vinum -> create config1 1 drives: D a State: up /dev/da1s2h A: 3582/4094 MB (87%) 1 volumes: V myvol State: up Plexes: 1 Size: 512 MB 1 plexes: P myvol.p0 C State: up Subdisks: 1 Size: 512 MB 1 subdisks: S myvol.p0.s0 State: up D: a Size: 512 MB
This output shows the brief listing format of vinum. It is represented graphically in Figure 12-4 .
(рис 12.4) A simple Vinum volume
This figure, and the ones that follow, represent a volume, which contains the plexes, which in turn contain the subdisks. In this trivial example, the volume contains one plex, and the plex contains one subdisk.
You create a file system on this volume in the same way as you would for a conventional disk:
# newfs -U /dev/vinum/myvol /dev/vinum/myvol: 512.0MB (1048576 sectors) block size 16384, fragment size 2048 using 4 cylinder groups of 128.02MB, 8193 blks, 16512 inodes. super-block backups (for fsck -b #) at: 32, 262208, 524384, 786560
This particular volume has no specific advantage over a conventional disk partition. It contains a single plex, so it is not redundant. The plex contains a single subdisk, so there is no difference in
The
drive b device /dev/da2s2h
volume mirror
plex org concat
sd length 512m drive a
plex org concat
sd length 512m drive b
In this example, it was not necessary to specify a definition of drive a again, because Vinum keeps track of all objects in its
2 drives: D a State: up /dev/da1s2h A: 3070/4094 MB (74%) D b State: up /dev/da2s2h A: 3582/4094 MB (87%) 2 volumes: V myvol State: up Plexes: 1 Size: 512 MB V mirror State: up Plexes: 2 Size: 512 MB 3 plexes: P myvol.p0 C State: up Subdisks: 1 Size: 512 MB P mirror.p0 C State: up Subdisks: 1 Size: 512 MB P mirror.p1 C State: initializing Subdisks: 1 Size: 512 MB 3 subdisks: S myvol.p0.s0 State: up D: a Size: 512 MB S mirror.p0.s0 State: up D: a Size: 512 MB S mirror.p1.s0 State: empty D: b Size: 512 MB
рис 12.5shows the structure graphically.
In this example, each plex contains the full 512 MB of
Note the state of mirror.p1 and mirror.p1.s0: initializing and empty respectively. There's a problem when you create two identical plexes: to ensure that they're identical, you need to copy the entire contents of one plex to the other. This process is called reviving, and you perform it with the start command:
vinum -> start mirror.pl vinum[278]: reviving mirror.p1.s0 Reviving mirror.p1.s0 in the background vinum -> vinum[278]: mirror.p1.s0 is up
(рис 12.5) A mirrored Vinum volume
During the start process, you can look at the status to see how far the revive has progressed:
vinum -> list mirror.pl.s0 Smirror.pl.s0 State: R43% D: bSize: 512 MB
setupstate keyword in the configuration file. We'll see an example of this below.
At some time after creating a volume, you may decide to add additional plexes. For example, you may want to add a plex to the volume myvol we saw above, putting its subdisk on drive b. The configuration file for this extension would look like:
plex name myvol.p1 org concat volume myvol sd size 1g drive b
To see what has happened, use the recursive listing option -r for the list command:
vinum -> l-r myvol V myvol State: up Plexes: 2 Size: 1024 MB P myvol.p0 C State: up Subdisks: 1 Size: 512 MB P myvol.p1 C State: initializing Subdisks: 1 Size: 1024 MB S myvol.p0.s0 State: up D: a Size: 512 MB S myvol.p1.s0 State: empty D: b Size: 1024 MB
The command l is a list, and the -r option means recursive: it displays all
Note that you can't use the setupstate keyword here. Vinum can't know whether the existing volume contains start command to synchronize the plexes.
After adding a second plex to myvol, it had one plex with 512 MB and another with 1024 MB. It makes sense to have the same size plexes, so the first thing we should do is add a second subdisk to the plex myvol.p0.
If you add subdisks to striped, RAID-4 or RAID-5 plexes, you will change the mapping of the data to the disks, which effectively destroys the contents. As a result, you must use the -f option. When you add subdisks to concatenated plexes, the data in the existing subdisks remains
sd name myvol.p0.s1 plex myvol.p0 size 512m drive c
After adding this subdisk, the volume looks like this:
(рис 12.6) An extended Vinum volume
It doesn't look too happy, however:
vinum -> l -r myvol V myvol State: up Plexes: 2 Size: 1024 MB P myvol.p0 C State: corrupt Subdisks: 2 Size: 1024 MB P myvol.p1 C State: initializing Subdisks: 1 Size: 1024 MB S myvol.p0.s0 State: up D: a Size: 512 MB S myvol.p0.s1 State: empty D: c Size: 512 MB S myvol.p1.s0 State: stale D: b Size: 1024 MB
In fact, it's in as good a shape as it ever has been. The first half of myvol still contains the file system that we put on it, and it's as accessible as ever. The trouble here is that there is nothing in the other two subdisks, which are shown
vinum -> setstate up myvol.p0.s1 myvol.p0 vinum -> l -r myvol V myvol State: up Plexes: 2 Size: 1024 MB P myvol.p0 C State: up Subdisks: 2 Size: 1024 MB P myvol.p1 C State: faulty Subdisks: 1 Size: 1024 MB S myvol.p0.s0 State: up D: Size: 512 MB S myvol.p0.s1 State: up D: Size: 512 MB S myvol.p1.s0 State: stale D: Size: 1024 MB vinum -> saveconfig
The command setstate changes the state of individual objects without updating those of related objects. For example, you can use it to change the state of a plex to up even if all the subdisks are down. If used incorrectly, it can can cause severe saveconfig for that, after you're sure you have the correct states. Read the man page before using them for any other purpose.
Next you start the second plex:
vinum -> start myvol.p1 Reviving myvol.p1.s0 in the background vinum[446]: reviving myvol.p1.s0 vinum -> vinum[446]: myvol.p1.s0 is up some time later l command for previous prompt 3 drives: D a State: up /dev/da1s2h A: 3582/4094 MB (87%) D b State: up /dev/da2s2h A: 3070/4094 MB (74%) D c State: up /dev/da3s2h A: 3582/4094 MB (87%) 1 volumes: V myvol State: up Plexes: 2 Size: 1024 MB 2 plexes: P myvol.p0 C State: up Subdisks: 2 Size: 1024 MB P myvol.p1 C State: up Subdisks: 1 Size: 1024 MB 3 subdisks: S myvol.p0.s0 State: up D: a Size 512 MB S myvol.p1.s0 State: up D: b Size 1024 MB S myvol.p0.s1 State: up D: c Size 512 MB
The message telling you that myvol.p1.s0 is up comes after the prompt, so the next command doesn't have a prompt. At this point you have a fully mirrored, functional volume, 1 GB in size. If you now look at the contents, though, you see:
# df /mnt Filesystem 1048576-blocks Used Avail Capacity Mounted on /dev/vinum/myvol 503 1 461 0% /mnt
The volume is now 1 GB in size, but the file system on the volume is still only 512 MB. To expand it, use growfs:
# umount /mnt
# growfs /dev/vinum/myvol
We strongly recommend you to make a backup before growing the Filesystem
Did you backup your data (Yes/No) ? Yes
new file systemsize is: 524288 frags
Warning: 261920 sector(s) cannot be allocated.
growfs: 896.1MB (1835232 sectors) block size 16384, fragment size 2048
using 7 cylinder groups of 128.02MB, 8193 blks, 16512 inodes.
super-block backups (for fsck -b #) at:
1048736, 1310912, 1573088
# mount /dev/vinum/myvol /mnt
# df /mnt
Filesystem 1048576-blocks Used Avail Capacity Mounted on
/dev/vinum/myvol 881 1 809 0% /mnt
The
drive c device /dev/da3s2h
drive d device /dev/da4s2h
volume stripe
plex org striped 480k
sd length 128m drive a
sd length 128m drive b
sd length 128m drive c
sd length 128m drive d
When creating striped plexes for the UFS file system, ensure that the stripe size is a multiple of the file system
Vinum requires that a striped plex have an integral number of stripes. You don't have to calculate the size exactly, though: if the size of the plex is not a multiple of the stripe size, Vinum trims off the remaining partial stripe and prints a console message:
vinum: removing 256 blocks of partial stripe at the end of stripe.p0
As before, it is not necessary to define the drives that are already known to Vinum. After processing this definition, the configuration looks like:
4 drives: D a State: up /dev/da1s2h A: 2942/4094 MB (71%) D b State: up /dev/da2s2h A: 2430/4094 MB (59%) D c State: up /dev/da3s2h A: 3966/4094 MB (96%) D d State: up /dev/da4s2h A: 3966/4094 MB (96%) 3 volumes: V myvol State: up Plexes: 2 Size: 1024 MB V mirror State: up Plexes: 2 Size: 512 MB V stripe State: up Plexes: 1 Size: 511 MB 5 plexes: P myvol.p0 C State: up Subdisks: 1 Size: 512 MB P mirror.p0 C State: up Subdisks: 1 Size: 512 MB P mirror.p1 C State: initializing Subdisks: 1 Size: 512 MB P myvol.p1 C State: up Subdisks: 1 Size: 1024 MB P stripe.p0 S State: up Subdisks: 4 Size: 511 MB 8 subdisks: S myvol.p0.s0 State: up D: a Size: 512 MB S mirror.p0.s0 State: up D: a Size: 512 MB S mirror.p1.s0 State: empty D: b Size: 512 MB S myvol.p1.s0 State: up D: b Size: 1024 MB S myvol.p0.s1 State: up D: c Size: 512 MB S stripe.p0.s0 State: up D: a Size: 127 MB S stripe.p0.s1 State: up D: b Size: 127 MB S stripe.p0.s2 State: up D: c Size: 127 MB S stripe.p0.s3 State: up D: d Size: 127 MB
This volume is represented in Figure 12-7. The darkness of the stripes indicates the position within the plex
(рис 12.7) A striped Vinum volume
With sufficient hardware, it is possible to build volumes that show both increased
drive e device /dev/da5s2h
drive f device /dev/da6s2h
drive g device /dev/da7s2h
drive h device /dev/da8s2h
drive i device /dev/da9s2h
drive j device /dev/da10s2h
volume raid10 setupstate
plex org striped 480k
sd length 102480k drive a
sd length 102480k drive b
sd length 102480k drive c
sd length 102480k drive d
sd length 102480k drive e
plex org striped 480k
sd length 102480k drive f
sd length 102480k drive g
sd length 102480k drive h
sd length 102480k drive i
sd length 102480k drive j
In this example, we have added another five disks for the second plex, so the volume is spread over ten
vinum -> l -r raid10 V raid10 State: up Plexes: 2 Size: 499 MB P raid10.p0 S State: up Subdisks: 5 Size: 499 MB P raid10.p1 S State: up Subdisks: 5 Size: 499 MB S raid10.p0.s0 State: up D: a Size: 99 MB S raid10.p0.s1 State: up D: b Size: 99 MB S raid10.p0.s2 State: up D: c Size: 99 MB S raid10.p0.s3 State: up D: d Size: 99 MB S raid10.p0.s4 State: up D: e Size: 99 MB S raid10.p1.s0 State: up D: f Size: 99 MB S raid10.p1.s1 State: up D: g Size: 99 MB S raid10.p1.s2 State: up D: h Size: 99 MB S raid10.p1.s3 State: up D: i Size: 99 MB S raid10.p1.s4 State: up D: j Size: 99 MB
This assumes the availability of ten disks. It's not essential to have all the components on different disks. You could put the subdisks of the second plex on the same drives as the subdisks of the first plex. If you do so, you should put corresponding subdisks on different drives:
plex org striped 480k sd length 102480k drive a sd length 102480k drive b sd length 102480k drive c sd length 102480k drive d sd length 102480k drive e plex org striped 480k sd length 102480k drive c sd length 102480k drive d sd length 102480k drive e sd length 102480k drive a sd length 102480k drive b
The subdisks of the second plex are offset by two drives from those of the first plex: this helps ensure that the failure of a drive does not cause the same part of both plexes to become unreachable, which would destroy the file system.
Figure 12-8 represents the structure of this volume.
(рис 12.8) A mirrored, striped Vinum volume
Vinum stores configuration information on each drive in essentially the same form as in the configuration files. You can display it with the dumpconfig command. When reading from the
vinum -> dumpconfig
Drive a: Device /dev/da1s2h
Created on bumble.example.org at Tue Nov 26 14:35:12 2002
Config last updated Tue Nov 26 16:12:35 2002
Size: 4293563904 bytes (4094 MB)
volume myvol state up
plex name myvol.p0 state up org concat vol myvol
plex name myvol.p1 state up org concat vol myvol
sd name myvol.p0.s0 drive a plex myvol.p0 len 1048576s driveoffset 265s state up plexoffset 0s
sd name myvol.p1.s0 drive b plex myvol.p1 len 2097152s driveoffset 265s state up plexoffset 0s
sd name myvol.p0.s1 drive c plex myvol.p0 len 1048576s driveoffset 265s state up plexoffset 1048576s
Drive /dev/da1s2h: 4094 MB (4293563904 bytes)
Drive b: Device /dev/da2s2h
Created on bumble.example.org at Tue Nov 26 14:35:27 2002
Config last updated Tue Nov 26 16:12:35 2002
Size: 4293563904 bytes (4094 MB)
volume myvol state up
plex name myvol.p0 state up org concat vol myvol
plex name myvol.p1 state up org concat vol myvol
sd name myvol.p0.s0 drive a plex myvol.p0 len 1048576s driveoffset 265s state up plexoffset 0s
sd name myvol.p1.s0 drive b plex myvol.p1 len 2097152s driveoffset 265s state up plexoffset 0s
sd name myvol.p0.s1 drive c plex myvol.p0 len 1048576s driveoffset 265s state up plexoffset 1048576s
The obvious differences here are the presence of explicit location information and naming (both of which are also allowed, but discouraged, for use by the user) and the information on the states (which are not available to the user). Vinum does not store information about drives in the configuration information: it finds the drives by scanning the configured
When you start Vinum with the vinum start command, Vinum reads the
Installing FreeBSD on Vinum is complicated by the fact that sysinstall and the
A typical disk installation lays out disk partitions in the following manner:
| da0s3a:/file sistem | da0s3c: entire disk |
| da0s3d:swap | |
| da0s3e:/usr file sistem | |
| da0s3f:/var file sistem |
This layout shows three file system partitions and a swap partition, which is not the layout recommended on page 68. We'll look at the reasons for this below.
Each partition corresponds logically to a Vinum subdisk. You could
8 partitions: # size offset fstype [fsize bsize bps/cpg] a: 524288 532480 4.2BSD 2048 16384 94 b: 532215 265 swap c: 8386733 0 unused 0 0 #"raw" part, don't edit e: 4194304 1056768 4.2BSD 2048 16384 89 f: 3135661 5251072 4.2BSD 2048 16384 89
To convert to Vinum, use bsdlabel with the -e (edit label) option to create a volume of type vinum that maps the c partition:
h: 8386733
After this, you have the following situation:
| da0s3b: swap | da0s3c: entire disk | da0s3h: vinum drive |
| da0s3a:/file system | ||
| da0s3a:/usr file | ||
| da0s3f:/var file sistem |
The
drive rootdev device /dev/da0s2h volume swap plex org concat # b: 532215 265 swap sd len 532215s driveoffset 265s drive rootdev volume root plex org concat # a: 524288 532480 4.2BSD 2048 16384 94 sd len 524288s driveoffset 532480s drive rootdev volume usr plex org concat # e: 4194304 1056768 4.2BSD 2048 16384 89 sd len 4194304s driveoffset 1056768s drive rootdev volume var plex org concat # f: 3135661 5251072 4.2BSD 2048 16384 89 sd len 3135661s driveoffset 5251072s drive rootdev
The comments are the corresponding lines from the bsdlabel output. They show the corresponding values for size and offset. Run vinum create against this file, and confirm that you have the volumes /, /usr and /var.
Next, ensure that you are set up to start Vinum with the new method. You should have the following lines in /boot/loader.conf:
vinum_load="YES" vinum.autostart="YES"
Then reboot to fsck against the volumes, using the -n option to tell fsck not to correct any errors it finds. You should see something like this:
# fsck -n -t ufs /dev/vinum/usr ** /dev/vinum/usr (NO WRITE) ** Last Mounted on /usr ** Phase 1 - Check Blocks and Sizes ** Phase 2 - Check Pathnames ** Phase 3 - Check Connectivity ** Phase 4 - Check Reference Counts ** Phase 5 - Check Cyl groups 35323 files, 314115 used, 718036 free (4132 frags, 89238 blocks, 0.4% fragmentation)
If there are any errors, they will probably be because you have miscalculated size or offset. You'll see something like this:
# fsck -n -t ufs /dev/vinum/usr ** /dev/vinum/usr (NO WRITE) Cannot find file system superblock /dev/vinum/usr: CANNOT FIGURE OUT FILE SYSTEM PARTITION
You need to do this in
If all is well, remount the root file system read-write:
# mount -u /
Then edit /etc/fstab to point to the new devices. For this example, /etc/fstab might initially contain:
# $Id: fstab,v 1.3 2002/11/14 06:48:16 grog Exp $ # Device Mountpoint FStype Options Dump Pass# /dev/da0s4a / ufs rw 1 1 /dev/da0s4b none swap sw 0 0 /dev/da0s4e /usr ufs rw 1 1 /dev/da0s4f /var ufs rw 1 1
Change it to reflect the Vinum volumes:
# $Id: fstab,v 1.3 2002/11/14 06:48:16 grog Exp $ # Device Mountpoint FStype Options Dump Pass# /dev/vinum/swap none swap sw 0 0 /dev/vinum/root / ufs rw 1 1 /dev/vinum/usr /usr ufs rw 1 1 /dev/vinum/var /var ufs rw 1 1 /dev/da0s4b none swap sw 0 0 /dev/da0s4e /usr ufs rw 1 1 /dev/da0s4f /var ufs rw 1 1
Then reboot again to mount the root file system from /dev/vinum/root. You can also optionally remove all the UFS partitions except the root partition. The
Once you have reached this stage, you can add additional plexes to the volumes, or you can extend the plexes (and thus the size of the file system) by adding subdisks to the plexes, as discussed on page 229.
One of the purposes of Vinum is to be able to recover from hardware problems. If you have chosen a redundant storage configuration, the failure of a single component will not stop the volume from working. In many cases, you can replace the components without down time.
If a drive fails, perform the following steps:
If you want to have this freedom with a hot-pluggable drive, you must stop Vinum and restart it.
drive data3 device /dev/da3s1h
Then enter:
# vinum create configfile
vinum -> l -r test V test State: up Plexes: 2 Size: 30 MB Ptest.p0 C State: up Subdisks: 1 Size: 30 MB Ptest.p1 C State: faulty Subdisks: 1 Size: 30 MB Stest.p0.s0 State: up PO: 0 B Size: 30 MB Stest.p1.s0 State: obsolete PO: 0 B Size: 30 MB vinum -> start test.p1.s0 Reviving test.p1.s0 in the background vinum -> vinum[295]: reviving test.p1.s0 this message appears after the prompt (some time later) vinum[295]: test.p1.s0 is up
If you're running your root file system on a Vinum volume, you can survive the failure of the boot volume if it is mirrored with at least two concatenated plexes each containing only one subdisk. Under normal circumstances, you can carry on running as if nothing had happened, but obviously you will no longer be able to reboot from that disk. Instead, boot from the other disk.
The root file system also has individual UFS partitions, so you have a choice of what you mount. For example, if your root file system has UFS partitions /dev/da0s4a and /dev/da1s4a, you can mount either of these partitions or /dev/vinum/root. Never mount more than one of them, otherwise you can cause
An even more insidious way to
Sometimes you might want to move a set of Vinum disks to a different FreeBSD machine. This is simple, as long as there are no name conflicts between the objects on the Vinum disks and any other Vinum objects you may already have on the system. Simply connect the disks and start Vinum. You don't need to put the disks in any particular location, and you don't need to run vinum create: Vinum stores the configuration on the drives themselves, and when it starts, it locates it accordingly.
The vinum command offers a large number of subcommands intended for specific purposes. It's easy to abuse them. Here are some things you should not do:
2 drives: D da2 State: up /dev/da1s1h A: 3582/4094 MB (87%) D dal State: up /dev/da1s2h A: 3582/4094 MB (87%)
This is clearly not helpful.
Vinum is a Volume Manager, a
From a user viewpoint, Vinum looks almost exactly the same as a disk, but in addition to the disks there is a
Vinum implements a four-level hierarchy of objects:
Plexes can include multiple subdisks spread overall drives in the Vinum configuration, so the size of an individual drive does not limit the size of a plex, and thus of a volume.
The way the data is shared across the drives has a strong influence on performance. It's
(рис 12.1) Concatenated organization
An alternative mapping is to divide the
(рис 12.2) Striped organization
Vinum offers two forms of redundant
Mirroring maintains two or more copies of the data on different
The most interesting of the
In the following figure, the numbers in the
(рис 12.3) RAID-5 organization
Compared to mirroring, RAID-5 has the advantage of requiring significantly less
Vinum also offers RAID-4, a simpler variant of RAID-5 which stores all the
Each plex organization has its unique advantages:
The following table
| Plex type | Minimum subdisks | Can add subdisks | Must be equal size | Application |
|---|---|---|---|---|
| concatenated | 1 | yes | no | Large |
| striped | 2 | no | yes | High performance in combination with highly |
| RAID-5 | 3 | no | yes | Highly reliable storage, primarily read access. |
Before you can do anything with Vinum, you need to reserve
8 partitions: # size offset fstype [fsize bsize bps/cpg] c: 6295133 0 unused 0 0 # (Cyl. 0 - 10302) b: 1048576 0 swap 0 0 # (Cyl. 0 - 10302) h: 5246557 1048576 vinum 0 0 # (Cyl. 0 - 10302)
Vinum comes with the base system as a kld. It gets loaded automatically when you run the vinum command. It's possible to build a special kernel that includes Vinum, but this is not recommended: in this case, you will not be able to stop Vinum.
FreeBSD Release 5 includes a new method of starting Vinum. Put the following lines in
/boot/loader.conf:
vinum_load="YES" vinum.autostart="YES"
The first line instructs the
Vinum maintains a configuration database that describes the objects known to an individual system. You create the
The configuration file describes individual Vinum objects. To define a simple volume, you might create a file called, say, configl, containing the following definitions:
drive a device /dev/da1s2h volume myvol plex org concat sd length 512m drive a
This file describes four Vinum objects:
drive line describes a disk partition (drive) and its location relative to the underlying hardware. It is given the symbolic name a. This separation of the symbolic names from the device names allows disks to be moved from one location to another without confusion.volume line describes a volume. The only myvol.plex line defines a plex. The only concat. No name is necessary: the system automatically generates a name from the volume name by adding the suffix .px, where x is the number of the plex in the volume. Thus this plex will be called myvol.p0.sd line describes a subdisk. The minimum specifications are the name of a drive on which to store it, and the length of the subdisk. As with plexes, no name is necessary: the system automatically assigns names derived from the plex name by adding the suffix .sx, where x is the number of the subdisk in the plex. Thus Vinum gives this subdisk the name myvol.p0.s0After processing this file, vinum(8) produces the following output:
vinum -> create config1 1 drives: D a State: up /dev/da1s2h A: 3582/4094 MB (87%) 1 volumes: V myvol State: up Plexes: 1 Size: 512 MB 1 plexes: P myvol.p0 C State: up Subdisks: 1 Size: 512 MB 1 subdisks: S myvol.p0.s0 State: up D: a Size: 512 MB
This output shows the brief listing format of vinum. It is represented graphically in Figure 12-4 .
(рис 12.4) A simple Vinum volume
This figure, and the ones that follow, represent a volume, which contains the plexes, which in turn contain the subdisks. In this trivial example, the volume contains one plex, and the plex contains one subdisk.
You create a file system on this volume in the same way as you would for a conventional disk:
# newfs -U /dev/vinum/myvol /dev/vinum/myvol: 512.0MB (1048576 sectors) block size 16384, fragment size 2048 using 4 cylinder groups of 128.02MB, 8193 blks, 16512 inodes. super-block backups (for fsck -b #) at: 32, 262208, 524384, 786560
This particular volume has no specific advantage over a conventional disk partition. It contains a single plex, so it is not redundant. The plex contains a single subdisk, so there is no difference in
The
drive b device /dev/da2s2h
volume mirror
plex org concat
sd length 512m drive a
plex org concat
sd length 512m drive b
In this example, it was not necessary to specify a definition of drive a again, because Vinum keeps track of all objects in its
2 drives: D a State: up /dev/da1s2h A: 3070/4094 MB (74%) D b State: up /dev/da2s2h A: 3582/4094 MB (87%) 2 volumes: V myvol State: up Plexes: 1 Size: 512 MB V mirror State: up Plexes: 2 Size: 512 MB 3 plexes: P myvol.p0 C State: up Subdisks: 1 Size: 512 MB P mirror.p0 C State: up Subdisks: 1 Size: 512 MB P mirror.p1 C State: initializing Subdisks: 1 Size: 512 MB 3 subdisks: S myvol.p0.s0 State: up D: a Size: 512 MB S mirror.p0.s0 State: up D: a Size: 512 MB S mirror.p1.s0 State: empty D: b Size: 512 MB
рис 12.5shows the structure graphically.
In this example, each plex contains the full 512 MB of
Note the state of mirror.p1 and mirror.p1.s0: initializing and empty respectively. There's a problem when you create two identical plexes: to ensure that they're identical, you need to copy the entire contents of one plex to the other. This process is called reviving, and you perform it with the start command:
vinum -> start mirror.pl vinum[278]: reviving mirror.p1.s0 Reviving mirror.p1.s0 in the background vinum -> vinum[278]: mirror.p1.s0 is up
(рис 12.5) A mirrored Vinum volume
During the start process, you can look at the status to see how far the revive has progressed:
vinum -> list mirror.pl.s0 Smirror.pl.s0 State: R43% D: bSize: 512 MB
setupstate keyword in the configuration file. We'll see an example of this below.
At some time after creating a volume, you may decide to add additional plexes. For example, you may want to add a plex to the volume myvol we saw above, putting its subdisk on drive b. The configuration file for this extension would look like:
plex name myvol.p1 org concat volume myvol sd size 1g drive b
To see what has happened, use the recursive listing option -r for the list command:
vinum -> l-r myvol V myvol State: up Plexes: 2 Size: 1024 MB P myvol.p0 C State: up Subdisks: 1 Size: 512 MB P myvol.p1 C State: initializing Subdisks: 1 Size: 1024 MB S myvol.p0.s0 State: up D: a Size: 512 MB S myvol.p1.s0 State: empty D: b Size: 1024 MB
The command l is a list, and the -r option means recursive: it displays all
Note that you can't use the setupstate keyword here. Vinum can't know whether the existing volume contains start command to synchronize the plexes.
After adding a second plex to myvol, it had one plex with 512 MB and another with 1024 MB. It makes sense to have the same size plexes, so the first thing we should do is add a second subdisk to the plex myvol.p0.
If you add subdisks to striped, RAID-4 or RAID-5 plexes, you will change the mapping of the data to the disks, which effectively destroys the contents. As a result, you must use the -f option. When you add subdisks to concatenated plexes, the data in the existing subdisks remains
sd name myvol.p0.s1 plex myvol.p0 size 512m drive c
After adding this subdisk, the volume looks like this:
(рис 12.6) An extended Vinum volume
It doesn't look too happy, however:
vinum -> l -r myvol V myvol State: up Plexes: 2 Size: 1024 MB P myvol.p0 C State: corrupt Subdisks: 2 Size: 1024 MB P myvol.p1 C State: initializing Subdisks: 1 Size: 1024 MB S myvol.p0.s0 State: up D: a Size: 512 MB S myvol.p0.s1 State: empty D: c Size: 512 MB S myvol.p1.s0 State: stale D: b Size: 1024 MB
In fact, it's in as good a shape as it ever has been. The first half of myvol still contains the file system that we put on it, and it's as accessible as ever. The trouble here is that there is nothing in the other two subdisks, which are shown
vinum -> setstate up myvol.p0.s1 myvol.p0 vinum -> l -r myvol V myvol State: up Plexes: 2 Size: 1024 MB P myvol.p0 C State: up Subdisks: 2 Size: 1024 MB P myvol.p1 C State: faulty Subdisks: 1 Size: 1024 MB S myvol.p0.s0 State: up D: Size: 512 MB S myvol.p0.s1 State: up D: Size: 512 MB S myvol.p1.s0 State: stale D: Size: 1024 MB vinum -> saveconfig
The command setstate changes the state of individual objects without updating those of related objects. For example, you can use it to change the state of a plex to up even if all the subdisks are down. If used incorrectly, it can can cause severe saveconfig for that, after you're sure you have the correct states. Read the man page before using them for any other purpose.
Next you start the second plex:
vinum -> start myvol.p1 Reviving myvol.p1.s0 in the background vinum[446]: reviving myvol.p1.s0 vinum -> vinum[446]: myvol.p1.s0 is up some time later l command for previous prompt 3 drives: D a State: up /dev/da1s2h A: 3582/4094 MB (87%) D b State: up /dev/da2s2h A: 3070/4094 MB (74%) D c State: up /dev/da3s2h A: 3582/4094 MB (87%) 1 volumes: V myvol State: up Plexes: 2 Size: 1024 MB 2 plexes: P myvol.p0 C State: up Subdisks: 2 Size: 1024 MB P myvol.p1 C State: up Subdisks: 1 Size: 1024 MB 3 subdisks: S myvol.p0.s0 State: up D: a Size 512 MB S myvol.p1.s0 State: up D: b Size 1024 MB S myvol.p0.s1 State: up D: c Size 512 MB
The message telling you that myvol.p1.s0 is up comes after the prompt, so the next command doesn't have a prompt. At this point you have a fully mirrored, functional volume, 1 GB in size. If you now look at the contents, though, you see:
# df /mnt Filesystem 1048576-blocks Used Avail Capacity Mounted on /dev/vinum/myvol 503 1 461 0% /mnt
The volume is now 1 GB in size, but the file system on the volume is still only 512 MB. To expand it, use growfs:
# umount /mnt
# growfs /dev/vinum/myvol
We strongly recommend you to make a backup before growing the Filesystem
Did you backup your data (Yes/No) ? Yes
new file systemsize is: 524288 frags
Warning: 261920 sector(s) cannot be allocated.
growfs: 896.1MB (1835232 sectors) block size 16384, fragment size 2048
using 7 cylinder groups of 128.02MB, 8193 blks, 16512 inodes.
super-block backups (for fsck -b #) at:
1048736, 1310912, 1573088
# mount /dev/vinum/myvol /mnt
# df /mnt
Filesystem 1048576-blocks Used Avail Capacity Mounted on
/dev/vinum/myvol 881 1 809 0% /mnt
The
drive c device /dev/da3s2h
drive d device /dev/da4s2h
volume stripe
plex org striped 480k
sd length 128m drive a
sd length 128m drive b
sd length 128m drive c
sd length 128m drive d
When creating striped plexes for the UFS file system, ensure that the stripe size is a multiple of the file system
Vinum requires that a striped plex have an integral number of stripes. You don't have to calculate the size exactly, though: if the size of the plex is not a multiple of the stripe size, Vinum trims off the remaining partial stripe and prints a console message:
vinum: removing 256 blocks of partial stripe at the end of stripe.p0
As before, it is not necessary to define the drives that are already known to Vinum. After processing this definition, the configuration looks like:
4 drives: D a State: up /dev/da1s2h A: 2942/4094 MB (71%) D b State: up /dev/da2s2h A: 2430/4094 MB (59%) D c State: up /dev/da3s2h A: 3966/4094 MB (96%) D d State: up /dev/da4s2h A: 3966/4094 MB (96%) 3 volumes: V myvol State: up Plexes: 2 Size: 1024 MB V mirror State: up Plexes: 2 Size: 512 MB V stripe State: up Plexes: 1 Size: 511 MB 5 plexes: P myvol.p0 C State: up Subdisks: 1 Size: 512 MB P mirror.p0 C State: up Subdisks: 1 Size: 512 MB P mirror.p1 C State: initializing Subdisks: 1 Size: 512 MB P myvol.p1 C State: up Subdisks: 1 Size: 1024 MB P stripe.p0 S State: up Subdisks: 4 Size: 511 MB 8 subdisks: S myvol.p0.s0 State: up D: a Size: 512 MB S mirror.p0.s0 State: up D: a Size: 512 MB S mirror.p1.s0 State: empty D: b Size: 512 MB S myvol.p1.s0 State: up D: b Size: 1024 MB S myvol.p0.s1 State: up D: c Size: 512 MB S stripe.p0.s0 State: up D: a Size: 127 MB S stripe.p0.s1 State: up D: b Size: 127 MB S stripe.p0.s2 State: up D: c Size: 127 MB S stripe.p0.s3 State: up D: d Size: 127 MB
This volume is represented in Figure 12-7. The darkness of the stripes indicates the position within the plex
(рис 12.7) A striped Vinum volume
With sufficient hardware, it is possible to build volumes that show both increased
drive e device /dev/da5s2h
drive f device /dev/da6s2h
drive g device /dev/da7s2h
drive h device /dev/da8s2h
drive i device /dev/da9s2h
drive j device /dev/da10s2h
volume raid10 setupstate
plex org striped 480k
sd length 102480k drive a
sd length 102480k drive b
sd length 102480k drive c
sd length 102480k drive d
sd length 102480k drive e
plex org striped 480k
sd length 102480k drive f
sd length 102480k drive g
sd length 102480k drive h
sd length 102480k drive i
sd length 102480k drive j
In this example, we have added another five disks for the second plex, so the volume is spread over ten
vinum -> l -r raid10 V raid10 State: up Plexes: 2 Size: 499 MB P raid10.p0 S State: up Subdisks: 5 Size: 499 MB P raid10.p1 S State: up Subdisks: 5 Size: 499 MB S raid10.p0.s0 State: up D: a Size: 99 MB S raid10.p0.s1 State: up D: b Size: 99 MB S raid10.p0.s2 State: up D: c Size: 99 MB S raid10.p0.s3 State: up D: d Size: 99 MB S raid10.p0.s4 State: up D: e Size: 99 MB S raid10.p1.s0 State: up D: f Size: 99 MB S raid10.p1.s1 State: up D: g Size: 99 MB S raid10.p1.s2 State: up D: h Size: 99 MB S raid10.p1.s3 State: up D: i Size: 99 MB S raid10.p1.s4 State: up D: j Size: 99 MB
This assumes the availability of ten disks. It's not essential to have all the components on different disks. You could put the subdisks of the second plex on the same drives as the subdisks of the first plex. If you do so, you should put corresponding subdisks on different drives:
plex org striped 480k sd length 102480k drive a sd length 102480k drive b sd length 102480k drive c sd length 102480k drive d sd length 102480k drive e plex org striped 480k sd length 102480k drive c sd length 102480k drive d sd length 102480k drive e sd length 102480k drive a sd length 102480k drive b
The subdisks of the second plex are offset by two drives from those of the first plex: this helps ensure that the failure of a drive does not cause the same part of both plexes to become unreachable, which would destroy the file system.
Figure 12-8 represents the structure of this volume.
(рис 12.8) A mirrored, striped Vinum volume
Vinum stores configuration information on each drive in essentially the same form as in the configuration files. You can display it with the dumpconfig command. When reading from the
vinum -> dumpconfig
Drive a: Device /dev/da1s2h
Created on bumble.example.org at Tue Nov 26 14:35:12 2002
Config last updated Tue Nov 26 16:12:35 2002
Size: 4293563904 bytes (4094 MB)
volume myvol state up
plex name myvol.p0 state up org concat vol myvol
plex name myvol.p1 state up org concat vol myvol
sd name myvol.p0.s0 drive a plex myvol.p0 len 1048576s driveoffset 265s state up plexoffset 0s
sd name myvol.p1.s0 drive b plex myvol.p1 len 2097152s driveoffset 265s state up plexoffset 0s
sd name myvol.p0.s1 drive c plex myvol.p0 len 1048576s driveoffset 265s state up plexoffset 1048576s
Drive /dev/da1s2h: 4094 MB (4293563904 bytes)
Drive b: Device /dev/da2s2h
Created on bumble.example.org at Tue Nov 26 14:35:27 2002
Config last updated Tue Nov 26 16:12:35 2002
Size: 4293563904 bytes (4094 MB)
volume myvol state up
plex name myvol.p0 state up org concat vol myvol
plex name myvol.p1 state up org concat vol myvol
sd name myvol.p0.s0 drive a plex myvol.p0 len 1048576s driveoffset 265s state up plexoffset 0s
sd name myvol.p1.s0 drive b plex myvol.p1 len 2097152s driveoffset 265s state up plexoffset 0s
sd name myvol.p0.s1 drive c plex myvol.p0 len 1048576s driveoffset 265s state up plexoffset 1048576s
The obvious differences here are the presence of explicit location information and naming (both of which are also allowed, but discouraged, for use by the user) and the information on the states (which are not available to the user). Vinum does not store information about drives in the configuration information: it finds the drives by scanning the configured
When you start Vinum with the vinum start command, Vinum reads the
Installing FreeBSD on Vinum is complicated by the fact that sysinstall and the
A typical disk installation lays out disk partitions in the following manner:
| da0s3a:/file sistem | da0s3c: entire disk |
| da0s3d:swap | |
| da0s3e:/usr file sistem | |
| da0s3f:/var file sistem |
This layout shows three file system partitions and a swap partition, which is not the layout recommended on page 68. We'll look at the reasons for this below.
Each partition corresponds logically to a Vinum subdisk. You could
8 partitions: # size offset fstype [fsize bsize bps/cpg] a: 524288 532480 4.2BSD 2048 16384 94 b: 532215 265 swap c: 8386733 0 unused 0 0 #"raw" part, don't edit e: 4194304 1056768 4.2BSD 2048 16384 89 f: 3135661 5251072 4.2BSD 2048 16384 89
To convert to Vinum, use bsdlabel with the -e (edit label) option to create a volume of type vinum that maps the c partition:
h: 8386733
After this, you have the following situation:
| da0s3b: swap | da0s3c: entire disk | da0s3h: vinum drive |
| da0s3a:/file system | ||
| da0s3a:/usr file | ||
| da0s3f:/var file sistem |
The
drive rootdev device /dev/da0s2h volume swap plex org concat # b: 532215 265 swap sd len 532215s driveoffset 265s drive rootdev volume root plex org concat # a: 524288 532480 4.2BSD 2048 16384 94 sd len 524288s driveoffset 532480s drive rootdev volume usr plex org concat # e: 4194304 1056768 4.2BSD 2048 16384 89 sd len 4194304s driveoffset 1056768s drive rootdev volume var plex org concat # f: 3135661 5251072 4.2BSD 2048 16384 89 sd len 3135661s driveoffset 5251072s drive rootdev
The comments are the corresponding lines from the bsdlabel output. They show the corresponding values for size and offset. Run vinum create against this file, and confirm that you have the volumes /, /usr and /var.
Next, ensure that you are set up to start Vinum with the new method. You should have the following lines in /boot/loader.conf:
vinum_load="YES" vinum.autostart="YES"
Then reboot to fsck against the volumes, using the -n option to tell fsck not to correct any errors it finds. You should see something like this:
# fsck -n -t ufs /dev/vinum/usr ** /dev/vinum/usr (NO WRITE) ** Last Mounted on /usr ** Phase 1 - Check Blocks and Sizes ** Phase 2 - Check Pathnames ** Phase 3 - Check Connectivity ** Phase 4 - Check Reference Counts ** Phase 5 - Check Cyl groups 35323 files, 314115 used, 718036 free (4132 frags, 89238 blocks, 0.4% fragmentation)
If there are any errors, they will probably be because you have miscalculated size or offset. You'll see something like this:
# fsck -n -t ufs /dev/vinum/usr ** /dev/vinum/usr (NO WRITE) Cannot find file system superblock /dev/vinum/usr: CANNOT FIGURE OUT FILE SYSTEM PARTITION
You need to do this in
If all is well, remount the root file system read-write:
# mount -u /
Then edit /etc/fstab to point to the new devices. For this example, /etc/fstab might initially contain:
# $Id: fstab,v 1.3 2002/11/14 06:48:16 grog Exp $ # Device Mountpoint FStype Options Dump Pass# /dev/da0s4a / ufs rw 1 1 /dev/da0s4b none swap sw 0 0 /dev/da0s4e /usr ufs rw 1 1 /dev/da0s4f /var ufs rw 1 1
Change it to reflect the Vinum volumes:
# $Id: fstab,v 1.3 2002/11/14 06:48:16 grog Exp $ # Device Mountpoint FStype Options Dump Pass# /dev/vinum/swap none swap sw 0 0 /dev/vinum/root / ufs rw 1 1 /dev/vinum/usr /usr ufs rw 1 1 /dev/vinum/var /var ufs rw 1 1 /dev/da0s4b none swap sw 0 0 /dev/da0s4e /usr ufs rw 1 1 /dev/da0s4f /var ufs rw 1 1
Then reboot again to mount the root file system from /dev/vinum/root. You can also optionally remove all the UFS partitions except the root partition. The
Once you have reached this stage, you can add additional plexes to the volumes, or you can extend the plexes (and thus the size of the file system) by adding subdisks to the plexes, as discussed on page 229.
One of the purposes of Vinum is to be able to recover from hardware problems. If you have chosen a redundant storage configuration, the failure of a single component will not stop the volume from working. In many cases, you can replace the components without down time.
If a drive fails, perform the following steps:
If you want to have this freedom with a hot-pluggable drive, you must stop Vinum and restart it.
drive data3 device /dev/da3s1h
Then enter:
# vinum create configfile
vinum -> l -r test V test State: up Plexes: 2 Size: 30 MB Ptest.p0 C State: up Subdisks: 1 Size: 30 MB Ptest.p1 C State: faulty Subdisks: 1 Size: 30 MB Stest.p0.s0 State: up PO: 0 B Size: 30 MB Stest.p1.s0 State: obsolete PO: 0 B Size: 30 MB vinum -> start test.p1.s0 Reviving test.p1.s0 in the background vinum -> vinum[295]: reviving test.p1.s0 this message appears after the prompt (some time later) vinum[295]: test.p1.s0 is up
If you're running your root file system on a Vinum volume, you can survive the failure of the boot volume if it is mirrored with at least two concatenated plexes each containing only one subdisk. Under normal circumstances, you can carry on running as if nothing had happened, but obviously you will no longer be able to reboot from that disk. Instead, boot from the other disk.
The root file system also has individual UFS partitions, so you have a choice of what you mount. For example, if your root file system has UFS partitions /dev/da0s4a and /dev/da1s4a, you can mount either of these partitions or /dev/vinum/root. Never mount more than one of them, otherwise you can cause
An even more insidious way to
Sometimes you might want to move a set of Vinum disks to a different FreeBSD machine. This is simple, as long as there are no name conflicts between the objects on the Vinum disks and any other Vinum objects you may already have on the system. Simply connect the disks and start Vinum. You don't need to put the disks in any particular location, and you don't need to run vinum create: Vinum stores the configuration on the drives themselves, and when it starts, it locates it accordingly.
The vinum command offers a large number of subcommands intended for specific purposes. It's easy to abuse them. Here are some things you should not do:
2 drives: D da2 State: up /dev/da1s1h A: 3582/4094 MB (87%) D dal State: up /dev/da1s2h A: 3582/4094 MB (87%)
This is clearly not helpful.
Для получения официальных документов о завершении программы дополнительного профессионального образования (удостоверения о повышении квалификации, дипломов о профессиональной переподготовке и MBA) необходимо предоставить:
Внимание! Вы можете не заказывать доставку бумажной версии официального документы, а скачать его в электронном виде и распечатать самостоятельно. Информация о выданном документе в течение 1 месяца загружается в Федеральную информационную систему «Федеральный реестр сведений о документах об образовании и (или) о квалификации, документах об обучении» - ФИС ФРДО.
Доступ на новый сайт осуществляется с использованием адреса электронной почты, который был указан вами при регистрации на "старом". Мы постарались перенести все ваши данные с прежнего ресурса, однако не исключена вероятность потери части информации.
При возникновении проблемы со входом, воспользуйтесь функцией сброса пароля
Если вы обнаружите несоответствия, пожалуйста, сообщите нам.