Which of the following commands creates a new logical volume in a volume group in Linux?
This chapter 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. Show
Warning: Risks 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. 5.1 Understanding the logical volume manager
LVM enables flexible distribution of hard disk space over several physical volumes (hard disks, partitions, LUNs). 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 storage 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. 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. Figure 5.1: Physical partitioning versus LVM
In LVM, the physical disk partitions that are incorporated in a volume group are called physical volumes (PVs). Within the volume groups in , four logical volumes (LV 1 through LV 4) have been defined, which can be used by the operating system via the associated mount points (MP). 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:
Note: LVM and RAID Even though LVM also supports RAID levels 0, 1, 4, 5 and 6, we recommend using 9 (see Chapter 7, Software RAID configuration). However, LVM works fine with RAID 0 and 1, as RAID 0 is similar to common logical volume management (individual logical blocks are mapped onto blocks on the physical devices). LVM used on top of RAID 1 can keep track of mirror synchronization and is fully able to manage the synchronization process. With higher RAID levels you need a management daemon that monitors the states of attached disks and can inform administrators if there is a problem in the disk array. LVM includes such a daemon, but in exceptional situations such as a device failure, the daemon does not work properly. Warning: IBM Z: LVM root file system If you configure the system with a root file system on LVM or software RAID array, you must place 0 on a separate, non-LVM or non-RAID partition, otherwise the system will fail to boot. The recommended size for such a partition is 500 MB and the recommended file system is Ext4.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. However, keep in mind that working with LVM is different from working with conventional partitions. You can manage new or existing LVM storage objects by using the YaST Partitioner. Instructions and further information about configuring LVM are available in the official LVM HOWTO. 5.2 Creating volume groups
An LVM volume group (VG) organizes the Linux LVM partitions into a logical pool of space. You can carve out logical volumes from the available space in the group. The Linux LVM partitions in a group can be on the same or different disks. You can add partitions or entire disks to expand the size of the group. To use an entire disk, it must not contain any partitions. When using partitions, they must not be mounted. YaST will automatically change their partition type to 1 when adding them to a VG.
5.3 Creating logical volumes
A logical volume provides a pool of space similar to what a hard disk does. To make this space usable, you need to define logical volumes. A logical volume is similar to a regular partition—you can format and mount it. Use The YaST Partitioner to create logical volumes from an existing volume group. Assign at least one logical volume to each volume group. You can create new logical volumes as needed until all free space in the volume group has been exhausted. An LVM logical volume can optionally be thinly provisioned, allowing you to create logical volumes with sizes that overbook the available free space (see for more information).
Procedure 5.1: Setting up a logical volume
5.3.1 Thinly provisioned logical volumes
An LVM logical volume can optionally be thinly provisioned. Thin provisioning allows you to create logical volumes with sizes that overbook the available free space. You create a thin pool that contains unused space reserved for use with an arbitrary number of thin volumes. A thin volume is created as a sparse volume and space is allocated from a thin pool as needed. The thin pool can be expanded dynamically when needed for cost-effective allocation of storage space. Thinly provisioned volumes also support snapshots which can be managed with Snapper—see Chapter 7, System recovery and snapshot management with Snapper for more information. To set up a thinly provisioned logical volume, proceed as described in . When it comes to choosing the volume type, do not choose Normal Volume, but rather Thin Volume or Thin Pool. Thin pool The logical volume is a pool of space that is reserved for use with thin volumes. The thin volumes can allocate their needed space from it on demand. Thin volumeThe volume is created as a sparse volume. The volume allocates needed space on demand from a thin pool. Important: Thinly provisioned volumes in a cluster To use thinly provisioned volumes in a cluster, the thin pool and the thin volumes that use it must be managed in a single cluster resource. This allows the thin volumes and thin pool to always be mounted exclusively on the same node. 5.3.2 Creating mirrored volumes
A logical volume can be created with several mirrors. LVM ensures that data written to an underlying physical volume is mirrored onto a different physical volume. Thus even though a physical volume crashes, you can still access the data on the logical volume. LVM also keeps a log file to manage the synchronization process. The log contains information about which volume regions are currently undergoing synchronization with mirrors. By default the log is stored on disk and if possible on a different disk than are the mirrors. But you may specify a different location for the log, for example volatile memory. Currently there are two types of mirror implementation available: "normal" (non-raid) 4 logical volumes and 5 logical volumes.After you create mirrored logical volumes, you can perform standard operations with mirrored logical volumes like activating, extending, and removing. 5.3.2.1 Setting up mirrored non-RAID logical volumes
To create a mirrored volume use the 6 command. The following example creates a 500 GB logical volume with two mirrors called lv1, which uses a volume group vg1.
Such a logical volume is a linear volume (without striping) that provides three copies of the file system. The 7 option specifies the count of mirrors. The 8 option specifies the size of the logical volumes.The logical volume is divided into regions of the 512 KB default size. If you need a different size of regions, use the 9 option followed by the desired region size in megabytes. Or you can configure the preferred region size by editing the 0 option in the 1 file. 5.3.2.2 Setting up > vgdisplay VG_NAME | grep "Total PE" |