Annotation of wikisrc/guide/lvm.mdwn, revision 1.2

1.1       jdf         1: # NetBSD Logical Volume Manager (LVM) configuration
                      2: 
1.2     ! jdf         3: NetBSD LVM allows logical volume management on NetBSD systems, with a well known
1.1       jdf         4: user interface, which is the same as the Linux LVM2 tools.
                      5: 
1.2     ! jdf         6: NetBSD LVM is built on Linux lvm2tools and libdevmapper, together with a
1.1       jdf         7: BSD-licensed device-mapper kernel driver specially written for NetBSD.
                      8: 
1.2     ! jdf         9: The LVM driver allows the user to manage available disk space effectively and
        !            10: efficiently. Disk space from several disks, and partitions, known as *Physical
        !            11: Volumes*, can be added to *Volume Groups*, which is the pool of available disk
1.1       jdf        12: space for *Logical Partitions* aka Logical Volumes.
                     13: 
                     14: Logical Volumes can be grown and shrunk at will using the LVM utilities.
                     15: 
1.2     ! jdf        16: The basic building block is the Physical Volume. This is a disk, or a part of a
1.1       jdf        17: disk, which is used to store data.
                     18: 
1.2     ! jdf        19: Physical Volumes are aggregated together to make Volume Groups, or VGs.
        !            20: Typically, Volume Groups are used to aggregate storage for the same functional
        !            21: unit. Typical Volume Groups could thus be named `Audio`, `Multimedia` or
        !            22: `Documents`. By segregating storage requirements in this functional way, the
        !            23: same type of resilience and redundancy is applied to the whole of the functional
1.1       jdf        24: unit.
                     25: 
                     26: The steps required to setup a LVM are as follows:
                     27: 
                     28:  1. Install physical media
                     29:  2. Configure kernel support
                     30:  3. Configure system, install tools
                     31:  4. *Optional step*
                     32:     Disklabel each volume member of the LVM
                     33:  5. Initialize the LVM disk devices
                     34:  6. Create a volume group from initialized disks
                     35:  7. Create Logical volume from created Volume group
                     36:  8. Create a filesystem on the new LV device
                     37:  9. Mount the LV filesystem
                     38: 
                     39: 
                     40: This example features a LVM setup on NetBSD/i386.
                     41: 
                     42: ## Anatomy of NetBSD Logical Volume Manager
                     43: 
                     44: ![Anatomy of Logical Volume Management](/guide/images/lvm.png)
                     45: 
                     46:  1. **Volume Group**
1.2     ! jdf        47:        The Volume Group is a disk space pool from which the user creates Logical
        !            48:        Volumes and to which Physical Volumes can be added. It is the basic
1.1       jdf        49:        administration unit of the NetBSD LVM implementation.
                     50: 
                     51:  2. **Physical Volume**
1.2     ! jdf        52:        A physical volume is the basic unit in a LVM structure. Every PV consists of
        !            53:        small disk space chunks called Physical Extends. Every Volume Group must
        !            54:        have at least one PV. A PV can be created on hard disks or hard disk like
1.1       jdf        55:        devices such as raid, ccd, or cgd device.
                     56: 
                     57:  3. **Logical Volume**
1.2     ! jdf        58:        The Logical Volume is a logical partition created from disk space assigned
        !            59:        to the Volume Group. LV can be newfsed and mounted as any other pseudo-disk
        !            60:        device. Lvm tools use functionality exported by the device-mapper driver in
1.1       jdf        61:        the kernel to create the LV.
                     62: 
                     63:  4. **Physical Extents**
1.2     ! jdf        64:        Each physical volume is divided chunks of disk space. The default size is
        !            65:        4MB. Every LV size is rounded by PE size. The LV is created by mapping
1.1       jdf        66:        Logical Extends in the LV to Physical extends in a Volume group.
                     67: 
                     68:  5. **Logical Extents**
1.2     ! jdf        69:        Each logical volume is split into chunks of disk space, known as logical
        !            70:        extents. The extent size is the same for all logical volumes in the volume
1.1       jdf        71:        group.
                     72: 
                     73:  6. **Physical Extents mapping**
1.2     ! jdf        74:        Every LV consists of *LEs* mapped to *PEs* mapped by a target mapping.
1.1       jdf        75:        Currently, the following mappings are defined.
                     76: 
                     77:     * **Linear Mapping**
                     78:       will linearly assign range of PEs to LEs.
1.2     ! jdf        79:          For example it can map 100 PEs from PV 1 to LV 1 and another 100 PEs from
1.1       jdf        80:          PV 0.
                     81: 
                     82:     * **Stripe Mapping**
1.2     ! jdf        83:          will interleave the chunks of the logical extents across a number of
1.1       jdf        84:          physical volumes.
                     85: 
                     86:  7. **Snapshots**
                     87: 
1.2     ! jdf        88:        A facility provided by LVM is 'snapshots'. Whilst in standard NetBSD, the
        !            89:        [fss(3)](http://netbsd.gw.com/cgi-bin/man-cgi?ffs+3+NetBSD-current) driver
        !            90:        can be used to provide file system snapshots at a file system level, the
        !            91:        snapshot facility in the LVM allows the administrator to create a logical
        !            92:        block device which presents an exact copy of a logical volume, frozen at
        !            93:        some point in time. This facility does require that the snapshot be made at
1.1       jdf        94:        a time when the data on the logical volume is in a consistent state.
                     95: 
1.2     ! jdf        96:        *Warning*: Snapshot feature is not fully implemented in LVM in NetBSD and
1.1       jdf        97:        should not be used in production.
                     98: 
                     99: 
                    100: ## Install physical media
                    101: 
1.2     ! jdf       102: This step is at your own discretion, depending on your platform and the hardware
        !           103: at your disposal. LVM can be used with disklabel partitions or even with
1.1       jdf       104: standard partitions created with fdisk.
                    105: 
                    106: From my `dmesg`:
                    107: 
                    108:     Disk #1:
                    109:     probe(esp0:0:0): max sync rate 10.00MB/s
                    110:     sd0 at scsibus0 target 0 lun 0: <SEAGATE, ST32430N SUN2.1G, 0444> SCSI2 0/direct fixed
                    111:     sd0: 2049 MB, 3992 cyl, 9 head, 116 sec, 512 bytes/sect x 4197405 sectors
                    112:     
                    113:     Disk #2
                    114:     probe(esp0:1:0): max sync rate 10.00MB/s
                    115:     sd1 at scsibus0 target 1 lun 0: <SEAGATE, ST32430N SUN2.1G, 0444> SCSI2 0/direct fixed
                    116:     sd1: 2049 MB, 3992 cyl, 9 head, 116 sec, 512 bytes/sect x 4197405 sectors
                    117:     
                    118:     Disk #3
                    119:     probe(esp0:2:0): max sync rate 10.00MB/s
                    120:     sd2 at scsibus0 target 2 lun 0: <SEAGATE, ST11200N SUN1.05, 9500> SCSI2 0/direct fixed
                    121:     sd2: 1005 MB, 1872 cyl, 15 head, 73 sec, 512 bytes/sect x 2059140 sectors
                    122:     
                    123:     Disk #4
                    124:     probe(esp0:3:0): max sync rate 10.00MB/s
                    125:     sd3 at scsibus0 target 3 lun 0: <SEAGATE, ST11200N SUN1.05, 8808 > SCSI2 0
                    126:     sd3: 1005 MB, 1872 cyl, 15 head, 73 sec, 512 bytes/sect x 2059140 sectors
                    127: 
                    128: ## Configure Kernel Support
                    129: 
1.2     ! jdf       130: The following kernel configuration directive is needed to provide LVM device
        !           131: support. It is provided as a kernel module, so that no extra modifications need
        !           132: be made to a standard NetBSD kernel. The dm driver is provided as a kernel
1.1       jdf       133: module, it first appeared in the NetBSD 6.0 release.
                    134: 
1.2     ! jdf       135: If your system doesn't use modules you can enable dm driver in NetBSD by adding
        !           136: this line to kernel configuration file. This will add device-mapper driver to
1.1       jdf       137: kernel and link it as statically linked module.
                    138: 
                    139:     pseudo-device dm
                    140: 
1.2     ! jdf       141: If you do not want to rebuild your kernel only because of LVM support you can
        !           142: use dm kernel module. The devmapper kernel module can be loaded on your system.
1.1       jdf       143: To get the current status of modules in the kernel, the tool
                    144: [modstat(8)](http://netbsd.gw.com/cgi-bin/man-cgi?modstat+8+NetBSD-current)
                    145: is used:
                    146: 
                    147:     vm1# modstat
                    148:     NAME            CLASS   SOURCE  REFS    SIZE    REQUIRES
                    149:     cd9660          vfs     filesys 0       21442   -
                    150:     coredump        misc    filesys 1       2814    -
                    151:     exec_elf32      misc    filesys 0       6713    coredump
                    152:     exec_script     misc    filesys 0       1091    -
                    153:     ffs             vfs     boot    0       163040  -
                    154:     kernfs          vfs     filesys 0       10201   -
                    155:     ptyfs           vfs     filesys 0       7852    -
                    156: 
                    157: You can use
1.2     ! jdf       158: [modload(8)](http://netbsd.gw.com/cgi-bin/man-cgi?modload+8+NetBSD-current) to
1.1       jdf       159: load the dm kernel module by issueing `modload dm`:
                    160: 
                    161:     vm1# modstat
                    162:     NAME            CLASS   SOURCE  REFS    SIZE    REQUIRES
                    163:     cd9660          vfs     filesys 0       21442   -
                    164:     coredump        misc    filesys 1       2814    -
                    165:     dm              misc    filesys 0       14448   -
                    166:     exec_elf32      misc    filesys 0       6713    coredump
                    167:     exec_script     misc    filesys 0       1091    -
                    168:     ffs             vfs     boot    0       163040  -
                    169:     kernfs          vfs     filesys 0       10201   -
                    170:     ptyfs           vfs     filesys 0       7852    -
                    171: 
                    172: ## Configure LVM on a NetBSD system
                    173: 
1.2     ! jdf       174: For using LVM you have to install lvm2tools and libdevmapper to NetBSD system.
1.1       jdf       175: These tools and libraries are not enabled as default.
                    176: 
1.2     ! jdf       177: To enable the build of LVM tools, set `MKLVM=yes` in the `/etc/mk.conf` or
1.1       jdf       178: `MAKECONF` file.
                    179: 
                    180: ## Disklabel each physical volume member of the LVM
                    181: 
1.2     ! jdf       182: Each physical volume disk in LVM will need a special file system established. In
1.1       jdf       183: this example, I will need to disklabel:
                    184: 
                    185:     /dev/rsd0d
                    186:     /dev/rsd1d
                    187:     /dev/rsd2d
                    188:     /dev/rsd3d
                    189: 
1.2     ! jdf       190: It should be borne in mind that it is possible to use the NetBSD vnd driver to
1.1       jdf       191: make standard file system space appear in the system as a disk device.
                    192: 
1.2     ! jdf       193: *Note*: Always remember to disklabel the character device, not the block device,
1.1       jdf       194: in `/dev/r{s,w}d*`
                    195: 
1.2     ! jdf       196: *Note*: On all platforms except i386 where `d` partition is used for this, the
1.1       jdf       197: `c` slice is symbolic of the entire NetBSD partition and is reserved.
                    198: 
1.2     ! jdf       199: You will probably want to remove any pre-existing disklabels on the physical
        !           200: volume disks in the LVM. This can be accomplished in one of two ways with the
1.1       jdf       201: [dd(1)](http://netbsd.gw.com/cgi-bin/man-cgi?dd+1+NetBSD-5.0.1+i386) command:
                    202: 
                    203:     # dd if=/dev/zero of=/dev/rsd0d bs=8k count=1
                    204:     # dd if=/dev/zero of=/dev/rsd1d bs=8k count=1
                    205:     # dd if=/dev/zero of=/dev/rsd2d bs=8k count=1
                    206:     # dd if=/dev/zero of=/dev/rsd3d bs=8k count=1
                    207: 
1.2     ! jdf       208: If your port uses a MBR (Master Boot Record) to partition the disks so that the
        !           209: NetBSD partitions are only part of the overall disk, and other OSs like Windows
        !           210: or Linux use other parts, you can void the MBR and all partitions on disk by
1.1       jdf       211: using the command:
                    212: 
                    213:     # dd if=/dev/zero of=/dev/rsd0d bs=8k count=1
                    214:     # dd if=/dev/zero of=/dev/rsd1d bs=8k count=1
                    215:     # dd if=/dev/zero of=/dev/rsd2d bs=8k count=1
1.2     ! jdf       216:     # dd if=/dev/zero of=/dev/rsd3d bs=8k count=1
1.1       jdf       217: 
1.2     ! jdf       218: This will make all data on the entire disk inaccessible. Note that the entire
        !           219: disk is slice `d` on i386 (and some other ports), and `c` elsewhere (e.g. on
1.1       jdf       220: sparc). See the `kern.rawpartition` sysctl - `3` means `d`, `2` means `c`.
                    221: 
                    222: The default disklabel for the disk will look similar to this:
                    223: 
                    224:     # disklabel -r sd0
                    225:     [...snip...]
                    226:     bytes/sector: 512
                    227:     sectors/track: 63
                    228:     tracks/cylinder: 16
                    229:     sectors/cylinder: 1008
                    230:     cylinders: 207
                    231:     total sectors: 208896
                    232:     rpm: 3600
                    233:     interleave: 1
                    234:     trackskew: 0
                    235:     cylinderskew: 0
                    236:     headswitch: 0           # microseconds
                    237:     track-to-track seek: 0  # microseconds
1.2     ! jdf       238:     drivedata: 0
1.1       jdf       239:     
                    240:     4 partitions:
                    241:     #        size    offset     fstype [fsize bsize cpg/sgs]
                    242:     a:    208896         0     4.2BSD      0     0     0  # (Cyl.      0 -    207*)
                    243:     d:    208896         0     unused      0     0        # (Cyl.      0 -    207*)
                    244: 
1.2     ! jdf       245: You will need to create one *slice* on the NetBSD partition of the disk that
        !           246: consumes the entire partition. The slice must begin at least two sectors after
        !           247: end of disklabel part of disk. On i386 it is `sector` 63. Therefore, the `size`
        !           248: value should be `total sectors` minus 2x `sectors`. Edit your disklabel
1.1       jdf       249: accordingly:
                    250: 
                    251:     # disklabel -e sd0
                    252: 
1.2     ! jdf       253: *Note*: The offset of a slice of type `4.2BSD` must be a multiple of the
1.1       jdf       254: `sectors` value.
                    255: 
1.2     ! jdf       256: *Note*: Be sure to `export EDITOR=[path to your favorite editor]` before
1.1       jdf       257: editing the disklabels.
                    258: 
                    259: *Note*: The slice must be fstype `4.2BSD`.
                    260: 
1.2     ! jdf       261: Because there will only be one slice on this partition, you can recycle the `d`
        !           262: slice (normally reserved for symbolic uses). Change your disklabel to the
1.1       jdf       263: following:
                    264: 
                    265:     3 partitions:
                    266:     #        size   offset    fstype   [fsize bsize   cpg]
                    267:      d:  4197403       65      4.2BSD                       # (Cyl. 1 - 4020*)
                    268: 
1.2     ! jdf       269: Optionally you can setup a slice other than `d` to use, simply adjust
1.1       jdf       270: accordingly below:
                    271: 
                    272:     3 partitions:
                    273:     #        size   offset    fstype   [fsize bsize   cpg]
                    274:      a:  4197403       65      4.2BSD                       # (Cyl. 1 - 4020*)
                    275:      c:  4197405       0       unused     1024  8192        # (Cyl. 0 - 4020*)
                    276: 
1.2     ! jdf       277: Be sure to write the label when you have completed. Disklabel will object to
1.1       jdf       278: your disklabel and prompt you to re-edit if it does not pass its sanity checks.
                    279: 
                    280: ## Create Physical Volumes
                    281: 
1.2     ! jdf       282: Once all disks are properly labeled, you will need to create physical volume on
        !           283: them. Every partition/disk added to LVM must have physical volume header on
        !           284: start of it. All informations, like Volume group where Physical volume belongs
1.1       jdf       285: are stored in this header.
                    286: 
                    287:     # lvm pvcreate /dev/rwd1[ad]
                    288: 
                    289: Status of physical volume can be viewed with the
                    290: [pvdisplay(8)](http://netbsd.gw.com/cgi-bin/man-cgi?pvdisplay+8+NetBSD-current)
                    291: command.
                    292: 
                    293:     # lvm pvdisplay
                    294: 
                    295: ## Create Volume Group
                    296: 
1.2     ! jdf       297: Once all disks are properly labeled with physical volume header, volume group
        !           298: must be created from them. Volume Group is pool of PEs from which administrator
1.1       jdf       299: can create Logical Volumes *partitions*.
                    300: 
                    301:     # lvm vgcreate vg0 /dev/rwd1[ad]
                    302: 
                    303:  * `vg0` is name of Volume Group
                    304:  * `/dev/rwd1[ad]` is Physical Volume
                    305: 
1.2     ! jdf       306: The volume group can be later extended/reduced with
1.1       jdf       307: [vgextend(8)](http://netbsd.gw.com/cgi-bin/man-cgi?vgextend+8+NetBSD-current)
                    308: and
                    309: [vgreduce(8)](http://netbsd.gw.com/cgi-bin/man-cgi?vgreduce+8+NetBSD-current)
                    310: commands. These commands add physical volumes to VG.
                    311: 
                    312:     # lvm vgextend vg0 /dev/rwd1[ad]
                    313:     # lvm vgreduce vg0 /dev/rwd1[ad]
                    314: 
                    315: The status of Volume group can be viewed with the
                    316: [vgdisplay(8)](http://netbsd.gw.com/cgi-bin/man-cgi?vgdisplay+8+NetBSD-current)
                    317: command.
                    318: 
                    319:     # lvm vgdisplay vg0
                    320: 
                    321: ## Create Logical Volume
                    322: 
1.2     ! jdf       323: Once the volume group was created, the administrator can create `logical
1.1       jdf       324: partitions` volumes.
                    325: 
                    326:     # lvm lvcreate  -L 20M -n lv1 vg0
                    327: 
                    328:  * `vg0` is the name of the volume group
                    329:  * `-L 20M` is the size of the logical volume
                    330:  * `-n lv1` is the name of the logical volume
                    331: 
                    332: 
                    333: Logical Volume can be later extended/reduced with the
                    334: [lvextend(8)](http://netbsd.gw.com/cgi-bin/man-cgi?lvextend+8+NetBSD-current)
                    335: and
                    336: [lvreduce(8)](http://netbsd.gw.com/cgi-bin/man-cgi?lvreduce+8+NetBSD-current)
                    337: commands.
                    338: 
                    339:     # lvm lvextend -L+20M /dev/vg0/lv1
                    340:     # lvm lvreduce -L-20M /dev/vg0/lv1
                    341: 
1.2     ! jdf       342: *Note*: To shrink a lv partition you have to shrink filesystem before. See the
        !           343: manpage of
        !           344: [resize_ffs(8)](http://netbsd.gw.com/cgi-bin/man-cgi?resize_ffs+8+NetBSD-current)
1.1       jdf       345: for how to do this.
                    346: 
                    347: The status of Logical Volume can be viewed with the
                    348: [lvdisplay(8)](http://netbsd.gw.com/cgi-bin/man-cgi?lvdisplay+8+NetBSD-current)
                    349: command
                    350: 
                    351:     # lvm lvdisplay lv0/lv1
                    352: 
1.2     ! jdf       353: After reboot, all functional LVs in the defined volume group can be activated
1.1       jdf       354: with the command:
                    355: 
                    356:     # lvm vgchange -a y
                    357: 
                    358: ## Example: LVM with Volume groups located on raid1
                    359: 
1.2     ! jdf       360: The motivation for using raid 1 disk as physical volume disk for Volume Group is
        !           361: disk reliability. With the PV on raid 1 disk it is possible to use Logical
1.1       jdf       362: Volumes even after disk failure.
                    363: 
                    364: ### Loading Device-Mapper driver
                    365: 
1.2     ! jdf       366: Before we can start work with the LVM tools, we have to be sure that NetBSD dm
        !           367: driver was properly compiled into the kernel or loaded as a module. The easiest
        !           368: way to find out if we have dm driver available is to run `modstat`. For more
        !           369: information, see [[Configure Kernel Support
1.1       jdf       370: chapter|guide/lvm#configuring-kernel]].
                    371: 
                    372: ### Preparing raid1 installation
                    373: 
1.2     ! jdf       374: Following the example raid configuration defined in [[Raid 1
        !           375: configuration|guide/rf#configuring-raid]], the user will set up a clean raid1
1.1       jdf       376: disk device with 2 disks in a mirror mode.
                    377: 
                    378: #### Example RAID1 configuration
                    379: 
                    380:     # vi /var/tmp/raid0.conf
                    381:     START array
                    382:     1 2 0
                    383:     
                    384:     START disks
                    385:     /dev/wd2a
                    386:     /dev/wd1a
                    387:     
                    388:     START layout
                    389:     128 1 1 1
                    390:     
                    391:     START queue
                    392:     fifo 100
                    393: 
                    394:     # raidctl -v -C /var/tmp/raid0.conf raid0
                    395:     raid0: Component /dev/wd1a being configured at col: 0
                    396:     Column: 0 Num Columns: 0
                    397:     Version: 0 Serial Number: 0 Mod Counter: 0
                    398:     Clean: No Status: 0
                    399:     Column out of alignment for: /dev/wd2a
                    400:     Number of columns do not match for: /dev/wd2a
                    401:     /dev/wd2a is not clean!
                    402:     raid0: Component /dev/wd1a being configured at col: 1
                    403:     Column: 0 Num Columns: 0
                    404:     Version: 0 Serial Number: 0 Mod Counter: 0
                    405:     Clean: No Status: 0
                    406:     Column out of alignment for: /dev/wd1a
                    407:     Number of columns do not match for: /dev/wd1a
                    408:     /dev/wd1a is not clean!
                    409:     raid0: There were fatal errors
                    410:     raid0: Fatal errors being ignored.
                    411:     raid0: RAID Level 1
                    412:     raid0: Components: /dev/wd2a /dev/wd1a
                    413:     raid0: Total Sectors: 19540864 (9541 MB)
                    414:     # raidctl -v -I 2004082401 raid0
                    415:     # raidctl -v -i raid0
                    416:     Initiating re-write of parity
                    417:     # tail -1 /var/log/messages
                    418:     raid0: Error re-writing parity!
                    419:     # raidctl -v -s raid0
                    420:     Components:
                    421:     /dev/wd2a: optimal
                    422:     /dev/wd1a: optimal
                    423:     No spares.
                    424:     Component label for /dev/wd1a:
                    425:     Row: 0, Column: 1, Num Rows: 1, Num Columns: 2
                    426:     Version: 2, Serial Number: 2004082401, Mod Counter: 7
                    427:     Clean: No, Status: 0
                    428:     sectPerSU: 128, SUsPerPU: 1, SUsPerRU: 1
                    429:     Queue size: 100, blocksize: 512, numBlocks: 19540864
                    430:     RAID Level: 1
                    431:     Autoconfig: No
                    432:     Root partition: No
                    433:     Last configured as: raid0
                    434:     Parity status: DIRTY
                    435:     Reconstruction is 100% complete.
                    436:     Parity Re-write is 100% complete.
                    437:     Copyback is 100% complete.
                    438:     Component label for /dev/wd2a:
                    439:     Row: 0, Column: 1, Num Rows: 1, Num Columns: 2
                    440:     Version: 2, Serial Number: 2004082401, Mod Counter: 7
                    441:     Clean: No, Status: 0
                    442:     sectPerSU: 128, SUsPerPU: 1, SUsPerRU: 1
                    443:     Queue size: 100, blocksize: 512, numBlocks: 19540864
                    444:     RAID Level: 1
                    445:     Autoconfig: No
                    446:     Root partition: No
                    447:     Last configured as: raid0
                    448:     Parity status: DIRTY
                    449:     Reconstruction is 100% complete.
                    450:     Parity Re-write is 100% complete.
                    451:     Copyback is 100% complete.
                    452:             
                    453: 
                    454: After setting up the raid we need to create a disklabel on the raid disk.
                    455: 
                    456: On i386:
                    457: 
                    458:      # disklabel -r -e -I raid0
                    459:     type: RAID
                    460:     disk: raid
                    461:     label: fictitious
                    462:     flags:
                    463:     bytes/sector: 512
                    464:     sectors/track: 128
                    465:     tracks/cylinder: 8
                    466:     sectors/cylinder: 1024
                    467:     cylinders: 19082
                    468:     total sectors: 19540864
                    469:     rpm: 3600
                    470:     interleave: 1
                    471:     trackskew: 0
                    472:     cylinderskew: 0
                    473:     headswitch: 0 # microseconds
                    474:     track-to-track seek: 0 # microseconds
                    475:     drivedata: 0
                    476:     
                    477:     #        size    offset     fstype [fsize bsize cpg/sgs]
                    478:     a:  19540789        65     4.2BSD      0     0     0  # (Cyl.      0 - 18569)
                    479:     d:  19540864         0     unused      0     0        # (Cyl.      0 - 19082*)
                    480: 
                    481: On sparc64:
                    482: 
                    483:     # disklabel -r -e -I raid0
                    484:     [...snip...]
                    485:     total sectors: 19539968
                    486:     [...snip...]
                    487:     2 partitions:
                    488:     #        size    offset     fstype [fsize bsize cpg/sgs]
                    489:     a:  19540793        65     4.2BSD      0     0     0  # (Cyl.      0 -  18799)
                    490:     c:  19539968         0     unused      0     0        # (Cyl.      0 -  19081)
                    491: 
1.2     ! jdf       492: Partitions should be created with offset 65, because sectors < than 65 sector
1.1       jdf       493: are marked as readonly and therefore can't be rewriten.
                    494: 
                    495: ### Creating PV, VG on raid disk
                    496: 
1.2     ! jdf       497: Physical volumes can be created on any block device (i.e., disklike), and on any
        !           498: partition on them. Thus, we can use the `a`, `d`, or on sparc64 `c` partitions.
        !           499: The PV will label the selected partition as LVM-used and add the needed
1.1       jdf       500: metainformation for the LVM to it.
                    501: 
1.2     ! jdf       502: The PV is created on the character disk device, as all other disk operations in
1.1       jdf       503: NetBSD:
                    504: 
1.2     ! jdf       505:     # lvm pvcreate /dev/rraid0a
1.1       jdf       506: 
1.2     ! jdf       507: For our example purpose I will create the `vg00` Volume Group. The first
        !           508: parameter of `vgcreate` is the name of the volume group, and the second is the
        !           509: PV created on the raid. If you later found out that the volume group size is not
1.1       jdf       510: sufficient, and you need more space, you can extend it with `vgextend`:
                    511: 
                    512:     # lvm vgcreate vg00 /dev/rraid0a
                    513:     # lvm vgextend vg00 /dev/rraid1a
                    514: 
1.2     ! jdf       515: **Warning**: If you add a non-raid PV to your Volume Group, your data is not
        !           516: safe anymore. Therefore you should add a raid based PV to VG if you want to keep
1.1       jdf       517: your data safe.
                    518: 
                    519: ### Creating LVs from VG located on raid disk
                    520: 
1.2     ! jdf       521: For our example purpose we will create Logical Volume named lv0. If you later
1.1       jdf       522: found that LV size is not sufficient for you can add it with `lvresize`.
                    523: 
1.2     ! jdf       524: *Note*: You have to resize filesystem, when you have resized LV. Otherwise you
1.1       jdf       525: will not see any filesystem change when you mount LV.
                    526: 
1.2     ! jdf       527: **Warning**: Shrinking of ffs file system is not supported in NetBSD be aware
        !           528: that. If you want to play with file system shrinking you must shrink it before
1.1       jdf       529: you shrink LV.  
                    530: This means that the `-L-*` option is not available in NetBSD.
                    531: 
                    532:     # lvm lvcreate -n lv0 -L 2G vg00
                    533:     # lvm lvresize -L+2G vg00/lv0
                    534: 
1.2     ! jdf       535: All lv device nodes are created in the `/dev/vg00/` directory. File system can
        !           536: be create on LV with this command. After file system creation LV can be mounted
1.1       jdf       537: to system.
                    538: 
                    539:     # newfs -O2 /dev/vg00/rlv0
                    540:     # mount /dev/vg00/lv0 /mnt/
                    541: 
                    542: ### Integration of LV's in to the system
                    543: 
1.2     ! jdf       544: For Proper LVM integration you have to enable lvm rc.d script, which detect LVs
        !           545: during boot and enables them. You have to add entry for Logical Volume to the
1.1       jdf       546: `/etc/fstab` file.
                    547: 
                    548:     # cat /etc/rc.conf
                    549:     [snip]
                    550:     lvm=yes
                    551: 
                    552:     # cat /etc/fstab
                    553:     /dev/wd0a               /       ffs     rw               1 1
                    554:     /dev/vg00/lv0           /lv0/   ffs     rw               1 1
                    555:     [snip]
                    556: 

CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb