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

Linux (06): LVM case

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

First, create a LVM

Use the fdisk-l command to view the disk

Partition the newly added hard disk / dev/sdb and convert it to LVM format

Use partition / dev/sdb1 to create LVM physical volumes. The partition must be created as a physical volume (PV) before subsequent volume groups (VG) can be created.

Pvcreate / dev/sdb1pvdisplay

Use partition / dev/sdb1 to create the volume group vg01, and make sure the volume group size

Vgcreate vg01 / dev/sdb1vgdisplay

A volume group can contain multiple logical volumes (LV), where-L is the specified size and-n is the specified name

Lvcreate-L 4.99G-n lv01 vg01lvcreate-l + 100%FREE-n lv01 vg01

The logical volume lv01 needs to be formatted after it is created.

Mkfs.xfs / dev/vg01/lv01

Hang it in the / mnt directory. If you want to boot and mount automatically, you need to write the mount information to the fstab file.

Mount / dev/vg01/lv01 / oradata, and use the df-ah command to view

Power on and load automatically

Second, expand the capacity (add disk)

Identification disk:

Echo "- -" > / sys/class/scsi_host/host0/scanpartx-a / dev/sdc

Re-identify the pv size

Pvresize / dev/sdb

Make pv

Pvcreate / dev/sdb2

Expand the capacity of vg01 using / dev/sdb2

Vgextend vg01 / dev/sdb2vgdisplay

Expand the logical volume lv01

Lvextend-L 14.99G / dev/vg01/lv01

Execute the command to resize the file system

Ext4:

Resize2fs / dev/vg01/lv01

Xfs:

Xfs_growfs / dev/vg01/lv01 III. Capacity expansion (disk expansion)

Identification storage

Echo 1 > / sys/class/scsi_device/device/rescanecho 1 > / sys/block/sdb/device/rescan

Re-identify the pv size

Pvresize / dev/sdb

Expand the capacity of vg01 using / dev/sdb

Vgs

Expand the logical volume lv01

Lvextend-l + 100%FREE / dev/vg01/lv01

Execute the command to resize the file system

Ext4:

Resize2fs / dev/vg01/lv01

Xfs:

Xfs_growfs / dev/vg01/lv01 IV. Unmount the logical volume LV of the volume group

To unmount all logical volumes for the corresponding volume group VG. From the above information, we can see that the corresponding volume group vg01 only has the logical volume LV of / dev/vg01/lv01.

Uninstall lv

Umount / dev/vg01/lv01umount / oradata

Delete logical volume LV

Lvremove / dev/vg01/lv01

Verification

Lvdisplay | grep "/ dev/vg01/lv01" 5. Delete volume group VG

Delete volume group VG

If the volume group VG is deleted in a secure manner, vg_name must be turned off using vgchange-an vg01

Vgchange-an vg01

And then delete it.

Vgremove vg01

Verify that the volume group (VG) is deleted

VGSCAN VI. Delete physical volume PV

Delete

Pvremove / dev/sdb

Verification

Pvscan

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