Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Shell Scripting
  • Kali Linux
  • Ubuntu
  • Red Hat
  • CentOS
  • Docker in Linux
  • Kubernetes in Linux
  • Linux interview question
  • Python
  • R
  • Java
  • C
  • C++
  • JavaScript
  • DSA
Open In App
Next Article:
How to Check Disk Space in Linux
Next article icon

How to Set up and Manage Disk Space with LVM in Linux?

Last Updated : 27 Aug, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

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.

Table of Content

  • How to Set up LVM in Linux?
    • Step 1: Install LVM configuration
    • Step 2: Create a Physical Volume system
    • Step 3: Create Logical Volume Groups
    • Step 4: Create the internal Filesystem and Configure
  • How to Manage Disk Space with LVM in Linux?
    • Step 1: Resize the Logical Volumes and implement Commands
    • Step 2: Move the Logical Volumes system settings
    • Step 3: Create useful Snapshots

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
LVM_1

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.

Disk_2

Step 4: Create the internal Filesystem and Configure

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.

Linux_3

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
Disk_3

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.

Disk_4

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
Disk_5

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

  • How to Add New Disk in Linux CentOS 7 Without Rebooting
  • How to Check Disk Space in Linux
  • 5 Best Partition Managers for Linux [Free]

Next Article
How to Check Disk Space in Linux
author
arponkumarchowdhury34
Improve
Article Tags :
  • TechTips
  • linux

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
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences