Linux in the maintenance process, often encounter disk space full situation, if the original disk planning is not handled well, processing disk space full of problems will be a more troublesome problem, when the system is installed directly to do disk partition mount, not using LVM (Logical Volume Manager) Managing disks, when disk space is full, and the need to migrate files from a disk full of space to a newly added disk after a new addition, is a lengthy process, especially for a very important machine for production tasks, which is a very difficult task to complete.
If the installation system was using LVM to manage the disks, it would be a very easy task to handle the problem of full disk space. Here's a quick overview of how LVM manages the disk, and for the newly added hard drive
The first step runs the command fdisk command, partitioning the disk,
Command (M for help): N # # NEW
Command actione EXTENDEDP Primary partition (1-4) p # # Primary Partition
Partition number (1-4): 1 # # code
Cylinder (1-1044, default 1): # # Carriage return with default 1
Last cylinder, +cylinders or +size{k,m,g} (1-1044, default 1044): # # Size Direct return
The second step is to change the type of partition you just created, and the normal LVM type is 8e
Command (M for help): t # # Change Type
Selected partition 1
Hex code (type L to list codes): 8e # # LVM partition codes
Changed system type of partition 1 to 8e (Linux LVM)
step three, create PV
Pvcreate/dev/sdb1
After successful creation, use Pvdisplay to view
---NEW physical volume---
PV NAME/DEV/SDB1
VG Name
PV Size 1.01 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID jszvzz-ena2-g5pd-irhv-t9wi-zfa3-0xo092
Step Fourth Create a VG
Vgcreate VG-WWW/DEV/SDB1 The first parameter vg-www is the name of VG, this can be arbitrarily named, easy to remember, the second parameter/dev/sdb1, is the name of PV,
After the creation is complete, you can use Vgdisplay to view
---Volume Group---
VG Name vg-www
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 1
VG Access Read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
ACT PV 1
VG Size 1.01 GiB
PE Size 4.00 MiB
Total PE 258
Alloc pe/size 0/0
Free Pe/size 258/1.01 GiB
VG UUID BWD2PS-FKAZ-LGVZ-QC7C-TAKV-FFUC-IZGNBK
Step fifth Create LV
Lvcreate-l 1g-n lv-www vg-www
The first argument-L is the amount of space to create the LV, and-N is the name of the LV, and the last Vg-www is the name of the VG
After the creation is complete, use the command lvdisplay to view
# Lvdisplay
--- Logical volume ---lv name /dev/vg-www/lv-www vg name vg-www lv uuid           YNQ1AA-QVT1-HEJ6-ARJX-I1Q4-Y1H1-OFETLW LV Write access read/write LV Status available# open 0 LV Size 1000.00 mib Current LE 25 Segments &nBsp; 1 allocation inherit read ahead sectors auto- CURRENTLY SET TO     256 block device
253:2
The sixth step, the creation of a good LV file system format, after the format is completed, you can use the partition, Mount
Mkfs.ext4/dev/vg-www/lv-www
Seventh Step: use LV
Mount/dev/vg-www/lv-www/www
Through the steps above, the LVM management of the new disk is completed, and the relationship between the PV VG LV in the process of using the following diagram