Linux hard disk space expansion under VMware

Source: Internet
Author: User

There are many ways to expand a hard disk in linux. Before expansion, try to see which disks exist in your space before expansion. If it is an extension, the disk symbol is the same as the existing symbol. For example, if it is an sda device, the Knowledge partition may be sda3 sda4.

If it is added, it may be sdb sdc relative to a new hard disk.

Many users choose to install Linux virtual machines on VMWare when learning about Nutch, Hadoop, or familiar with Linux operating systems, but do not want to allocate enough hard disk space to Linux virtual machines, this may easily cause Linux to find that the hard disk space on the virtual machine is insufficient after a period of time. How can this problem be solved? Some people directly choose to reinstall the Linux virtual machine, but the next hard disk is not enough. Do you have to reinstall the operating system? What about the next time? This method is bound to go into a repetitive and boring process. In addition to increasing the proficiency of operating systems and wasting a lot of time, there is really no merit. To address this very likely problem, this article describes how to dynamically expand the Linux hard disk on VMWare, which has installed the Linux operating system, to solve the problem of insufficient hard disk space for Linux virtual machines, this avoids the trouble of re-installing the Linux operating system.

This article is based on VMWare Workstation 9 and Red Hat Enterprise Linux 6. There is no essential difference between other versions.

1. Start the VMWare program and click "Edit virtual machine settings", as shown in.


2. In the pop-up dialog box, click the "Hardware" tab to find that the disk space is 20 GB. Click Utilities on the right and select "Expand ".


3. In the next pop-up dialog box, select the maximum disk size, set it to 30 GB, and click the Expand button.


4. It takes some time to expand the disk space, as shown in the following figure:


5. After the hard disk expansion is successful, you need to re-partition the hard disk and the extended File System on the client (that is, the Linux virtual machine.


6. Start the Linux Virtual Machine and log on as the root user because the subsequent operations require the permissions of the root user. Open the terminal window and enter "df-h" to view the file system. As shown in, we can see that in my virtual machine, the size of/home is 2.2 GB and the available capacity is 83 mb. The goal of this expansion is to increase the size of the/home directory, note that the file partition is/dev/sda3, and the subsequent operations are mainly for this partition.


7. Run the fdisk-l command below to check the hard disk partition. It can be found that the hard disk space has indeed been expanded to 30 GB.


8. now, perform hard disk operations on the hard disk/dev/sda, execute the command fdisk/dev/sda, enter d after the command, and then enter the number of the partition to be deleted, enter partition 3 to be deleted. After execution, enter p to check the hard disk partition./dev/sda3 has been deleted.


9. it is still not possible to allocate the extended space to the/home directory because swap partition still exists, as a result, the remaining space cannot be allocated (including the new space and the space in the previous/home directory). Therefore, you also need to delete partition 4, which is consistent with the step described in section 8th.

10. enter the fdisk-l command again (verify the hard disk space partition every time, because the hard disk partition needs to be operated with caution, only to ensure that the previous operations have been correctly executed, subsequent operations may not cause any problems). We found that/dev/sda3 and/dev/sda4 have been deleted. Then execute fdisk/dev/sda to add partitions to the hard disk. Enter n (add partition) in the command prompt, and select p (primary partition ), enter the Partition Number as 3, enter the start and end cylinder numbers, and select the default start number (you can also customize the start number to leave extra hard disk space ), the end number is not selected by default in this operation because it also requires space for the swap partition. Here, set the swap partition to 2G, the end number of/dev/sda3 can be calculated (3661 ).


11. If a desktop application is installed in Linux, you can also use a graphical Disk Utility. Here, we will briefly introduce how to allocate swap partitions. Select the disk utility in the application, open the interface shown in, click the hard disk at the bottom of the Left, select free space on the right, Click create partition at the bottom, and select the partition size, type, click Create to create a partition.


12. after the partition is created, mount the new partition to the/home directory, run the mount/dev/sda3/home command, and then run df-h to view the file system, for the execution process and result, see.


13. after mounting the partition to the/home directory, you also need to modify the/etc/fstab and add the relationship between/dev/sda3 and/home directories, in this way, when the system is started, the directory can be correctly loaded. The modification method and content are shown in. After the modification, the system is restarted and the hard disk expansion process is completed successfully.


At this step, we have already introduced how to dynamically expand Linux hard disks in VMWare. However, we still need to pay attention to the following aspects, as mentioned in step 1. Another point that needs to be noticed is to delete/dev/sda3 after execution and restart the operating system with the following error message:


This is because the content in/etc/fstab needs to be loaded at system startup, and the/dev/sda3 partition has been deleted, so an error occurs when parsing the corresponding content, in this case, you need to fix the file content, remove the content corresponding to/dev/sda3, enter vi/etc/fstab at the # prompt, and the interface shown is displayed:


Note that the text readonly in the last line in brackets indicates that the file is a read-only file. In this case, You need to exit the vi editor and execute mount-o remount and rw /. In this way, you can modify the/etc/fstab file, remove the/dev/sda3 line, and then run reboot to restart the system.


Now, we have introduced in detail how to dynamically expand Linux hard disks under VMWare and how to solve possible problems.


The following section does not describe how to format the hard disk, format the hard disk in the next article, and possible errors!

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.