CLASS="sect1" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" >

13.1. Setting up LVM on three SCSI disks

For this recipe, the setup has three SCSI disks that will be put into a logical volume using LVM. The disks are at /dev/sda, /dev/sdb, and /dev/sdc.

13.1.1. Preparing the disks

Before you can use a disk in a volume group you will have to prepare it:

WarningWarning!
 

The following will destroy any data on /dev/sda, /dev/sdb, and /dev/sdc

Run pvcreate on the disks

# pvcreate /dev/sda
# pvcreate /dev/sdb
# pvcreate /dev/sdc
          
This creates a volume group descriptor area (VGDA) at the start of the disks.

13.1.2. Setup a Volume Group

  1. Create a volume group
    
# vgcreate my_volume_group /dev/sda /dev/sdb /dev/sdc/
                  

  2. Run vgdisplay to verify volume group
    
# vgdisplay
    # vgdisplay
    --- Volume Group ---
    VG Name	              my_volume_group
    VG Access             read/write
    VG Status             available/resizable
    VG #                  1
    MAX LV                256
    Cur LV                0
    Open LV               0
    MAX LV Size           255.99 GB
    Max PV                256
    Cur PV                3
    Act PV                3
    VG Size               1.45 GB
    PE Size               4 MB
    Total PE              372
    Alloc PE / Size       0 / 0
    Free  PE / Size       372/ 1.45 GB
    VG UUID               nP2PY5-5TOS-hLx0-FDu0-2a6N-f37x-0BME0Y
                  
    The most important things to verify are that the first three items are correct and that the VG Size item is the proper size for the amount of space in all four of your disks.

13.1.3. Creating the Logical Volume

If the volume group looks correct, it is time to create a logical volume on top of the volume group.

You can make the logical volume any size you like. (It is similar to a partition on a non LVM setup.) For this example we will create just a single logical volume of size 1GB on the volume group. We will not use striping because it is not currently possible to add a disk to a stripe set after the logical volume is created.

# lvcreate -L1G -nmy_logical_volume my_volume_group
lvcreate -- doing automatic backup of "my_volume_group"
lvcreate -- logical volume "/dev/my_volume_group/my_logical_volume" successfully created
          

13.1.4. Create the File System

Create an ext2 file system on the logical volume

# mke2fs /dev/my_volume_group/my_logical_volume
mke2fs 1.19, 13-Jul-2000 for EXT2 FS 0.5b, 95/08/09
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
131072 inodes, 262144 blocks
13107 blocks (5.00%) reserved for the super user
First data block=0
9 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376

Writing inode tables: done
Writing superblocks and filesystem accounting information: done
               

13.1.5. Test the File System

Mount the logical volume and check to make sure everything looks correct

# mount /dev/my_volume_group/my_logical_volume /mnt
# df
Filesystem           1k-blocks      Used Available Use% Mounted on
/dev/hda1              1311552    628824    616104  51% /
/dev/my_volume_group/my_logical_volume
                       1040132        20    987276   0% /mnt
          

If everything worked properly, you should now have a logical volume with and ext2 file system mounted at /mnt.