How to Set up and Manage Disk Space with LVM in Linux?
Last Updated : 27 Aug, 2024
Managing disc space in the Linux operating system is essential to keeping a server up to date, especially when storage requirements alter and grow over time by following some major tasks. Logical Volume Manager is a potent tool within the distributed system that Linux offers for managing and configuring disc space. An administrator can group available storage resources and assign them to implement all the logical volumes using the Linux logical volume management system to proceed with the documentation. After that, logical volumes will be utilized to store the internal data in the same way as partitions of a physical hard disc configuration by formatting them with internal file systems after processing the adjustment.
In this article, we'll explore how to set up and manage disk space with LVM in Linux effectively.
How to Set up LVM in Linux?
To set up the LVM in the Linux distribution system, users need to follow the below steps -
Step 1: Install LVM configuration
The majority of Linux distributions provide LVM utilities pre-installed to configure the overall system. If not, though, you can use your manually configured system package manager to install them efficiently.
Commands:
sudo apt-get install lvm1
sudo yum install lvm1
Step 2: Create a Physical Volume system
The storage devices or partitions you wish to use with LVM must first be identified and configured within the system. Use lsblk or fdisk -l to list your discs step-by-step.
Follow the below commands to simplify the processes -
Command: sudo pvcreate /dev/sdX2
Note: /dev/sdX1 is the device name which may vary from user to user.
Step 3: Create Logical Volume Groups
First, combine one or more physical volumes propositionally into a VG through the system > Create logical volume groups by the following commands -
Commands:
sudo vgcreate my_vg /dev/sdX1 /dev/sdY2
sudo lvcreate -L 20G -n my_lv my_vg
Note: This command establishes a 20GB logical volume called my_lv inside the my_vg volume group to update the variation.
After the logical volume has been configured, it can be created and formatted using a discovery filesystem. Follow the below commands:
Commands:
sudo mkfs.ext4 /dev/my_vg/my_lv_01
sudo mount /dev/my_vg/my_lv /mnt/my_mount_point_01
It is now possible for you to begin all the required data to store on your logical volume format.
How to Manage Disk Space with LVM in Linux?
A disc management program for the Linux distribution system that gives you a higher-level view of your drives and partitions is called Logical Volume Manager, or LVM. Users need to follow the below-mentioned steps to manage disk space with LVM in Linux.
Step 1: Resize the Logical Volumes and implement Commands
The actual capacity of LVM to resize logical volumes without experiencing any logical downtime is among its most potent capabilities.
- Extend the Logical Volume > Add 10 GB to the logical volume storage section
Command: sudo lvextend -L +10G /dev/my_vg/my_lv
- Resize the additional system to implement a storage facility > Follow the below command
Command: sudo resize2fs /dev/my_vg/my_lv
Step 2: Move the Logical Volumes system settings
Moving the required logical volumes between physical volumes is another feature of LVM that comes in handy when it comes time to swap out the internal discs to proceed or adjust the storage of the devices.
Command: sudo pvmove /dev/sdX1 /dev/sdZ2
Note: With no downtime, this operation transfers all the internal data from /dev/sdX1 to /dev/sdZ1.
Step 3: Create useful Snapshots
You can make point-in-time copies of a logical volume using LVM snapshots to implement the overall management system. For testing or backup purposes, this is helpful to implement.
- Type the command to create a snapshot
Command: sudo lvcreate --size 10G --snapshot --name my_lv_snapshot /dev/my_vg/my_lv1
- Type the command to remove the snapshot
Command: sudo lvremove /dev/my_vg/my_lv1_snapshot
Conclusion
On Linux systems, LVM offers a strong and versatile disc space management solution to implement logical systems. LVM simplifies and improves the overall efficiency of several processes, including making snapshots, transferring all the possible data, and extending disk storage or managing them. You may confidently control and secure your disc space with the help of the LVM tool in the Linux-distributed system.
Also Read
Similar Reads
How to Use Package Managers in Linux? APT and YUM
Package managers like APT and YUM are essential tools for managing software on Linux systems. They allow you to install, update, and remove packages easily, ensuring your system is up-to-date and secure. APT is commonly used in Debian-based distributions like Ubuntu, while YUM is used in Red Hat-bas
5 min read
How to Check Disk Space in Linux
Efficient disk space management is important for maintaining the performance and stability of your Linux system. Over time, files and applications can fill up your storage, potentially causing slowdowns or errors. Knowing how to check disk space in Linux helps you monitor usage, prevent issues, and
6 min read
How to Add New Disk in Linux CentOS 7 Without Rebooting
Let's Say we hosted the DataBase on our Server Initially with 500GB given space and as we know Database should run 24/7 because the user's using it. One day it consumes space about 400GB only 100GB left Now we want to Increase the Space at the runtime only and In the case of static partitioning we n
3 min read
How to Manage Packages in Red Hat-based Linux?
Package management tools like dnf (Dandified YUM) or yum (Yellowdog Updater Modified) are used to manage packages on Red Hat-based Linux systems. These programs support the installation, removal, and upgrading of software packages on your computer. Typical package management tasks include the follow
4 min read
How To Free Up Space and Speed up Kali Linux?
Kali Linux is an extremely powerful operating system that is specially designed for professionals so that they can perform security testing and ethical hacking in simple and easy way. However, after a certain time, it is bound to slow down just like any other operating system due to the addition of
6 min read
How to Back Up and Restore Data in Linux?
Backing up and restoring data in Linux is essential for ensuring the security and integrity of your files and system. Whether you're safeguarding personal data or managing critical system files, having a reliable backup strategy is crucial. Linux offers various methods and tools for creating backups
4 min read
How to Manage Directories in Linux?
Directories in Linux or any operating system help to organize the data and files, which is then easier to find and manage. In this article, you will learn everything you will need to manage directories in Linux. We will try to cover every topic from creating, and copying to deleting the directories
6 min read
How to Mount and Unmount Drives on Linux
In the Linux operating system, everything is treated as a file. Every Linux administrator must know how to organize and access files better. In this article, we will learn about the Mount and Unmount commands. What are mounting and unmounting in Linux?Mounting and Unmounting are essential tasks in a
4 min read
How to Mount File System in Linux | mount Command
Working with file systems is a fundamental part of managing a Linux system, and knowing how to mount them is a skill every Linux user should have. Whether youâre connecting a USB drive, accessing a network share, or setting up a new partition, the mount command is your go-to tool for making file sys
7 min read
How to Manage Linux Containers using LXC
LXC is a technology for creating light weighted containers on your system. This technology is able to run on more than one Linux host. It is just like its counterparts i.e the other hypervisors like KVM and Xen. Unlike complete virtualization, containerization does not provide the user with complete
4 min read