Previously built a CentOS (7.0, x64) VM, has not been aware of its hard disk space. Yesterday, the system suddenly pop-up warning, said the root directory space is insufficient.
In this case, you can only add space to it.
I've actually increased my hard disk space, but to write this blog, I've added 10GB hard drives again.
On the premise of the virtual machine shutdown , first, through VMware to the virtual machine to add some hard disk space, the following figure:
After clicking "Expand", wait a moment, wait for VMware to finish processing.
After processing, VMware will prompt you, although the expansion of the hard disk space, but you need to go into the system after the partition and other operations before use.
Seeing this hint, I was crashing. Because I'm not going to partition under Linux at all, it's not as simple as Windows partitioning or scaling. That's a whole thing to do. There are only two ways to go: Either add the newly added hard drive to the system or recreate a new virtual machine.
It is obvious that the second road is more difficult than the first road. So, only with tears to choose the first road.
But, on this road, I am not alone in the struggle, I found a good guide on the Internet, there are: http://blog.sina.com.cn/s/blog_967817f20102v2a6.html http://www.cnblogs.com/ Yorian/archive/2012/02/06/2340438.html http://stackoverflow.com/questions/26305376/ Resize2fs-bad-magic-number-in-super-block-while-trying-to-open http://stackoverflow.com/questions/13362910/ Trying-to-resize2fs-eb-volume-fails
In which, the 1th link, which introduced the relevant knowledge of LVM, and the 2nd link, is my main reference to the link, according to the instructions inside the operation; 3rd is a problem found in the solution. The 4th article is the resolution referred to in article 3rd.
The following starts the operation in Linux. please operate as root user
Partitioning is performed first. For a section, you can refer to the 2nd link above. However, after I logged into the system, I used a graphical operation.
Open the system's disk tool
As you can see from the diagram, the newly added hard disk space
Use Df-hl to see the current space situation
View partitioning with "fdisk-l"
Click on the "+" number in the above image to partition
Adjust partition type
View partition again with fdisk-l
As you can see from the diagram, the newly added partitions are available.
So far, we've created a new partition/dev/sda4, at which point we can use this new space through the Mount command ( Mount). But for me, this does not satisfy my needs, because I intend to use it to extend the root directory space. And since there are already partitions mounted to the root directory "/", the new partition cannot be mounted to "/" again, and can only be extended/by extending the capacity of the partition known to be mounted to "/". (This description sounds very clumsy:)
View the current logical volume with LVS
Remember the contents of the VG column in the previous figure (that is, "CentOS"), which you use below
Use pvcreate to create a physical volume for the new partition
Use vgextend to append the new physical volume to the VG above for you to remember.
Although the system prompts extend to succeed, this time, the "/" capacity has not increased.
Can be viewed through df-hl
View the system's current VG with vgdisplay
The main view free pe/size 2696/10.53 GiB, indicating that we can have a maximum of 10.53GB expansion space.
To extend the capacity of the root directory with lvextend
Here are two questions to note: The values of the last two parameters of the lvextend :
"/dev/centos/root": Please look at the screenshot above df-hl command, which is the value of the mount point "/" corresponding "file system" in the screenshot /dev/ SDA4: This is the new partition above. The screenshot above reported a mistake: insufficient freespace:2696 extents needed, butonly 2559 available, This note, although the above said there is "10.53GB" free space, but we can not use all, but in the lvextend command, a little less, the following figure:
The final step is to tell the system "/" the capacity has increased.
If you refer to the top 2nd link, it uses the "resize2fs" command, I use the system will be an error:
Later, after investigation, found a solution on the StackOverflow , that is, the 3rd and 4th links above.
Follow their prompts to install the xfsprogs.x86_64First, and then:
The XFS_GROWFS notification System "/" has increased capacity
Finally, check the space with Df-hl .
Finally, it's best to restart the virtual machine Oh:))))