Scenario Description:
Install the operating system, do the LVM, the application software is basically installed in the "/" directory, the server after a period of time, the directory of storage space use of tension, and now use LVM to disk space expansion.
Note: The installation system needs to do logical volume management, to ensure that the system to have VG, expand or add the hard disk after the need to restart the server, the added hard drive to be discovered.
Another: It needs to be clear, is to expand the original partition or add a new hard disk;
For example: If 10G is extended on the original partition SDA, the command line fdisk-l will not see the new partition;
If it is a newly added hard disk, fdisk-l can see new unallocated partitions such as the SDB SDC.
Results Demo: Extended SDA, disk partition SDA usage printout: (you can see that the space becomes 32.2G increased by 10G)
Add a new hard disk for the server, here we added two, boot identification is SDB and SDC;
(1) We can see that there are 3 hard drives, the first hard drive is partitioned and used, the second and third drives are unused, and now we are going to create a new LVM partition on the second drive SDB
Use FDISK/DEV/SDB to partition, press N to create a new partition, press p to create the primary partition, press 1, create the first partition, select Start track, start with the default mode, and use the entire hard disk space. When created, press W to exit. (Note: Even in a different case, the extended SDA also needs to be re-partitioned on SDA, Partition number (1-4) when the corresponding value is entered. )
The new partition is formatted;
#mkfs-T EXT3/DEV/SDB1 (the system needs to be restarted if the partition sdb1 is not found; the default "done" does not have to be tapped manually, waiting for a moment to appear automatically.) )
(2) Change the partition to LVM format
Modify the partition format so that the newly created partition supports LVM format. After entering Fdisk, press T to modify the partition format, type to 8e (before default is 83). Press W to save the entry.
Perform partprobe without restarting the machine to make the partition table effective.
Fdisk-l view the newly added partition, the format has become LVM 8e.
3 View VG
#vgdisplay
VolGroup00 is the time to install the operating system, built;
Note: If you need a separate VG, you can create a new one; (We haven't built this time)
The Create command is as follows:
#vgcreate VOLGROUP01/DEV/SDC1
4 View PV
Create using the following command: PVCREATE/DEV/SDB1
View the existing PV, where/dev/sda2 was created when we installed the operating system;
#pvdisplay
5 View Create LV
By looking at the command, you can see that lv:/dev/volgroup00/logvol00 is the directory that we want to extend the LV
6. LVM expansion
Expansion VG
#vgextend VOLGROUP00/DEV/SDB1
View extended VG increased by 10G
To view the current disk space usage, you can see that the current "/" directory corresponds to a space size of 14G, so next, the LV expansion words
The parameter needs to be added to the following parameters: 24G, which indicates expansion to 24G.
Extended LV
#lvextend-L 24g/dev/volgroup00/logvol00
Attention:
If the following prompt appears, it means that the maximum expansion is not enough space, you can turn the value down a little bit, change to 23.8G, that is smaller than 24G (here according to the size of the actual expansion to adjust).
[Email protected] ~]# lvextend-l 24g/dev/volgroup00/logvol00
Extending logical Volume LogVol00 to 26.00 GB
Insufficient free space:321 extents needed and only available
To view the extended LV size:
[Email protected] ~]# Lvdisplay
We then look at the current disk usage, found no change;
Do not worry, perform the reset size;
#resize2fs/dev/volgroup00/logvol00
OK, our expansion is complete here.
PS: Allow reprint, please specify the source!
Linux_lvm_ Disk Expansion