VMware Ubuntu 12.04 partition Dynamic adjustment notes

Source: Internet
Author: User
Tags rsync

Overview

When you install Ubuntu 12.04 in WMware, the partition size defaults to 20G, and the root directory size is only 12G after the installation is complete. Since the original plan is to put the source into a separate mounted partition, it feels that 12G should be enough. But in the Android source code compilation process encountered a problem of insufficient space, source code compilation will eventually be the relevant IMG files compressed into a ZIP package, this step will temporarily use the/tmp directory. Because the root directory is only 12G, plus/home under a bit of things, Android source code compilation last package, the root space is not enough to pack the operation was terminated.

The purpose of this article is to dynamically adjust the partition size, expand the root partition capacity, and avoid Android compilation cannot be packaged.

Reprint please be sure to indicate the source Http://blog.csdn.net/yihongyuelan

Step Partitioning expansion Plan

It is mentioned in the overview that the original root partition is only 12G, and this article plans to replace it with 20G. Instead of replacing the 12G root partition with a 20G root partition, it will also have 12G of capacity and plan to use this 12G for/home standalone. The adjusted hard drive mount condition is shown in 1:


Figure 1 WMware Mount drive information after adjustment

Use df-h in Ubuntu to view the partition as shown in Scenario 2:


Figure 2 Viewing partition information in Ubuntu

As you can see from Figure 2, the root partition changes from/dev/sda1 to/DEV/SDC1 and the size from 12G to 20G, and the original/dev/sda1 is mounted to the/home directory.

Create a new virtual hard disk

To add a new hard disk in the wmware->settings, the steps are simpler and more specific than the table. When specifying the disk capacity, it is recommended to tick allocate all disk space immediately, 3:


Figure 3 Tick "Allocate all disk space now (A)"

Root partition migration

After you've finished adding your new hard drive, remember to partition and format your new hard drive in Ubuntu using FDISK or the Disk Utility tool, and then back up your original root directory. After the new hard drive is formatted and the partition is complete, here is/DEV/SDC1, which is mounted to the/new_root and executed in the terminal:

sudo mkdir/new_rootsudo mount/dev/sdc1/new_root
Because the current root directory needs to be migrated, you need to build a backup directory/old_root and mount the current root directory to/old_root (the current root directory is/dev/sda1), so the operation is as follows:
sudo mkdir/old_rootsudo mount/dev/sda1/old_root
You then need to use the rsync command to complete the migration of the root directory.

Rsync is a data-mirroring Backup tool for Unix-like systems, remote sync. Rsync is a file synchronization and data Transfer tool under the Linux system that allows file synchronization between the client and remote file servers, and the ability to back up data from one partition to another on the local system. If Rsync has a data transfer interruption during the backup process, it can continue to transmit inconsistent portions after recovery, and rsync can perform a full or incremental backup (specific information can be man, Chinese translation reference here).

Using the Rsync command, back up the/old_root to/new_root:

sudo rsync-lva/old_root/. /new_root
Parameter explanation:

-L means keep soft links;

-A represents the archive archive mode, which means that files are transferred recursively, and all file attributes are maintained, equal to-rlptgod;

-v means verbose output of the operation process;

Uninstall Old_root after completion:

sudo umount/old_root

Modify/etc/fstab

Because/new_root follow-up is the new root partition, so you need to modify the/new_root under the Fstab file, that is,/new_root/etc/fstab, modified as follows:

#UUID =46df0a25-8f0f-4ef5-90c0-8a665f4ab82d/               ext4    errors=remount-ro 0       1/dev/sdc1/               ext4    Errors=remount-ro 0       1
The first line indicates that the original root mount is commented out, and the second line indicates that the new device is/DEV/SDC1 mounted to the root directory.

Because you want to switch the boot partition to/DEV/SDC1, update the boot-related information to the Grub menu and continue executing in the terminal:

sudo grub-install/dev/sdc
In the Grub boot menu, add/DEV/SDC, and then update the GRUB boot menu:
sudo update-grub

Change boot order now device/dev/sda1 is the original root directory (Old_root), the new device/DEV/SDC1 is the new root directory (New_root), has been added to the Grub boot menu, you need to set which device priority load, that is, the boot sequence. Modifying the boot order is essentially entering the BIOS and setting the load order of the hard drives.

After completing the above operation, select Restart, and quickly short press F2 (the virtual machine power on the prompt), enter the BIOS interface, through the left and RIGHT arrow keys to select the "Boot" menu, and through the upper and lower arrow keys to select the Hard Drive submenu, 4:


Figure 4 WMware BIOS interface

Add the newly added hard disk/DEV/SDC1 through +/-to the first of the bootable add-in cards, where VMware Virtual SCSI Drive (0:2) is saved and exited by F10 and then restarted to enter the system. After you complete the above operation, the migration of the root partition is roughly complete.

Standalone/home partition

The root partition has been switched from/DEV/SDA1 to/DEV/SDC1, so/dev/sda1 is no longer available, and I intend to use it as the/home standalone partition for maximum resource utilization, while the operation steps are similar to that of backing up the root partition. Create a new/home_new, mount the/dev/sda1 to/home_new, delete the contents of the/dev/sda1, and sync the contents of home/home to/home_new via rsync, rename/home to/home_bak,/ Home_new Rename to/home, and modify/etc/fstab as follows:

/DEV/SDA1/home       ext4 defaults,user,exec,dev,suid 0 0

After the save is restarted, you can see the effect in 5 by df-h:


Figure 5 The adjusted partition

Problems encountered

Although the steps described in the article are clear, many pits are encountered in the actual operation, such as:

1. Start execution if the/old_root folder is not established

sudo rsync-lva//new_root
This results in a recursive backup, that is,/new_root/new_root/new_root/.... Infinite cycle down;

2. If found in the/new_root directory./And. /ower and group wrong, executable

sudo chown root:root./. /
Summarize

Because the root partition was set too small, resulting in the source code compilation package time and space, so that the package operation cannot be completed, the root partition after the problem resolution. If there is a problem with the reload system, the standalone/home partition can be reused, and many configurations do not have to be set again.

VMware Ubuntu 12.04 partition Dynamic adjustment notes

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.