LINUX in VM perfectly increases hard disk space (LVM)

Source: Internet
Author: User
When CENTOS is installed, the disk space occupied by CENTOS is underestimated. as a result, the website cannot be opened when only 2 MB of disk/directory is left, and MYSQL cannot be restarted. I can see from the Internet that the tutorial is not out of context, it is a post, and the word is wrong... Angry! no one says you are technically poor, but you are not serious...

When CENTOS is installed, the disk space occupied by CENTOS is underestimated. as a result, the website cannot be opened when only 2 MB of disk/directory is left, and MYSQL cannot be restarted.
I can see from the Internet that the "tutorial" is not out of context, it is a post, and all the wrong words are still being transferred... Angry! no one says you are poor in technology, but if you don't take it seriously or responsibly, you just need to find a hacker. no one has to teach you how to write this article, just write out an instance process I encountered:
Step 1 add a partition:
1. expand the disk under VM-> setting-> harddisk (menu operations are no longer complex ).
2. the added capacity is not yet visible in the system. (many of them are just mentioned here, and there will be no more below .. Angry ).
Use the fdisk command
Fdisk/dev/sda
# Use the n command to create a P-type disk, and then use the t command to change the ID to 8e (LVM category ).
# P:
Disk/dev/sda: 17.1 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 cylinders
Units = cylinders of 16065*512 = 8225280 bytes

Device Boot Start End Blocks Id System
/Dev/sda1*1 13 104391 83 Linux
/Dev/sda2 14 1044 8281507 + 8e Linux LVM
/Dev/sda3 1045 1545 4024282 + 8e Linux LVM
/Dev/sda4 1546 2088 4361647 + 83 Linux
Last W save
Ps: Restart the server. Otherwise, the new sda3 and sda4 cannot be mounted, or you do not need to restart the server. please let me know.
Step 2 add VLM:
There are two methods to resize/directory, one is to migrate/var,/usr, and so on to sda3, and then do ln-s, but if sda3 fails, then, cry.
This article uses another method:
Root # lvm
Lvm> pvcreate/dev/sda3 # Create an LVM hard partition
Can't open/dev/sda3 exclusively. Mounted filesystem?
Root # mkfs. ext3/dev/sda3 # The result is that the file is not formatted. the file must be in the same format as the/directory.
Lvm> pvcreate/dev/sda3
Physical volume "/dev/sda3" successfully created
Lvm> vgextend VolGroup00/dev/sda3 # add to the same LVM Group/
Volume group "VolGroup00" successfully extended
Check it out:
Lvm> pvdisplay
--- Physical volume ---
PV Name/dev/sda2
VG Name VolGroup00
PV Size 7.90 GB/not usable 23.41 MB
Allocatable yes (but full)
PE Size (kbytes) 32768
Total PE 252
Free PE 0
Allocated PE 252.
Pvuuid ua5FJN-jSLL-bGkp-w0XO-N8JG-MBR0-1yDzGW

--- Physical volume ---
PV Name/dev/sda3
VG Name VolGroup00
PV Size 3.84 GB/not usable 25.96 MB
Allocatable yes
PE Size (kbytes) 32768
Total PE 122
Free PE 122
Allocated PE 0
Pvuuid mHKWzk-mQ1o-jkQB-0DZC-PVqW-w2R9-14y19G
Change sda3 to an LVM virtual disk (the key to increasing capacity)
Vgextend/dev/VolGroup00/LogVol102/dev/sda3
Step 3 Increase/directory capacity
Lvm & gt; lvextend-L + 3.8G/dev/VolGroup00/logvol
Rounding up size to full physical extent 3.81 GB
Extending logical volume LogVol00 to 9.69 GB
Logical volume LogVol00 successfully resized
# Identify disk capacity again
# Resize2fs/dev/VolGroup00/LogVol00
Resize2fs 1.39 (29-May-2006)
Filesystem at/dev/VolGroup00/LogVol00 is mounted on/; on-line resizing required
Ming an on-line resize of/dev/VolGroup00/LogVol00 to 2539520 (4 k) blocks.
The filesystem on/dev/VolGroup00/LogVol00 is now 2539520 blocks long.
View the final result:
Lvm> lvdisplay
--- Logical volume ---
LV Name/dev/VolGroup00/LogVol00
VG Name VolGroup00
Lvuuid r9eG4x-njBD-z2HT-lmL2-2l81-P3XV-KVd0e4
LV Write Access read/write
LV Status available
# Open 1
LV Size 9.69 GB
Current LE 310
Segments 2
Allocation inherit
Read ahead sectors auto
-Currently sets to 256
Block device 253: 0
Written at the end: Using LVM to manage disks does not need to be loaded in/etc/fstab. increasing or decreasing the disk capacity will not cause File losses. End (-:
This article is from the "kras-linux" blog

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.