UNIX System Administration Handbook - Evi Nemeth [95]
# vgdisplay /dev/vg01
--- Volume groups ---
VG Name /dev/vg01
VG Write Access read/write
VG Status available
...
Once your disks have all been added to a convenient volume group, you can split the volume group’s pool of disk space back into logical volumes. The lvcreate command creates a new logical volume. Specify the size of the volume in megabytes with the -L flag or in logical extents with the -l flag. The logical extent size is the same as the physical extent size described above and is typically 4MB per extent unless you specified a different value to vgcreate. Sizes specified in megabytes will be rounded up to the nearest multiple of the logical extent size.
In the sequence below, we specify the size of the backup root (1GB) and swap space (1GB) in megabytes.13 We obtain the remaining number of logical extents from the vgdisplay command and assign them to the third logical volume. The default name for a logical volume is /dev/vgXX/lvolN, where XX is the volume group number and N is an increasing number. You can change the name of the logical volume to something more descriptive with the -n flag, but we just used the default names.
If you plan to use a logical volume as a boot or swap device or to store system core dumps, you must specify contiguous allocation and turn off bad block remapping with the -C and -r flags to lvcreate, as we do below.
# lvcreate -C y -r n -L 1024 /dev/vg01
Logical volume "/dev/vg01/lvol1" has been successfully created with character
device "/dev/vg01/rlvol1".
Logical volume "/dev/vg01/lvol1" has been successfully extended.
Volume Group configuration for /dev/vg01 has been saved in
/etc/lvmconf/vg01.conf
# lvcreate -C y -r n -L 1024 /dev/vg01
Logical volume "/dev/vg01/lvol2" has been successfully created with character
device "/dev/vg01/rlvol2".
...
# lvcreate -l 2676 /dev/vg01
Logical volume "/dev/vg01/lvol3" has been successfully created with character
device "/dev/vg01/rlvol3".
...
We must run the lvlnboot command to notify the system of the new root and swap volumes. See the man page for lvlnboot for more information about the special procedures for creating boot, swap, and dump volumes.
# lvlnboot -r /dev/vg01/lvol1
Volume Group configuration for /dev/vg01 has been saved in
/etc/lvmconf/vg01.conf
# lvlnboot -s /dev/vg01/lvol2
Volume Group configuration for /dev/vg01 has been saved in
/etc/lvmconf/vg01.conf
Another common way to create a logical volume is to use lvcreate to create a zero-length volume and then use lvextend to add storage to it. That way, you can specify exactly which physical volumes in the volume group should compose the logical volume. If you use lvcreate to allocate space, it simply uses free extents from any physical volumes in the volume group, which is good enough for most situations.
Once the logical volumes have been created, verify them by running vgdisplay -v /dev/vg01 to double-check their sizes and make sure they were set up correctly. At this point, you can also determine which logical volumes a particular physical volume belongs to with pvdisplay -v /dev/dsk/c0t3d0. The output of pvdisplay in verbose mode can be very long, so pipe it through a pager such as more.
After you have defined the logical volumes, you can create filesystems within them with the newfs command. The default filesystem type is specified in /etc/default/fs and is typically vxfs, the Veritas filesystem. You can override the filesystem type with the -F option to most filesystem-related commands. Another option is hfs, which is HP-UX’s version of the Berkeley Fast File System (the default on most versions of UNIX). HFS is mostly there for backward compatibility; VXFS is a better choice for new installations.
newfs takes the character (raw) device associated with the target logical volume as a command-line argument. In our example:
# newfs -F vxfs /dev/vg01/rlvol1
version 3 layout
1048576 sectors, 1048576 blocks of size 1024, log size
1024 blocks
unlimited inodes, 1048576 data blocks, 1047224 free data blocks
32 allocation units of 32768