Extended Linux hard disk space under VMware __linux

Source: Internet
Author: User
Tags extend

Many people will choose to install Linux virtual machines on VMware while learning Nutch, Hadoop or familiar Linux operating system, and often do not want to allocate to the Linux virtual machine large enough hard disk space, which makes it easy to use Linux for a period of time, found that the virtual machine is not enough space on the hard disk, how to solve this time. Some people directly choose to reinstall the Linux virtual machine, but the next hard drive is not enough, but also to reinstall the operating system, then the next time. This approach is bound to go into a repetitive boring process, in addition to increasing the proficiency of the installation operating system and waste a lot of time, there is no merit. To address this very likely issue, this article describes how to dynamically extend the Linux hard drive on VMware, which is already installed on the Linux operating system, to solve the problem of insufficient hard disk space on the Linux virtual machine and to avoid reinstalling the Linux operating system.

This article is based on VMware Workstation 9 and Red Hat Enterprise Linux 6, and the remaining versions are not fundamentally different.

1. Start VMware Program, click "Edit Virtual machine settings", as shown in the following figure.


2. In the pop-up dialog box, click on the "Hardware" tab, you can find hard disk space size of 20G, click on the right side of utilities, select "Expand".


3. In the Next pop-up dialog box, select the maximum size of the hard drive, set to 30G here, click the expand button.


4. Extending the hard disk space takes a while, as shown in the following illustration:


5. After the successful expansion of the hard disk, it is necessary to repartition the hard disk and extend the file system on the client (that is, the Linux virtual machine).


6. Start the Linux virtual machine and log in as root, because the following operations require the root user's privileges. Open the terminal window and enter "Df-h" to view the file system. As shown in the following figure, you can see the size of the/home in my virtual machine is 2.2G, the usable capacity is 83M, the goal of this extended hard disk is to increase the size of the/home directory, note that the file partition is/dev/sda3, the following operations are mainly for the partition.


7. The following FDISK–L command to view the hard disk partition, you can find that hard disk space has indeed been extended to 30G.


8. Hard drive/DEV/SDA now hard drive operation, execute command FDISK/DEV/SDA, enter d (delete partition command) After command, then enter the number that needs to delete partition, here Enter the partition that wants to delete 3, enter p after completion, view hard disk partition situation,/dev The/sda3 has been removed.


9. Now, if you want to allocate the extended space to the/home directory, it is still not possible, because there is also a swap partition, which will result in the inability to allocate the remaining space (both the new space and the previously/home directory space), so you also need to delete the partition 4, step and 8th introduction.

10. Enter the Fdisk–l command again (the reason is to verify the hard disk space partition, because the hard disk partition needs careful operation, only to ensure that the previous operations have been properly executed, subsequent operation may not be the problem), found that/dev/sda3,/dev/sda4 have been deleted. Then execute FDISK/DEV/SDA to the hard disk new partition, at command prompt input n (new partition), the hint is the primary or extended partition, select P (primary partition), enter the partition number 3, enter the starting and ending cylinder number, The start number is selected by default (or you can customize the start number so that extra hard disk space is left), and the end number is not selected by default in this operation because there is also room for the swap partition, where the swap partition is set to 2g,/dev/ The ending number of the Sda3 can be calculated from (3661).


11. If Linux installs the desktop application, you can also use the graphical disk utility, here to allocate swap partition as an example, a brief introduction. Select the disk utility in the application, open the interface shown in the following figure, click on the hard drive at the bottom of the left, select the free space on the right, click the Create partition below, select the partition size, type, click the Create button, and complete the partition creation.


12. After the partition is created, the new partition will be mounted to the/home directory, execute the command mount/dev/sda3/home, then perform the df–h view file system, the execution process and the result see the following figure.


13. Mount the partition to the/home directory, you also need to modify the/etc/fstab, the/dev/sda3 and/home directory of the relationship to add, so that the system in the boot can load the directory correctly, modify the method and content as shown in the following figure, after the modification of the system to restart, The process of extending the hard drive completed successfully.


At this point, VMware's dynamic expansion of the Linux hard drive has been introduced, but there are still a few places to pay attention to, such as the 9th step mentioned. There is also a place to draw everyone's attention, that is, after the completion of the deletion of/dev/sda3, restart the operating system will appear in the following image error message:


This is because the contents of the/etc/fstab need to be loaded when the system is started, and the/dev/sda3 partition has been deleted, so there will be an error parsing its corresponding content, the contents of the file need to be repaired, the contents of the/dev/sda3 should be removed, and the # prompt should be entered vi/etc /fstab, the interface shown in the following illustration appears:


Note that the text readonly in parentheses in the last line of the previous figure indicates that the file is read-only, and you need to exit the VI editor and execute Mount–o remount, RW/. This can modify the/etc/fstab file, remove the/dev/sda3 line can be completed after the implementation of the reboot, restart the system.


At this point, we have described in detail how to dynamically extend the Linux hard drive under VMware, and how to solve the problems that may arise.



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.