A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.netbsd.org/~haad/lvm_doc.diff below:

+

+Chapter 16. NetBSD Logical Volume Manager configuration

+

+

NetBSD LVM is build on Linux lvm2tools and libdevmapper with device-mapper kernel driver + written for NetBSD.

+

The LVM driver allows the user to manage available disk space. Disk space + from several disks, partitions can be added to “Volume Groups”, which is pool + available disk space for “Logical Partitions” + aka Logical Volumes.

+

The steps required to setup a LVM are as follows:

+

    +
  1. Install physical media

  2. +
  3. Configure kernel support

  4. +
  5. Configure system, install tools

  6. +
  7. +

    + Optional step +

    +

    Disklabel each volume member of the LVM

    +
  8. +
  9. Initialize the LVM disk devices

  10. +
  11. Create a volume group from initialized disks

  12. +
  13. Create Logical volume from created Volume group

  14. +
  15. Create a filesystem on the new LV device

  16. +
  17. Mount the LV filesystem

  18. +

+

This example features a LVM setup on NetBSD/i386 -current.

+

+

+16.1. Anatomy of NetBSD Logical Volume Manager

+

+

+

Figure 16.1. Anatomy of Logical Volume Management

+

+

+


    +
  1. +

    Volume Group

    +

    The Volume Group is the highest level abstraction used within the LVM. It gathers + together a collection of Logical Volumes and Physical Volumes into one administrative + unit.

    +
  2. +
  3. +

    Physical Volume

    +

    A physical volume is typically a hard disk, though it may well just be a device that + 'looks' like a hard disk (eg. a software raid device).

    +
  4. +
  5. +

    Logical Volume

    +

    The equivalent of a disk partition in a non-LVM system. The LV is visible as a + standard block device; as such the LV can contain a file system (eg. /home).

    +
  6. +
  7. +

    Physical Extends

    +

    Each physical volume is divided chunks of data, known as physical extents, these + extents have the same size as the logical extents for the volume group.

    +
  8. +
  9. +

    Logical Extends

    +

    Each logical volume is split into chunks of data, known as logical extents. The extent + size is the same for all logical volumes in the volume group.

    +
  10. +
  11. +

    Physical Extends mapping

    +

    There are couple of general strategies used for mapping “LE's” to + “PE's”.

    + +

    +

    +
  12. +
  13. +

    Snapshots

    +

    A wonderful facility provided by LVM is 'snapshots'. This allows the administrator to + create a new block device which presents an exact copy of a logical volume, frozen at some + point in time. Typically this would be used when some batch processing, a backup for + instance, needs to be performed on the logical volume, but you don't want to halt a live + system that is changing the data. When the snapshot device has been finished with the + system administrator can just remove the device. This facility does require that the + snapshot be made at a time when the data on the logical volume is in a consistent state.

    +

    +

    Warning

    +

    Snapshot feature is not fully implemented in NetBSD and should not be used in + production.

    +

    +
  14. +

+

+

+

+16.2. Install physical media

+

This step is at your own discretion, depending on your platform and the hardware at your + disposal. LVM can be used with disklabel partitions or even with standard + partitions created with fdisk.

+

From my DMESG:

+

Disk #1:
+            probe(esp0:0:0): max sync rate 10.00MB/s
+            sd0 at scsibus0 target 0 lun 0: <SEAGATE, ST32430N SUN2.1G, 0444> SCSI2 0/direct fixed
+            sd0: 2049 MB, 3992 cyl, 9 head, 116 sec, 512 bytes/sect x 4197405 sectors
+            
+            Disk #2
+            probe(esp0:1:0): max sync rate 10.00MB/s
+            sd1 at scsibus0 target 1 lun 0: <SEAGATE, ST32430N SUN2.1G, 0444> SCSI2 0/direct fixed
+            sd1: 2049 MB, 3992 cyl, 9 head, 116 sec, 512 bytes/sect x 4197405 sectors
+            
+            Disk #3
+            probe(esp0:2:0): max sync rate 10.00MB/s
+            sd2 at scsibus0 target 2 lun 0: <SEAGATE, ST11200N SUN1.05, 9500> SCSI2 0/direct fixed
+            sd2: 1005 MB, 1872 cyl, 15 head, 73 sec, 512 bytes/sect x 2059140 sectors
+            
+            Disk #4
+            probe(esp0:3:0): max sync rate 10.00MB/s
+            sd3 at scsibus0 target 3 lun 0: <SEAGATE, ST11200N SUN1.05, 8808 > SCSI2 0
+            sd3: 1005 MB, 1872 cyl, 15 head, 73 sec, 512 bytes/sect x 2059140 sectors

+

+

+

+16.3. Configure Kernel Support

+

The following kernel configuration directive is needed to provide LVM device support. It + is not enabled in the GENERIC kernel:

+

+

Note

+

This driver is only available in haad-dm branch. Therefore you have + to update your src/sys directory to haad-dm branch.

+

+

pseudo-device  dm   # device-mapper device

+

+

+

+16.4. Configure NetBSD system

+

For using LVM you have to install lvm2tools and libdevmapper to NetBSD system. These tools + are not enabled as default.

+

To enable building of LVM tools set MKLVM=yes in mk.conf file.

+

+

Note

+

These tools are only available in haad-dm branch. Therefore you + have to update your src/external/gpl2 directory to haad-dm branch.

+

+

After installation of lvm2tools and libdevmapper /etc/lvm directory + should be created. For debuging purposes it is good to copy + lvm2tools/dist/doc/example.conf there as lvm.conf.

+

+

+

+16.5. Disklabel each physical volume member of the LVM

+

Each physical volume disk in LVM will need a special file system established. In this + example, I will need to disklabel:

+


+            /dev/rsd0d
+            /dev/rsd1d
+            /dev/rsd2d
+            /dev/rsd3d
+        

+

+

Note

+

Always remember to disklabel the character device, not the block device, in + /dev/r{s,w}d*

+

+

+

Note

+

On all platforms except i386 where d partition is used for this, + the c slice is symbolic of the entire NetBSD partition and is + reserved.

+

+

You will probably want to remove any pre-existing disklabels on the physical voleme disks + in the LVM. This can be accomplished in one of two ways with the dd(1) command:

+

# dd if=/dev/zero of=/dev/rsd0d bs=8k count=1
+            # dd if=/dev/zero of=/dev/rsd1d bs=8k count=1
+            # dd if=/dev/zero of=/dev/rsd2d bs=8k count=1
+            # dd if=/dev/zero of=/dev/rsd3d bs=8k count=1

+

If your port uses a MBR (Master Boot Record) to partition the disks so that the NetBSD + partitions are only part of the overall disk, and other OSs like Windows or Linux use other + parts, you can void the MBR and all partitions on disk by using the command:

+

# dd if=/dev/zero of=/dev/rsd0d bs=8k count=1
+            # dd if=/dev/zero of=/dev/rsd1d bs=8k count=1
+            # dd if=/dev/zero of=/dev/rsd2d bs=8k count=1
+            # dd if=/dev/zero of=/dev/rsd3d bs=8k count=1 

+

This will make all data on the entire disk inaccessible. Note that the entire disk is + slice d on i386 (and some other ports), and c + elsewhere (e.g. on sparc). See the “kern.rawpartition” sysctl - "3" means "d", + "2" means "c".

+

The default disklabel for the disk will look similar to this:

+

# disklabel -r sd0
+            [...snip...]
+            bytes/sector: 512
+            sectors/track: 63
+            tracks/cylinder: 16
+            sectors/cylinder: 1008
+            cylinders: 207
+            total sectors: 208896
+            rpm: 3600
+            interleave: 1
+            trackskew: 0
+            cylinderskew: 0
+            headswitch: 0           # microseconds
+            track-to-track seek: 0  # microseconds
+            drivedata: 0 
+            
+            4 partitions:
+            #        size    offset     fstype [fsize bsize cpg/sgs]
+            a:    208896         0     4.2BSD      0     0     0  # (Cyl.      0 -    207*)
+            d:    208896         0     unused      0     0        # (Cyl.      0 -    207*)

+

You will need to create one “slice” on the NetBSD partition of the disk + that consumes the entire partition. The slice must begin at least two sectors after end of + disklabel part of disk. On i386 it is sector “63”. Therefore, the + “size” value should be “total sectors” minus 2x + “sectors”. Edit your disklabel accordingly:

+

# disklabel -e sd0

+

+

Note

+

The offset of a slice of type “4.2BSD” must be a multiple of the + “sectors” value.

+

+

+

Note

+

Be sure to export EDITOR=[path to your favorite editor] before + editing the disklabels.

+

+

+

Note

+

The slice must be fstype 4.2BSD.

+

+

Because there will only be one slice on this partition, you can recycle the + d slice (normally reserved for symbolic uses). Change your disklabel to the + following:

+

3 partitions:
+            #        size   offset    fstype   [fsize bsize   cpg]
+            d:  4197403       65      4.2BSD                       # (Cyl. 1 - 4020*)

+

Optionally you can setup a slice other than d to use, simply adjust + accordingly below:

+

3 partitions:
+            #        size   offset    fstype   [fsize bsize   cpg]
+            a:  4197403       65      4.2BSD                       # (Cyl. 1 - 4020*)
+            c:  4197405       0       unused     1024  8192        # (Cyl. 0 - 4020*)

+

Be sure to write the label when you have completed. Disklabel will object to your + disklabel and prompt you to re-edit if it does not pass its sanity checks.

+

+

+

+16.6. Create Physical Volumes

+

Once all disks are properly labeled, you will need to create physical volume on them. + Every partition/disk added to LVM must have physical volume header on start + of it. All informations, like Volume group where Physical volume belongs are stored in this + header.

+

+                # lvm pvcreate /dev/rwd1[ad]
+            

+

Status of physical volume can be viewed with pvdisplay command.

+

+          # lvm pvdisplay
+      

+

+

+

+16.7. Create Volume Group

+

Once all disks are properly labeled with physical volume header, volume group must be + created from them. Volume Group is pool of PE's from which administrator can create Logical + Volumes “partitions”.

+

+            # lvm vgcreate vg0 /dev/rwd1[ad]
+    

+

+

Volume group can be later extended/reduced with vgextend and vgreduce commands. These + commands adds physical volumes to VG.

+

+          # lvm vgextend vg0 /dev/rwd1[ad]
+          
+          # lvm vgreduce vg0 /dev/rwd1[ad]
+      

+

Status of Volume group can be viewed with vgdisplay command.

+

+          # lvm vgdisplay vg0
+      

+

+

+

+16.8. Create Logical Volume

+

Once Volume Group was created administrator can create “logical partitions” + volumes.

+

+            # lvm lvcreate  -L 20M -n lv1 vg0
+        

+

+

Logical Volume can be later extended/reduced with lvextend and lvreduce commands.

+

+          # lvm lvextend -L+20M /dev/vg0/lv1
+          
+          # lvm lvreduce -L-20M /dev/vg0/lv1
+      

+

+

Note

+

To shrink lv partition you have to shrink filesystem before and NetBSD ffs2 doesn't + support it now.

+

+

Status of Logical Volume can be viewed with lvdisplay command.

+

+          # lvm vgdisplay vg0/lv1
+      

+

+


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.3