Configuring Logical Volume Management (LVM) on Linux for zSeries

Abstract

Minidisks on z/VM cannot span more than one physical DASD volume. Without a volume management system, this limits the size of a file system on Linux for zSeries to the size of a DASD volume. For a 3390 model 3, this translates to 2.3GB of available space for a Linux file system.

Volume management systems allow multiple DASD devices to be combined into a single Linux file system (and thereby overcome the single DASD volume size limit). This Tip describes how to configure Logical Volume Management (LVM) for Linux on zSeries.

Contents


LVM concepts
LVM has its own terminology, which we describe briefly here:
    • A DASD volume is called a physical volume (PV), because that’s the volume where the data is physically stored.
    • The PV is divided into several physical extents (PE) of the same size. The PEs are like blocks on the PV.
    • Several PVs make up a volume group (VG), which becomes a pool of PEs available for the logical volume (LV).
    • The LVs appear as normal devices in /dev/ directory. You can add or delete PVs to/from a VG, and increase/decrease your LVs.
The following figure illustrates LVM components:

LVM components

LVM can be exercised either from the command line, or by using the setup tools like YaST on SLES. The line commands are common to all Linux distributions so we describe the LVM line commands to use. Spreading the LVM minidisks (mdisk) over several packs allows z/VM to issue multiple I/O's versus one I/O per full pack (complete DASD) mdisk. LVMs can perform much better then a single large mdisk.

Preparing DASD devices for LVM

Before the physical volumes can be created, they must first be formatted and partitioned for zSeries Linux. This is done using the dasdfmt and fdasd commands.

    1. To see the DASD devices recognized by Linux, issue the following command:
      # cat /proc/dasd/devices
      0201(ECKD) at ( 94: 0) is dasda : active at blocksize: 4096, 36000 blocks, 140 MB
      0202(ECKD) at ( 94: 4) is dasdb : active at blocksize: 4096, 564840 blocks, 2206 MB
      0203(ECKD) at ( 94: 8) is dasdc : active at blocksize: 4096, 36000 blocks, 140 MB
      0204(ECKD) at ( 94: 12) is dasdd : active at blocksize: 4096, 36000 blocks, 140 MB
    2. To format a single DASD device, a block size of 4 KB is recommended. Use the following command:
      # dasdfmt -b 4096 -d cdl -f /dev/dasdc
      Drive Geometry: 200 Cylinders * 15 Heads = 3000 Tracks
      I am going to format the device /dev/dasdc in the following way:
      Device number of device : 0x203
      Labelling device : yes
      Disk label : VOL1
      Disk identifier : 0X0203
      Extent start (trk no) : 0
      Extent end (trk no) : 2999
      Compatible Disk Layout : yes
      Blocksize : 4096
      --->> ATTENTION! <<---
      All data of that device will be lost.
      Type "yes" to continue, no will leave the disk untouched:
      yes
      Formatting the device. This may take a while (get yourself a coffee).
      Finished formatting the device.
      Rereading the partition table... ok

      Answer yes to the query.
    3. To create a single partition from a formatted DASD, use the -a flag of the fdasd command. If the -a flag is omitted, an interactive formatting session similar to the PC fdisk command is invoked, as follows:
      # fdasd -a /dev/dasdc
      auto-creating one partition for the whole disk...
      writing volume label...
      writing VTOC...
      rereading partition table..
Repeat the dasdfmt and fdasd commands for each DASD device to be used by LVM.

Setting up LVM

Once the DASD devices have been formatted and partitioned, LVM can be installed on the devices. Use the following commands to create a logical volume consisting of the /dev/dasdc1 and /dev/dasdd1 devices.

    1. Create physical volumes for each DASD that will be included in the logical volume. This can be done for all DASD by using one command, or one at a time by using multiple pvcreate commands, as follows:
      # pvcreate /dev/dasdc1 /dev/dasdd1
      pvcreate -- physical volume "/dev/dasdc1" successfully created
      pvcreate -- physical volume "/dev/dasdd1" successfully create
    2. Show the currently defined physical volumes by using the pvscan command:
      # pvscan
      pvscan -- reading all physical volumes (this may take a while...)
      pvscan -- inactive PV "/dev/dasdc1" is in no VG [140.53 MB]
      pvscan -- inactive PV "/dev/dasdd1" is in no VG [140.53 MB]
      pvscan -- total: 2 [281.06 MB] / in use: 0 [0] / in no VG: 2 [281.06 MB]
    3. Create the volume group by using the vgcreate command. All physical volumes to be included in the group must be specified in the command, as follows:
      # vgcreate lvmdata /dev/dasdc1 /dev/dasdd1
      vgcreate -- INFO: using default physical extent size 4 MB
      vgcreate -- INFO: maximum logical volume size is 255.99 Gigabyte
      vgcreate -- doing automatic backup of volume group "lvmdata"
      vgcreate -- volume group "lvmdata" successfully created and activated
    4. Display the volume group just created by using the vgdisplay command, as follows:
      # vgdisplay /dev/lvmdata
      --- Volume group ---
      VG Name lvmdata
      VG Access read/write
      VG Status available/resizable
      VG # 0
      MAX LV 256
      Cur LV 0
      Open LV 0
      MAX LV Size 255.99 GB
      Max PV 256
      Cur PV 2
      Act PV 2
      VG Size
      272 MB
      PE Size 4 MB
      Total PE 68
      Alloc PE / Size 0 / 0
      Free PE / Size 68 / 272 MB
      VG UUID fxozbU-5VqJ-v5FG-LfIV-JcyK-1Jbh-KHXd2N


      The reported
      VG SIZE is used in the next step
    5. Create a logical volume using the VG SIZE noted above:
      # lvcreate -L 272M -n vol1 lvmdata
      lvcreate -- doing automatic backup of "lvmdata"
      lvcreate -- logical volume "/dev/lvmdata/vol1" successfully created
    6. Display the logical volume just created by using the lvdisplay command, as follows:
      #
      lvdisplay /dev/lvmdata/vol1
      --- Logical volume ---
      LV Name /dev/lvmdata/vol1
      VG Name lvmdata
      LV Write Access read/write
      LV Status available
      LV # 1
      # open 0
      LV Size 272 MB
      Current LE 68
      Allocated LE 68
      Allocation next free
      Read ahead sectors 1024
      Block device 58:00
Creating a file system on the logical volume

After the logical volume is created, a file system can be installed on it. For the ext3 file system, use the mkfs.ext3 or, as in the following example, the mke2fs command:
# mke2fs -j /dev/lvmdata/vol1

The file system can now be mounted, as follows:
# mkdir /data
#
mount /dev/lvmdata/vol1 /data

Special Notices

This material has not been submitted to any formal IBM test and is published AS IS. It has not been the subject of rigorous review. IBM assumes no responsibility for its accuracy or completeness. The use of this information or the implementation of any of these techniques is a client responsibility and depends upon the client's ability to evaluate and integrate them into the client's operational environment.

Profile

Publish Date
13 January 2003

Last Update
07 October 2009


Rating:
(based on 8 reviews)


Author(s)

IBM Form Number
TIPS0128