148 IBM z/VM and Linux on IBM System z: Virtualization Cookbook for Red Hat Enterprise Linux 4
The minidisk is now ready for you to use in the logical volume. If you are creating a new
logical volume, see 11.1.4, “Creating the logical volume and file system” on page 148. If you
are extending an existing logical volume, skip ahead to 11.1.5, “Extending an existing logical
volume” on page 150.
11.1.4 Creating the logical volume and file system
The overall steps involved in creating a logical volume are:
1. Create physical volumes from the DASD.
2. Create a volume group.
3. Create a logical volume.
4. Make a file system from the logical volume.
Creating a physical volume from the new DASD
In Example 11-6, the pvcreate command initializes DASD for LVM use. Initialize the new
DASD partition, and verify with the pvdisplay command.
Example 11-6 Using pvcreate and pvdisplay
# pvcreate /dev/dasdd1
Physical volume "/dev/dasdd1" successfully created
# pvdisplay
--- NEW Physical volume ---
PV Name /dev/dasdd1
VG Name
PV Size 2.09 GB
Creating a single volume group
This section describes how to create a new volume group in an LVM. If you would like to
extend an existing LVM, skip ahead to the next section “Extending an existing logical volume”
on page 150.
In Example 11-7, use the vgcreate command to create a volume group named vg0 from the
physical volume. Use the vgdisplay command to verify.
Example 11-7 Using vgcreate and vgdisplay
# vgcreate vg0 /dev/dasdd1
Volume group "vg0" successfully created
# vgdisplay
--- Volume group ---
VG Name vg0
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 1
VG Access read/write
VG Status resizable
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
Chapter 11. Miscellaneous recipes 149
VG Size 2.08 GB
PE Size 4.00 MB
Total PE 533
Alloc PE / Size 0 / 0
Free PE / Size 533 / 2.08 GB
VG UUID 7mfjvz-6NRc-FyqL-98xa-rPwt-s70I-9YpzoI
In this example, there are 533 free extents. The default extent size is 4 MB, therefore this
gives you approximately 2 GB of free space.
Creating a single logical volume
Use the lvcreate command to create a logical volume, as Example 11-8 shows. The -l 533
flag specifies to use all free extents in this example. The -n lv0 specifies the name of the
logical volume. The last argument vg0 specifies the name of the volume group from which you
can create the logical volume. Use the lvdisplay command to verify.
Example 11-8 Using lvcreate and lvdisplay
# lvcreate -l 533 -n lv0 vg0
Logical volume "lv0" created
# lvdisplay
--- Logical volume ---
LV Name /dev/vg0/lv0
VG Name vg0
LV UUID lfComT-fX4O-3JHz-95hH-aCdO-Ms2d-eBt68Y
LV Write Access read/write
LV Status available
# open 0
LV Size 2.08 GB
Current LE 533
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 253:0
Making a file system from the logical volume
You have a logical volume. Use the mke2fs command to create a file system on it. The -j flag
adds a journal, therefore it is of type ext3 as Example 11-9 shows.
Example 11-9 Using mke2fs
# mke2fs -j /dev/vg0/lv0
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
273088 inodes, 545792 blocks
27289 blocks (5.00%) reserved for the super user

Get IBM z/VM and Linux on IBM System z: Virtualization Cookbook for Red Hat Enterprise Linux 4 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.