Use the system storage manager to manage LVM volumes on CentOS7

Source: Internet
Author: User
Logical Volume Manager (LVM) is an extremely flexible disk management tool that allows you to create logical disk volumes from multiple physical hard drives and resize them without downtime. However, its powerful functions also have their disadvantages: it is difficult to learn to use. compared with managing traditional disk partitions, using multiple command line tools to create LVM involves more complex steps. But there is good news for CentOS/RHEL users. The latest version of CentOS/RHEL7 now comes with the system Storage Manager (also called ssm ).

Logical Volume Manager (LVM) is an extremely flexible disk management tool that allows you to create logical disk volumes from multiple physical hard drives and resize them without downtime. However, its powerful functions also have their disadvantages: it is difficult to learn to use. compared with managing traditional disk partitions, using multiple command line tools to create LVM involves more complex steps.

But there is good news for CentOS/RHEL users. The latest version of CentOS/RHEL 7 now comes with the system Storage Manager (also called ssm), which is a unified command line interface developed by RedHat to manage a variety of storage devices. Currently, there are three types of volume management backends available for ssm: LVM, Btrfs, and Crypt.

In this tutorial, I will demonstrate how to use ssm to manage LVM volumes. You will be surprised to find out how simple it is to create and manage LVM volumes.

Prepare ssm

On the new CentOS/RHEL 7, you must first install the system storage manager.

$ sudo yum install system-storage-manager

First, check the available hard drive and LVM volume information. The following command displays information about existing disk storage devices, storage pools, LVM volumes, and storage snapshots. The output is from the newly installed CentOS 7, which uses the LVM and XFS file systems by default.

$ sudo ssm list

In this example, there are two physical devices ("/dev/sda" and "/dev/sdb"), one storage pool ("centos "), and two LVM volumes ("dev/centos/root" and "/dev/centos/swap") created in the storage pool ").

Add a physical disk to the LVM pool

Add a new physical disk (such as/dev/sdb) to an existing storage pool (such as centos ). To add a new physical disk to an existing storage pool, run the following command:

$ sudo ssm add -p 
 
   
  
 

After a new device is added to the storage pool, the storage pool automatically expands, depending on the size of the device. Check the size of the storage pool named centos, as shown below.

As you can see, the centos storage pool has been successfully expanded from 7.5GB to 8.5 GB. However, at the moment, the disk volumes (such as/dev/centos/root and/dev/centos/swap) in the storage pool do not use larger space. To this end, we need to expand the existing LVM volumes.

Expand LVM volume

If you have extra space in the storage pool, you can expand the existing disk volumes in the storage pool. Therefore, use the resize option of the ssm command.

$ sudo ssm resize -s [size] [volume]

Increase the size of the/dev/centos/root volume to 500 MB.

$ sudo ssm resize -s+500M /dev/centos/root

Check the size of the added existing volume.

$ sudo ssm list volumes

We can verify that the size of the/dev/centos/root volume has increased from 6.7GB to 7.2 GB. However, this does not mean that you can immediately use the extra space in the file system created in the volume. You will find that the file system size ("FS size") is still 6.7 GB.

To enable the file system to identify the increased volume size, you need to "expand" the existing file system itself. There are different tools available to expand the existing file system, depending on which file system you use. For example, there are resize2fs for EXT2/EXT3/EXT4, xfs_growfs for XFS, and Btrfs for btrfs.

In this example, we use CentOS 7 and the XFS file system is created by default. Therefore, we use xfs_growfs to expand the existing XFS file system.

After the XFS file system is expanded, it is verified that the file system occupies 7.2 GB of the entire disk volume.

Create a new LVM pool/Volume

In this example, you may want to see how to create a new storage pool and a new LVM volume on a physical disk drive. If you use a traditional LVM tool, the entire process is quite complex. you need to prepare partitions, create physical volumes, Volume groups, logical volumes, and finally create a file system. However, if ssm is used, the whole process will be completed overnight!

The purpose of the following command is to create a storage pool named mypool, create a mb lvm volume named disk0 in the storage pool, and format the volume using the XFS file system, and mount it to/mnt/test. Now you can see the powerful functions of ssm.

$ sudo ssm create -s 500M -n disk0 --fstype xfs -p mypool /dev/sdc /mnt/test

Verify the created disk volume.

Take a snapshot of the LVM volume

With ssm, you can take snapshots of existing disk volumes. Note: Snapshots are only applicable to backend snapshots that contain volumes. The LVM backend supports the online snapshot function, which means that we do not need to take snapshots of volumes offline. In addition, because the LVM backend of ssm supports LVM2, snapshots can read/write data.

Take a snapshot of an existing LVM volume (such as/dev/mypool/disk0.

$ sudo ssm snapshot /dev/mypool/disk0

Once a snapshot is taken, it is stored as a special snapshot volume, storing all the data when the snapshot is taken in the original volume.

After a snapshot is stored, you can delete the original volume and mount the snapshot volume to access the data in the snapshot.

Note: When you try to mount the snapshot volume when the original volume is mounted, the following error message is displayed.

kernel: XFS (dm-3): Filesystem has duplicate UUID 27564026-faf7-46b2-9c2c-0eee80045b5b - can't mount

Delete LVM volumes

Deleting an existing disk volume or storage pool is as easy as creating a disk volume or storage pool. If you try to delete a mounted volume, ssm will automatically unmount it first. There is no trouble in this regard.

To delete an LVM volume:

$ sudo ssm remove 
 

To delete a storage pool:

$ sudo ssm remove 
 

Conclusion

I hope that you have learned the power of ssm. In an enterprise storage environment, processing a large number of storage devices, disk volumes, and file systems is quite common. Now you can use ssm, a single command line tool, to allow its backend to complete tasks for you, rather than using many different tools to manage a set of storage configurations. Ssm is an essential tool for any system administrator in a complex storage management environment.

Http://xmodulo.com/2014/09/manage-lvm-volumes-centos-rhel-7-system-storage-manager.html.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.