Linux system, LVM management and creation steps

888u

Last update at :2024-07-05,Edit by888u

1. Basic knowledge LVM: Logical partition management, which can reduce the space used by hardware devices based on dynamic expansion. Concept: pv, VG, lv pv (physical volume, composed of pp basic unit): physical disk VG (volume group, composed of pv basic units): a collection of one or more physical disks (capacity) lv (logical volume, composed of lp basic units): the use partition (space) divided under VG

2. Operation steps 1.Create pv 2. Create vg 3. Add pv to vg 4. Create lv in vg 5. Format the lv partition 6. Mount the lv partition to a directory for use

3. Specific operations 1. Create PV [root@z1~]# pvcreate /dev/sdb1 Create pv /dev/sdb1 Make the first primary partition of the second SCSI hard disk into pv [root@z1~]# pvcreate /dev/sdc1 . . . Make the first primary partition of the third SCSI hard disk into pv (the Linux operating system should be in the first hard disk) View PV [root@z1~]# pvdisplay

2. Create a volume group VG [root@z1~]# vgcreate datavg /dev/sdb1 /dev/sdc1 Create a volume group named datavg, and add the two pvs /dev/sdb1 and /dev/sdc1 to this volume group View VG [root@z1~]#vgdisplay

3. Create a logical volume LV [root@z1~]# lvcreate –n lv1 –L 40G datavg Create a 40G logical volume named lv1 in datavg View LV [root@z1~]# lvdisplay

4. Format LV into ext3 file format [root@z1~]# mkfs .ext3 /dev/datavg/lv1 or mke2fs -t ext3 /dev/datavg/lv1 Format lv1 into ext3 file system type [root@z1~]# partprobe The system can identify these partitions without restarting the machine

5. Create a directory [root@z1~]# mkdir /oracle mount [root@z1~]# mount /dev/datavg/lv1 /oracle Mount lv1 to the /oralce directory

View capacity Ls –lh

6. Expand the mounted logical volume [root@z1~]# lvextend –L +50M /dev/rootvg/lv1 Expand lv by 50M (provided datavg has 50M space) Check partition usage [root@z1~]# df –h Check disk usage fdisk -l

7. Online (dynamic) expansion of lv1 [root@z1~]#resize2fs /dev/datavg/lv1 resize2fs is a tool for adjusting the size of the ext2 file system. ext3 is just ext2 with the addition of journal and can also be used.

8. Expand the mounted logical volume [root@z1~]#lvextend –L +70M /dev/datavg/lv1 Add 70M to lv1 (70 comes from datavg) [root@z1~]#e2fsck –f /dev/datavg/lv1 Forcefully check the correctness of ext2, ext3, ext4 and other file systems (clean up disk fragments and prevent data from being scattered, this is crucial when shrinking LV) [root@z1~]#lvdipaly

9. Expanding the capacity of VG (1) [root@z1~]# pvcreate /dev/sdb2 Create pv /dev/sdb2 [root@z1~]# vgextend datavg /dev/sdb2 Add the pv /dev/sdb2 to the volume group datavg Expanding the capacity of VG (2) [root@z1~]# pvcreate /dev/sdb2 Create pv /dev/sdb2 [root@z1~]# pvcreate /dev/sdc3 Create pv /dev/sdb3 [root@z1~]# vgcreate datavg /dev/sdb2 Create datavg (/dev/sdb2 inside) [root@z1~]# vgcreate rootvg /dev/sdc3 Create rootvg (/dev/sdb3 inside) [root@z1~]# vgmerge rootvg datavg Integrate rootvg and datavg into rootvg

10. How to unmount a volume: Unmount a physical volume: pvremove PVDEVICE Unmount volume group: vgremove VGNAME Unmount logical volumes: lvremove LVDEVICE The order of uninstallation: first logical - volume group - physical volume Don’t forget to back up before uninstalling

Reprinted from: https://blog.csdn.net/alone_map/article/details/51850381

Recommended site searches: foreign server rental, private server rental, personal virtual host, Hong Kong server defense, server rental, Zhengzhou server, overseas server rental price, me domain name registration, Beijing domain name registration, PHP space purchase,

Linux system, LVM management and creation steps

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码