国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
My Server Setup – Requirements
Check LVM Disk Storage in Linux
Create a New Volume Group in LVM
Create a Disk Partition
Create LVM Physical Volume
Creating LVM Volume Groups
Creating LVM Logical Volumes
Method 1: Creating Logical Volumes using PE Size
Method 2: Creating Logical Volumes using GB Size
Creating File System
Permanent Mounting of Logical Volumes
Home System Tutorial LINUX How to Create Disk Storage with LVM in Linux - Part 1

How to Create Disk Storage with LVM in Linux - Part 1

Jun 10, 2025 am 11:17 AM

Logical Volume Management (LVM) is a powerful tool that greatly simplifies disk space management. With LVM, the task of allocating additional space to a file system becomes effortless.

Whenever a file system requires more space, it can easily draw from the available free space in its corresponding volume group. As a result, file systems can be dynamically resized to accommodate our specific needs.

Furthermore, LVM offers robust data protection in the event of disk failures. If a disk begins to show signs of failure, we can seamlessly integrate a replacement disk into the volume group as a new physical volume.

By doing so, the logical volumes can be efficiently migrated to the fresh disk, ensuring continuity and safeguarding against any potential data loss.

In essence, LVM empowers administrators to handle disk space allocation and management with unparalleled flexibility and resilience. Its dynamic resizing capabilities and built-in redundancy features make it an indispensable asset for optimizing storage utilization and enhancing data integrity in any system configuration.

Introducing the comprehensive series “Preparation for Setting Up LVM (Logical Volume Management)“, thoughtfully crafted across Parts 1 to 6, with an in-depth exploration of the following essential topics:

Before proceeding with the LVM setup, consider the following prerequisites:

My Server Setup – Requirements
  • OS – RHEL 9 with LVM Installation
  • IP – 192.168.0.200
  • Disks – 3 disks with 20GB each.

Check LVM Disk Storage in Linux

1. To gain insight into our LVM setup, we can utilize the following commands to reveal the distinct components: Physical Volume (PV), Volume Group (VG), and Logical Volume (LV).

# pvs 
# vgs
# lvs

How to Create Disk Storage with LVM in Linux - Part 1

Here, is the description of each parameter shown in the above screenshot.

  • Physical Disk Size (PV Size)
  • The disk used was Virtual Disk sda.
  • Volume Group Size (VG Size)
  • Volume Group name (vg_tecmint)
  • Logical Volume name (LogVol00, LogVol01)
  • LogVol00 Assigned for a swap with 956MB Size
  • LogVol01 Assigned for/with?18.63GB

So, from here we come to know that there is not enough free space in the VDA disk.

Create a New Volume Group in LVM

2. To create a new Volume Group, we need to add an additional 3 hard disks to this server. However, it is not compulsory to use 3 drives; just 1 is enough to create a new VG and LV (Logical Volume) inside that VG.

I am adding the following 3 disks here for demonstration purposes and to provide more feature command explanations.

sdb, sdc, sdd

3. To list all the disks and their partitions, such as the disk name, size, partition type, start and end sectors, and more use the fdisk utility as shown.

# fdisk -l

How to Create Disk Storage with LVM in Linux - Part 1

Here, is the description of each disk shown in the above screenshot.

  • The default disk used for the Operating System is RHEL 9.
  • Partitions defined on the default disk are as follows: (sda1 = boot), (sda2 = /).
  • Additionally, added disks are mentioned as Disk1, Disk2, and Disk3.

Each and every disk is 20 GB in size.

4. Now run the vgdisplay command to view the detailed information about all the Volume Groups present on the system, including their name, size, free space, physical volume (PV) information, and more.

# vgdisplay

How to Create Disk Storage with LVM in Linux - Part 1

Here, is the description of each parameter shown in the above screenshot.

  • VG Name – A volume group name.
  • Format – LVM architecture used lvm2.
  • VG Access – The Volume Group is in read-and-write mode and ready to use.
  • VG Status – The Volume Group can be resized. We can expand it if we need to add more space.
  • Cur LV – Currently, there are 2 Logical volumes in this Volume Group.
  • CurPV and Act PV – Currently, the physical disk in use is 1 (vda), and it’s active. So, we can use this Volume Group.
  • PE Size – Physical Extents (PEs) and size for a disk can be defined using either PE or GB size. The default PE size of LVM is 4 MB. For example, if we need to create a 5 GB logical volume, we can use a sum of 1280 PEs. Do you understand what I’m saying?

Here’s the explanation: 1 GB is equal to 1024 MB, so 1024 MB x 5 = 5120 PE = 5 GB. Now, divide 5120 by 4 = 1280. 4 is the default PE size.

  • Total PE – This Volume Group has.
  • Alloc PE – Total PE Used, full PE already Used, 5008 x 4PE = 20032.
  • Free PE – Here it’s already used so there was no free PE.

5. Now list the file system disk space information, here only sda is used with /boot, /, and swap on the sda physical disk using LVM. There is no space remaining on this disk.

# df -TH

How to Create Disk Storage with LVM in Linux - Part 1

The above image shows the mount point we are using, and the 19GB is fully used for the root, so there is no free space available.

Create a Disk Partition

6. So, let’s create a new physical volume (PV) and volume group (VG) named tecmint_add_vg, and create logical volumes (LVs) within it. Here, we can create 4 logical volumes with the names tecmint_documents, tecmint_manager, and tecmint_public.

We can extend the Volume Group of the currently used VG to get more space. However, in this case, we are going to create a new Volume Group and experiment with it. Later, we can see how to extend the file systems of the Volume Group that is currently in use.

Before using a new disk, we need to partition the disk using the fdisk command as shown.

# fdisk -c /dev/sdb

How to Create Disk Storage with LVM in Linux - Part 1

Next, follow the below steps to create a new partition.

  • Choose n to create new.
  • Choose p to create a primary partition.
  • Choose which number of partitions we need to create.
  • Press enter twice to use the full space of the disk.
  • We need to change the type of newly created partition type t.
  • Which number of partition need to change, choose the number which we created its 1.
  • Here we need to change the type, we need to create LVM so we going to use the type code of LVM as 8e, if we do not know the type code Press L to list all types of codes.
  • Print the partition that we created to just confirm.
  • Here we can see the ID as 8e LINUX LVM.
  • Write the changes and exit the fdisk.

7. Do the above steps for the other 2 disks sdc and sdd to create new partitions. Then restart the machine to verify the partition table using the fdisk command.

# fdisk -l

How to Create Disk Storage with LVM in Linux - Part 1

Create LVM Physical Volume

8. Now, it’s time to create Physical Volumes using all 3 disks. Here, I have listed the physical disks using the ‘pvs‘ command, and now only one default PV is listed.

# pvs

9. Then create the new physical disks and confirm the newly created physical disks.

# pvcreate /dev/sdb1 /dev/sdc1 /dev/sdd1
# pvs

How to Create Disk Storage with LVM in Linux - Part 1

Creating LVM Volume Groups

10. Create a Volume Group named tecmint_add_vg using the available free PV and a PE size of 32. To display the current volume groups, we can see that there is one volume group with 1 PV in use.

# vgs

11. This will create the volume group named tecmint_add_vg using a 32MB PE size and the 3 physical volumes we created in the last steps.

# vgcreate -s 32M tecmint_add_vg /dev/sdb1 /dev/sdc1 /dev/sdd1

12. Next, verify the volume group by running the vgs command again.

# vgs

How to Create Disk Storage with LVM in Linux - Part 1

Understanding vgs command output:

  • Volume Group name.
  • Physical Volumes used in this Volume Group.
  • Shows free space available in this volume group.
  • Total Size of the Volume Group.
  • Logical Volumes inside this volume group, Here we have not yet created so there is 0.
  • SN = Number of Snapshots the volume group contains. (Later we can create a snapshot).
  • Status of the Volume group as Writeable, readable, resizeable, exported, partial, and clustered, Here it is wz–n- that means w = Writable, z = resizeable.
  • Number of Physical Volume (PV) used in this Volume Group.

13. To display more information about the volume group use the command.

# vgs -v

How to Create Disk Storage with LVM in Linux - Part 1

14. To get more information about newly created volume groups, run the following command.

# vgdisplay tecmint_add_vg

How to Create Disk Storage with LVM in Linux - Part 1

Here, is the description of each parameter shown in the above screenshot.

  • Volume group name
  • LVM Architecture used.
  • It can be read and write state, ready to use.
  • This volume group can be resizeable.
  • No Physical disk was used and they are active.
  • Volume Group total size.
  • A Single PE size was 32 here.
  • Total number of PE available in this volume group.
  • Currently, we have not created any LV inside this VG so it’s totally free.
  • UUID of this volume group.

Creating LVM Logical Volumes

15. Now, create 3 Logical Volumes named tecmint_documents, tecmint_manager, and tecmint_public. Here, we will demonstrate how to create Logical Volumes using both PE size and GB size.

First, list the current Logical Volumes using the following command..

# lvs

How to Create Disk Storage with LVM in Linux - Part 1

16. These Logical Volumes are in the vg_tecmint Volume Group. To see how much free space is available to create logical volumes, list the Volume Group and available Physical Volumes using the ‘vgs‘ command.

# vgs

How to Create Disk Storage with LVM in Linux - Part 1

The volume group size is almost 60GB, and it is unused, so we can create LVs in it. Let us divide the volume group into equal sizes to create 3 Logical Volumes. That means 60GB/3 = 20GB. Each Logical Volume will be 20GB in size after creation.

Method 1: Creating Logical Volumes using PE Size

First, let us create Logical Volumes using the Physical Extent (PE) size. We need to know the default PE size assigned to this Volume Group and the total available PEs to create new Logical Volumes.

Run the following command to get this information.

# vgdisplay tecmint_add_vg

How to Create Disk Storage with LVM in Linux - Part 1

  • The default PE Assigned for this VG is 32MB, Here Single PE size will be 32MB.
  • Total Available PE is 1917.

Just do and see a little Calculation using the bc command.

# bc
1917PE/3 = 639 PE. 
639 PE x 32MB = 20448 --> 20GB

How to Create Disk Storage with LVM in Linux - Part 1

Press CRTL D to exit from bc.

Let us now create 3 Logical Volumes using 639 PE’s. Here -l used to extend the size and -n to assign a logical volume name.

# lvcreate -l 639 -n tecmint_documents tecmint_add_vg
# lvcreate -l 639 -n tecmint_manager tecmint_add_vg
# lvcreate -l 639 -n tecmint_public tecmint_add_vg

List the created Logical Volumes using lvs command.

# lvs

How to Create Disk Storage with LVM in Linux - Part 1

Method 2: Creating Logical Volumes using GB Size

While creating Logical Volume using GB size we cannot get the exact size. So, the better way is to create using extend.

# lvcreate -L 20G -n tecmint_documents tecmint_add_vg
# lvcreate -L 20G -n tecmint_manager tecmint_add_vg
# lvcreate -L 20G -n tecmint_public tecmint_add_vg
# lvcreate -L 20G -n tecmint_public tecmint_add_vg

List the Created logical Volumes using lvs command.

# lvs

Here, we can see while creating the 3rd LV we can’t Round-up to 20GB, it is because of small changes in size, but this issue will be ignored while creating LV using Extend size.

Creating File System

17. For using the logical volumes we need to format. Here I am using the ext4 file-system to create the volumes and going to mount them under /mnt/.

# mkfs.ext4 /dev/tecmint_add_vg/tecmint_documents
# mkfs.ext4 /dev/tecmint_add_vg/tecmint_public
# mkfs.ext4 /dev/tecmint_add_vg/tecmint_manager

How to Create Disk Storage with LVM in Linux - Part 1

18. Let us create directories in /mnt and mount the Logical volumes that we have created file-system.

# mount /dev/tecmint_add_vg/tecmint_documents /mnt/tecmint_documents/
# mount /dev/tecmint_add_vg/tecmint_public /mnt/tecmint_public/
# mount /dev/tecmint_add_vg/tecmint_manager /mnt/tecmint_manager/

19. List and confirm the Mount point using.

 
# df -h

How to Create Disk Storage with LVM in Linux - Part 1

Permanent Mounting of Logical Volumes

20. It’s now temporarily mounted, for permanent mount, we need to add the entry in fstab, for that let us get the mount entry from mtab using

# cat /etc/mtab

21. We need to make slight changes in the fstab entry while entering the mount entry contents copies from mtab, we need to change the rw to defaults

# vi /etc/fstab

Our fstab entries should look similar to the below sample.

/dev/mapper/tecmint_add_vg-tecmint_documents    /mnt/tecmint_documents  ext4    defaults 0 0
/dev/mapper/tecmint_add_vg-tecmint_public       /mnt/tecmint_public     ext4    defaults 0 0
/dev/mapper/tecmint_add_vg-tecmint_manager      /mnt/tecmint_manager    ext4    defaults 0 0

How to Create Disk Storage with LVM in Linux - Part 1

22. Finally, run the command mount -a to check for the fstab entry before restarting.

# mount -av

How to Create Disk Storage with LVM in Linux - Part 1

Here we have seen how to set up flexible storage with logical volumes by using physical disk to physical volume, physical volume to the volume group, and volume group to logical volumes.

In my upcoming future articles, I will see how to extend the volume group, and logical volumes, reduce logical volume, take snapshots, and restore from snapshots. Till then stay updated to TecMint for more such awesome articles.

The above is the detailed content of How to Create Disk Storage with LVM in Linux - Part 1. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

10 Best File Comparison and Difference (Diff) Tools in Linux 10 Best File Comparison and Difference (Diff) Tools in Linux Jun 11, 2025 am 10:26 AM

While writing program files or normal text files, programmers and writers sometimes want to know the difference between two files or two versions of the same file. When you compare two computer files on Linux, the difference between their contents is

How to create a new, empty file from the command line? How to create a new, empty file from the command line? Jun 14, 2025 am 12:18 AM

There are three ways to create empty files in the command line: First, the simplest and safest use of the touch command, which is suitable for debugging scripts or placeholder files; Second, it is quickly created through > redirection but will clear existing content, which is suitable for initializing log files; Third, use echo"> file name to create a file with an empty string, or use echo-n""> file name to avoid line breaks. These three methods have their own applicable scenarios, and choosing the right method can help you complete the task more efficiently.

5 Best Open Source Mathematical Equation Editors for Linux 5 Best Open Source Mathematical Equation Editors for Linux Jun 18, 2025 am 09:28 AM

Are you looking for good software to write mathematical equations? If so, this article provides the top 5 equation editors that you can easily install on your favorite Linux distribution.In addition to being compatible with different types of mathema

How to Install Eclipse IDE in Debian, Ubuntu, and Linux Mint How to Install Eclipse IDE in Debian, Ubuntu, and Linux Mint Jun 14, 2025 am 10:40 AM

Eclipse is a free integrated development environment (IDE) that programmers around the world use to write software, primarily in Java, but also in other major programming languages using Eclipse plugins.The latest release of Eclipse IDE 2023?06 does

dutree - Analyze File System Disk Usage in Linux dutree - Analyze File System Disk Usage in Linux Jun 11, 2025 am 10:33 AM

dutree is a free, open-source, fast command-line tool for analyzing disk usage, written in the Rust programming language. It was created by combining durep (disk usage reporter) and tree (list directory content in tree-like format) command-line tools

15 Useful 'ifconfig' Commands to Configure Network in Linux 15 Useful 'ifconfig' Commands to Configure Network in Linux Jun 11, 2025 am 10:01 AM

ifconfig in short “interface configuration” utility for system/network administration in Unix/Linux operating systems to configure, manage, and query network interface parameters via command-line interface or in a system configuration scripts

SCP Linux Command – Securely Transfer Files in Linux SCP Linux Command – Securely Transfer Files in Linux Jun 20, 2025 am 09:16 AM

Linux administrators should be familiar with the command-line environment. Since GUI (Graphical User Interface) mode in Linux servers is not commonly installed.SSH may be the most popular protocol to enable Linux administrators to manage the servers

24 Hilarious Linux Commands That Will Make You Laugh 24 Hilarious Linux Commands That Will Make You Laugh Jun 14, 2025 am 10:13 AM

Linux has a rich collection of commands, and while many of them are powerful and useful for various tasks, there are also some funny and whimsical commands that you can try out for amusement. 1. sl Command (Steam Locomotive) You might be aware of the

See all articles