Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to mount the disk as LVM

Shulou Source: shulou.com Published: 2022-06-03 03:59:40 09月22日 Update

LVM

LVM is the abbreviation of Logical Volume Manager (logical Volume Management). It is a mechanism for managing disk partitions in the Linux environment. It is implemented by Heinz Mauelshagen on the Linux 2.4 kernel. The latest versions are stable version 1.0.5, development version 1.1.0-rc2, and LVM2 development version. A common and difficult problem encountered by Linux users when installing Linux operating system is how to correctly evaluate the size of each partition in order to allocate appropriate hard disk space. The common disk partition management method cannot change the size of a logical partition after it has been partitioned. When a logical partition cannot hold a file, the file cannot be stored across multiple partitions because of the limitations of the upper file system. So it can't be put on other disks at the same time.

The process of creating a LVM:

1. Mount a physical disk

two。 Add a physical disk to a physical volume

3. Add a physical volume to a volume group

4. Divide the disk resources in a volume group into different logical volumes

Mounting method:

1. Check the disk condition: fdisk-l

two。 Partition disk sdb:

Command: fdisk / dev/sdb

If you don't know the specific operation in fdisk, you can enter m to help. The most commonly used is n (new) d (delete) p (print) Q (exit) t (modify system identifier) w (write and exit)

Create a new partition:

Enter p to print the existing partition (there is no partition yet)

Enter n to create a new partition

Enter p to establish the primary partition (at this time p is after n, not printing)

Enter 1 to create the first primary partition

Enter p to print the partition and find that a partition / dev/sdb1 has been created, but this partition is in Linux format

Change the system identifier:

Enter t to change the properties of partition 1

Enter L to see a command corresponding to an attribute

Enter 8e to change partition 1 to Linux LVM format

Enter p to print the partition and find that the partition / dev/sdb1 is in Linux LVM format

3. Create a PV:

Sweep system PV:pvscan

Create PV:pvcreate / dev/sdb1

View PV:pvdisplay

4. Create a VG:

Sweep system VG:vgscan

Create VG:vgcreate vg_test / dev/sdb1

View VG:vgdisplay

5. Create a LV:

Sweep system LV:lvscan

Create LV:lvcreate-l 1274-n lv_test vg_test (1274 is the number of PE in VG)

View LV:lvdisplay

6. Format the LV you just created

Command: mkfs-t ext4 / dev/vg_test/lv_test

7. Create a directory and mount it

Create a directory: mkdir / test

Mount: mount / dev/vg_test/lv_test / test

View: df-h

8. The last step is to set the boot mount.

Write / dev/mapper/vg_test-lv_test / test ext4 defaults 1 2 to / etc/fstab

At this point, the job is done.

Tags: Input disk system situation format physics logic command file management size attribute identity identifier directory development different appropriate ordinary done Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Docker OPPO Reno Microsoft NVidia