To create a new logical volume on an HDLM device:
This subsection explains the procedure for using an HDLM device to create a new logical volume. Use the following procedure to configure the environment shown in Figure 1.
Stop all processes and services that are using the HDLM device.
Create a disk partition on the HDLM device and change the system ID from Linux (83 in hexadecimal representation) to Linux LVM (8e in hexadecimal representation).
The following shows an example of how to create two partitions in /dev/sddlmad (HDLM device):
Edit the /etc/lvm/lvm.conf file.
Edit the device section in the file as shown below to disable the SCSI device configuration and enable the HDLM device configuration:
The following shows an example of editing the /etc/lvm/lvm.conf file.
-
For Red Hat Enterprise Linux 9 or Oracle Linux 9:
Before:
devices { : # global_filter = [ "a/.*/" ] global_filter = [ "r|sddlm[a-p][a-p].*|", "a|/dev/sd|" ] : # types = [ "fd", 16 ] : md_component_detection = 1 : allow_changes_with_duplicate_pvs = 0 : multipath_component_detection=1 : use_devicesfile=1 : }After:
devices { : # global_filter = [ "a/.*/" ] # global_filter = [ "r|sddlm[a-p][a-p].*|", "a|/dev/sd|" ] global_filter = [ "a|sddlm[a-p][a-p].*|", "r|/dev/sd|" ] : # types = [ "fd", 16 ] types = [ "sddlmfdrv", 16 ] : # md_component_detection = 1 md_component_detection=0 : # allow_changes_with_duplicate_pvs = 0 allow_changes_with_duplicate_pvs = 1 : # multipath_component_detection=1 multipath_component_detection=0 : # use_devicesfile=1 use_devicesfile=0 : }Comment out the existing global_filter, types, md_component_detection, allow_changes_with_duplicate_pvs, multipath_component_detection, and use_devicesfile lines, and then add the underlined parts.
Record the original values, because they are necessary when restoring the SCSI device configuration.
For Red Hat Enterprise Linux 8, Oracle Linux 8, Oracle Unbreakable Enterprise Kernel 8 or SUSE LINUX Enterprise Server 15 SP2 or later:
For Red Hat Enterprise Linux 8.8 or later, Oracle Linux 8.8 or later, or SUSE LINUX Enterprise Server 15 SP5 or later, set the value of multipath_component_detection to 0. For details, see NOTES_ON_USING_LVM2=GUID-91F95B7F-B4F1-4A73-A110-536AD5C219CC=5=EN=.html#GUID-91F95B7F-B4F1-4A73-A110-536AD5C219CC .
Before:
devices { : # global_filter = [ "a/.*/" ] global_filter = [ "r|sddlm[a-p][a-p].*|", "a|/dev/sd|" ] : # types = [ "fd", 16 ] : md_component_detection = 1 : allow_changes_with_duplicate_pvs = 0 : }After:
devices { : # global_filter = [ "a/.*/" ] # global_filter = [ "r|sddlm[a-p][a-p].*|", "a|/dev/sd|" ] global_filter = [ "a|sddlm[a-p][a-p].*|", "r|/dev/sd|" ] : # types = [ "fd", 16 ] types = [ "sddlmfdrv", 16 ] : # md_component_detection = 1 md_component_detection=0 : # allow_changes_with_duplicate_pvs = 0 allow_changes_with_duplicate_pvs = 1 : }Comment out the existing global_filter, types, md_component_detection and allow_changes_with_duplicate_pvs lines, and then add the underlined parts.
Record the original values, because they are necessary when restoring the SCSI device configuration.
For SUSE LINUX Enterprise Server 12, SUSE LINUX Enterprise Server 15 SP1 or earlier, Red Hat Enterprise Linux 7, Oracle Linux 7 or Oracle Unbreakable Enterprise Kernel 7:
Specify 1 for allow_changes_with_duplicate_pvs and 0 for write_cache_state. For details, see NOTES_ON_USING_LVM2=GUID-91F95B7F-B4F1-4A73-A110-536AD5C219CC=5=EN=.html.
If you want to use use_lvmetad=0 for operation, specify filter, not global_filter.
Before:
# This section allows you to configure which block devices should # be used by the LVM system. devices { : # filter = [ "a/.*/" ] filter = [ "r|sddlm[a-p][a-p].*|", "a|/dev/sd|" ] : write_cache_state = 1 : # types = [ "fd", 16 ] : md_component_detection = 1 : }After:
# This section allows you to configure which block devices should # be used by the LVM system. devices { : # filter = [ "a/.*/" ] # filter = [ "r|sddlm[a-p][a-p].*|", "a|/dev/sd|" ] filter = [ "a|sddlm[a-p][a-p].*|", "r|/dev/sd|" ] : # write_cache_state = 1 write_cache_state = 0 : # types = [ "fd", 16 ] types = [ "sddlmfdrv", 16 ] : # md_component_detection = 1 md_component_detection=0 : }Comment out the existing filter, write_cache_state, types and md_component_detection lines, and then add the underlined parts.
Record the original values, because they are necessary when restoring the SCSI device configuration.
-
Execute the VG scan.
After editing the file, execute the following command.
# /sbin/vgscan
Delete the LVM cache files.
If the following files exist, delete them:
/etc/lvm/.cache
/etc/lvm/cache/.cache
Create the physical volumes.
The following example shows how to define /dev/sddlmad1 and /dev/sddlmad2 as physical volumes:
# pvcreate /dev/sddlmad1 Physical volume "/dev/sddlmad1" successfully created # pvcreate /dev/sddlmad2 Physical volume "/dev/sddlmad2" successfully created
Create a volume group.
In the following example, the command creates the vg01 volume group by using the physical volumes /dev/sddlmad1 and /dev/sddlmad2:
# vgcreate vg01 /dev/sddlmad1 /dev/sddlmad2 Volume group "vg01" successfully created
Create the logical volume.
In the following example, the command creates the logical volume (lvol1: 100 MB) by using the vg01 volume group:
# lvcreate -L 100M -n lvol1 vg01 Logical volume "lvol1" created
Create a file system.
The following example shows how to use the mke2fs command to create a file system on the lvol1 logical volume:
# mke2fs /dev/vg01/lvol1 Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) 25688 inodes, 102400 blocks 5120 blocks (5.00%) reserved for the super user First data block=1 13 block groups 8192 blocks per group, 8192 fragments per group 1976 inodes per group Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729 Writing inode tables: done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 38 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.Create the directory to which the logical volume is to be mounted.
The following example shows how to create the /mnt/lvol1 directory:
# mkdir /mnt/lvol1
Mount the logical volume.
The following example shows how to mount the logical volume to the /mnt/lvol1 directory:
# mount /dev/vg01/lvol1 /mnt/lvol1