Extending Linux hard disk space under VMware

Source: Internet
Author: User

There are many ways to extend a hard disk under Linux, before it is extended. Try to see which disks exist in your space and then expand them.

If it is an extension, the disk symbol is the same as the existing symbol, such as SDA device, knowledge partition is different. It could be Sda3 sda4.

Suppose to be added, relative to a new hard disk, may be SDB SDC

Many people choose to install a Linux virtual machine on VMware when learning Nutch, Hadoop, or a Linux operating system, and often do not want to allocate enough hard disk space to a Linux virtual machine, which makes it easy to use Linux for a period of time. Find out if the hard disk space on the virtual machine is not enough, how to solve this? Some people directly choose to install the Linux virtual machine again. But the next time the hard drive is not enough, but also to install the operating system again, then the next time? Such a method is bound to enter a repetitive boring process, in addition to the installation of operating system proficiency and waste a lot of time, there is no merit. In response to this very likely problem, this article describes how to dynamically extend the Linux hard disk on VMware, which has completed Linux operating systems, to solve the problem of insufficient disk space for Linux virtual machines and to avoid the hassle of installing Linux OS again.

This article is based on VMware Workstation 9 and Red Hat Enterprise Linux 6, with no essential differences in the remaining version numbers.

1. Start the VMware program. Click "Edit Virtual machine settings", for example to see.

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvc2t5d2fsa2vyx29ubhk=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma== /dissolve/70/gravity/southeast "align=" Middle "height=" "width=" >


2. In the popup dialog box, click on the "Hardware" tab to find the hard disk space size is 20G, click on the right side of the utilities. Select "Expand".

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvc2t5d2fsa2vyx29ubhk=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma== /dissolve/70/gravity/southeast "align=" Middle "height=" "width=" >

3. In the dialog box that pops up next. Select the maximum hard drive size, set here to 30G, and click Expandbutton.


4. It takes a while to extend the hard disk space, as seen in this step:


5. Once the hard drive has been expanded successfully, it is necessary to partition the hard disk and extend the file system again on the client (that is, the Linux virtual machine).


6. Start the Linux virtual machine. Log in as root, as the root user is required for subsequent operations.

Open the terminal form, enter "Df-h" to view the file system. For example, as seen, you can see that the size of/home in my virtual machine is 2.2G. Available capacity is 83M. The goal of this extended hard drive is to add the size of the/home folder, note that the file partition is/dev/sda3, and the subsequent operations are mainly for that partition.

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvc2t5d2fsa2vyx29ubhk=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma== /dissolve/70/gravity/southeast "align=" Middle "height=" "width=" >

7. Run the fdisk–l command below. Looking at the partition of the hard disk, you can see that the hard disk space has indeed expanded to 30G.


8. Now drive the hard disk/DEV/SDA, run the command FDISK/DEV/SDA, enter D (the command to delete the partition) after command, and enter the number to delete the partition, enter the partition 3 to delete. After the completion of the operation, enter p to see the hard disk partition,/dev/sda3 has been deleted.


9. Now if you want to allocate the extended space to the/home folder. Still not able to, because the swap partition, which will cause the remaining space can not be allocated (including the new space and space before the/home folder), so you also need to delete partition 4, the steps and the 8th is consistent with the introduction.

10. Enter the Fdisk–l command again (to verify the hard disk space partitioning every time.) is due to the need for careful operation of the hard disk partition. Just to ensure that the previous operation has been correctly run, perhaps the operation will not fail, and found that/dev/sda3,/dev/sda4 have been deleted. Then run FDISK/DEV/SDA to add a partition to the hard drive. Enter n (new partition) at command prompt. Indicates whether the primary or extended partition is active. Select P (primary partition) and enter the partition number 3. Enter the start and end cylinder number, the start number selection by default will be able to (also can define the starting number, so that the extra hard disk space will be set aside), the end number in this operation is not selected by default. The swap partition is set to 2G because there is still room for the swap partition. The end number of the/dev/sda3 can be calculated from this (3661).

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvc2t5d2fsa2vyx29ubhk=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma== /dissolve/70/gravity/southeast "height=" "width=" >

11. If Linux has a desktop application installed. It is also possible to use a graphical disk useful tool, which is an example of allocating a swap partition for a brief introduction. Select the disk useful tool in the application, open for example to see the interface, click on the bottom left side of the hard disk, on the right side select spare space, click Create partition below, select partition size. Type, click Create button to complete the creation of the partition.

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvc2t5d2fsa2vyx29ubhk=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma== /dissolve/70/gravity/southeast "height=" "width=" >

12. After the partition is created, the following will mount the new partition to the/home folder, run the command mount/dev/sda3/home, then run df–h to view the file system, run the process and the results see.


13. After the partition is mounted to the/home folder. There is also a need to change/etc/fstab. Add the relationship between the/dev/sda3 and/home folders. This allows the system to load the folder correctly when it is started. The methods and contents of the changes are as seen. After the change is complete, the system is started again and the process of expanding the hard disk is completed successfully.


At this point, the method of dynamically extending Linux hard drives under VMware has been introduced, but several places still need to be noted. As mentioned in the 9th step.

Another place that needs to be noticed is the error message that occurs when you run the delete/dev/sda3 and restart the operating system:


This is due to the need to load/etc/fstab in the system boot, and the/dev/sda3 partition has been deleted, so the resolution of its corresponding content will be an error, you need to repair the contents of the file, remove the corresponding content with/dev/sda3, enter the # prompt after the vi/etc /fstab. The interface you see appears:

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvc2t5d2fsa2vyx29ubhk=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma== /dissolve/70/gravity/southeast "align=" Middle "height=" "width=" >

Notice the text readonly in parentheses in the last line. Indicates that the file is a read-only file. You need to exit the VI editor at this time. Run Mount–o remount, RW/. This will be able to change the/etc/fstab file, remove/dev/sda3 that line can be. When finished, run reboot and reboot the system.


So far. The method for dynamically extending Linux hard disks under VMware has been specifically described. And how to solve the problems that may arise.


It doesn't say how to format the hard drive. Format the next article, as well as possible error situations.

Extending Linux hard disk space under VMware

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.