Contents
This section briefly describes the principles behind Logical Volume Manager (LVM) and its basic features that make it useful under many circumstances. The YaST LVM configuration can be reached from the YaST Expert Partitioner. This partitioning tool enables you to edit and delete existing partitions and create new ones that should be used with LVM.
![]() | |
Using LVM might be associated with increased risk, such as data loss. Risks also include application crashes, power failures, and faulty commands. Save your data before implementing LVM or reconfiguring volumes. Never work without a backup. |
LVM enables flexible distribution of hard disk space over several file systems. It was developed because the need to change the segmentation of hard disk space might arise only after the initial partitioning has already been done during installation. Because it is difficult to modify partitions on a running system, LVM provides a virtual pool (volume group or VG) of memory space from which logical volumes (LVs) can be created as needed. The operating system accesses these LVs instead of the physical partitions. Volume groups can span more than one disk, so that several disks or parts of them can constitute one single VG. In this way, LVM provides a kind of abstraction from the physical disk space that allows its segmentation to be changed in a much easier and safer way than through physical repartitioning.
Figure 4.1, “Physical Partitioning versus LVM” compares physical partitioning (left) with LVM segmentation (right). On the left side, one single disk has been divided into three physical partitions (PART), each with a mount point (MP) assigned so that the operating system can access them. On the right side, two disks have been divided into two and three physical partitions each. Two LVM volume groups (VG 1 and VG 2) have been defined. VG 1 contains two partitions from DISK 1 and one from DISK 2. VG 2 contains the remaining two partitions from DISK 2. In LVM, the physical disk partitions that are incorporated in a volume group are called physical volumes (PVs). Within the volume groups, four logical volumes (LV 1 through LV 4) have been defined, which can be used by the operating system via the associated mount points. The border between different logical volumes need not be aligned with any partition border. See the border between LV 1 and LV 2 in this example.
LVM features:
Several hard disks or partitions can be combined in a large logical volume.
Provided the configuration is suitable, an LV (such as
/usr
) can be enlarged when the free space is
exhausted.
Using LVM, it is possible to add hard disks or LVs in a running system. However, this requires hot-swappable hardware that is capable of such actions.
It is possible to activate a striping mode that distributes the data stream of a logical volume over several physical volumes. If these physical volumes reside on different disks, this can improve the reading and writing performance just like RAID 0.
The snapshot feature enables consistent backups (especially for servers) in the running system.
With these features, using LVM already makes sense for heavily used home PCs or small servers. If you have a growing data stock, as in the case of databases, music archives, or user directories, LVM is especially useful. It allows file systems that are larger than the physical hard disk. Another advantage of LVM is that up to 256 LVs can be added. However, keep in mind that working with LVM is different from working with conventional partitions. Instructions and further information about configuring LVM is available in the official LVM HOWTO.
Starting from kernel version 2.6, LVM version 2 is available, which is downward-compatible with the previous LVM and enables the continued management of old volume groups. When creating new volume groups, decide whether to use the new format or the downward-compatible version. LVM 2 does not require any kernel patches. It makes use of the device mapper integrated in kernel 2.6. This kernel only supports LVM version 2. Therefore, when talking about LVM, this section always refers to LVM version 2.
You create an LVM partition by first clicking
+ then selecting as the partition identifier. After creating all the partitions to use with LVM, click to start the LVM configuration.
If no volume group exists on your system yet, you are prompted to add
one (see Figure 4.2, “Creating a Volume Group”). It is
possible to create additional groups with ,
but usually one single volume group is sufficient.
system
is suggested as a name for the volume group in
which the SUSE® Linux Enterprise Server system files are located.
The physical extent size defines the size of a physical block in the
volume group. All the disk space in a volume group is handled in chunks
of this size. This value is normally set to 4 MB and allows for a
maximum size of 256 GB for physical and logical volumes. The physical
extent size should only be increased, for example, to 8, 16, or 32 MB,
if you need logical volumes larger than 256 GB.
After a volume group has been created, the next dialog (see Figure 4.3, “Physical Volume Setup”) lists all partitions with either the “Linux LVM” or “Linux native” type. No swap or DOS partitions are shown. If a partition is already assigned to a volume group, the name of the volume group is shown in the list. Unassigned partitions are indicated with “--”.
If there are several volume groups, set the current volume group in the selection box to the upper left. The buttons in the upper right enable creation of additional volume groups and deletion of existing volume groups. Only volume groups that do not have any partitions assigned can be deleted. All partitions that are assigned to a volume group are also referred to as a physical volumes.
To add a previously unassigned partition to the selected volume group, first click the partition, then click
. At this point, the name of the volume group is entered next to the selected partition. Assign all partitions reserved for LVM to a volume group. Otherwise, the space on the partition remains unused. Before exiting the dialog, every volume group must be assigned at least one physical volume. After assigning all physical volumes, click to proceed to the configuration of logical volumes.After the volume group has been filled with physical volumes, use the next dialog (see Figure 4.4, “Logical Volume Management”) to define the logical volumes the operating system should use. Set the current volume group in a selection box to the upper left. Next to it, the free space in the current volume group is shown. The list below contains all logical volumes in that volume group. All normal Linux partitions to which a mount point is assigned, all swap partitions, and all already existing logical volumes are listed here. You can use , , and options to manage the logical volumes as needed until all space in the volume group has been exhausted. Assign at least one logical volume to each volume group.
To create a new logical volume (see
Figure 4.5, “Creating Logical Volumes”), click
and fill out the pop-up that opens. For
partitioning, specify the size, file system, and mount point. Normally,
a file system, such as Reiserfs or Ext2, is created on a logical volume
and is then designated a mount point. The files stored on this logical
volume can be found at this mount point on the installed system.
Additionally it is possible to distribute the data stream in the logical
volume among several physical volumes (striping). If these physical
volumes reside on different hard disks, this generally results in a
better reading and writing performance (like RAID 0). However, a
striping LV with n
stripes can only be created
correctly if the hard disk space required by the LV can be distributed
evenly to n
physical volumes. If, for example, only
two physical volumes are available, a logical volume with three stripes
is impossible.
![]() | |
YaST has no chance at this point to verify the correctness of your entries concerning striping. Any mistake made here is apparent only later when the LVM is implemented on disk. |
If you have already configured LVM on your system, the existing logical volumes can be specified now. Before continuing, assign appropriate mount points to these logical volumes too. Click
to return to the YaST Expert Partitioner and finish your work there.If you already have configured LVM and only want to change something, there is an alternative method available. In the YaST Control Center, select
+ . You can manage your LVM system by using the methods already described.The lvresize, lvextend, and lvreduce commands are used to resize logical volumes. See the man pages for each of these commands for syntax and options information.
You can also increase the size of a logical volume by using the YaST partitioner. YaST uses parted(8) to grow the partition.
To extend an LV there must be enough unallocated space available on the VG.
LVs can be extended or shrunk while they are being used, but this may not be true for a filesystem on them. Extending or shrinking the LV does not automatically modify the size of file systems in the volume. You must use a different command to grow the filesystem afterwards. For information about resizing file systems, see Chapter 5, Resizing File Systems.
Make sure you use the right sequence:
If you extend an LV, you must extend the LV before you attempt to grow the filesystem.
If you shrink an LV, you must shrink the filesystem before you attempt to shrink the LV.
To extend the size of a logical volume:
Open a terminal console, log in as the root
user.
If the logical volume contains file systems that are hosted for a virtual machine (such as a Xen VM), shut down the VM.
Dismount the file systems on the logical volume.
At the terminal console prompt, enter the following command to grow the size of the logical volume:
lvextend -L +size
/dev/vgname/lvname
For size
, specify the amount of space you
want to add to the logical volume, such as 10GB. Replace
with the Linux path to the logical volume, such as
/dev/vgname/lvname
/dev/vg1/v1
. For example:
lvextend -L +10GB /dev/vg1/v1
For example, to extend an LV with a (mounted and active) ReiserFS on it by 10GB:
lvextend −L +10G/dev/vgname/lvname
resize_reiserfs −s +10GB −f/dev/vg−name/lv−name
For example, to shrink an LV with a ReiserFS on it by 5GB:
umount/mountpoint−of−LV
resize_reiserfs −s −5GB/dev/vgname/lvname
lvreduce/dev/vgname/lvname
mount/dev/vgname/lvname
/mountpoint−of−LV