Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How do I manage LVM volumes with ssm on CentOS/RHEL 7?

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you how to manage LVM volumes with ssm on CentOS/RHEL 7. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.

Logical Volume Manager (LVM) is an extremely flexible disk management tool that allows users to create logical disk volumes from multiple physical hard drives and resize them without downtime at all. However, its powerful features also have its drawbacks: it is a bit difficult to learn and use, and using multiple command-line tools to create a LVM involves more complex steps than managing traditional disk partitions.

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

I will demonstrate how to manage LVM volumes with ssm. You'll be amazed at how easy it is to create and manage LVM volumes.

Prepare ssm

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

$sudo yum install system-storage-manager

First, check the information about available hard drives and LVM volumes. 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 created in the storage pool ("dev/centos/root" and "/ dev/centos/swap").

Add physical disks to the LVM pool

You might as well add a new physical disk (such as / dev/sdb) to the existing storage pool (such as centos). The command to add a new physical disk to an existing storage pool is as follows:

$sudo ssm add-p

"when 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.5GB. Currently, however, disk volumes located in the storage pool (such as / dev/centos/root and / dev/centos/swap) do not use larger space. To do this, we need to expand the existing LVM volume.

Expand LVM Volum

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

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

You might as well increase the size of the / dev/centos/root volume by 500MB.

$sudo ssm resize-slots 500m / dev/centos/root

Verify the increased size of the 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.2GB. 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.7GB.

In order for the file system to recognize the increased volume size, you need to "expand" the existing file system itself. There are different tools available to expand existing file systems, depending on which file system you use. For example, there are resize2fs for EXT2/EXT3/EXT4, xfs_growfs for XFS, and btrfs for Btrfs, to name a few.

In this example, we use the CentOS 7 dint XFS file system to create it by default. Therefore, we use xfs_growfs to extend the existing XFS file system.

"after expanding the XFS file system, verify that the file system fully consumes the 7.2GB of the entire disk volume."

Create a new LVM pool / volume

In this example, take a look at how to create a new storage pool and a new LVM volume on a physical disk drive. If you use traditional LVM tools, the whole process is quite complex, you need to prepare partitions, you need to create physical volumes, volume groups, logical volumes, and finally a file system. However, if you use ssm, the whole process can be achieved overnight!

The following command creates a storage pool named mypool, creates a 500MB-sized LVM volume named disk0 in the storage pool, formats the volume using the XFS file system, and mounts it under / mnt/test. You can immediately appreciate the power of ssm.

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

You may wish to verify the disk volumes that have been created.

Take a snapshot of a LVM volume

Using the ssm tool, you can also take snapshots of existing disk volumes. Note that snapshots are applicable only if the backend with volumes supports the snapshot mechanism. The LVM backend supports online snapshots, which means there is no need to take snapshots of volumes offline. In addition, because the LVM backend of ssm supports LVM2, snapshots have read / write capabilities.

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

$sudo ssm snapshot / dev/mypool/disk0

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

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

Please note: when you try to mount a snapshot volume while the original volume is mounted, you will get the following error message.

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

Delete LVM Volum

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 respect.

To delete a LVM volume:

$sudo ssm remove

To delete a storage pool:

$sudo ssm remove

I hope you have seen the power of ssm by now. In an enterprise storage environment, it is quite common to handle a large number of storage devices, disk volumes, and file systems. Instead of worrying about using many different tools to manage a complete set of storage configurations, you can now use a single command-line tool, ssm, to get the back end to do the job for you. Ssm is an absolute must-have tool for any system administrator in a complex storage management environment.

About how to manage LVM volumes with ssm on CentOS/RHEL 7? So much for sharing here. I hope the above content can help you to some extent and learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report