VirtualBox Linux System Expansion __linux

Source: Internet
Author: User

When you started installing a Linux virtual machine, think about giving a 10G enough. The result is to write the code to install an eclipse, but also to download a large code file, so sad to rush. The internet has a way of sorting it out and writing it here:


The following steps are needed to expand the Linux system on a virtual machine:

1. VirtualBox on the hard disk expansion.

2. mount a new disk partition on the Linux system.

3. Modify the Mount disk partition permissions.


Let's say we need to add 30G of space to the Linux virtual machine. Linux system is Ubuntu


1. VirtualBox to the virtual machine hard disk expansion.

Open the Command Window CD to the VirtualBox installation directory, and then use the command: Vboxmanage modifyhd <path to your vdi>--resize the size in <new. Here 30G = 1024M = 30720M.

This time turn on your virtual machine settings-storage-sata Controller-UBUNTU.VDI, you can see the virtual allocation space has been 40 g (the original 10g+ extended 30G).


2. mount a new disk partition on the Linux system.

On the VirtualBox to the virtual machine hard disk expansion is not enough, if you use Fdisk-l to view the disk partition, found that the amount of the original point or place. It's like you're adding a new hard drive to your computer, but turning on my computer doesn't have much room on the disk. So to really take advantage of this new capacity, you need to tell the system where your added capacity is.

Before you mount a new disk partition to your Linux system, understand what the partition is and what rules are in the partition http://vbird.dic.ksu.edu.tw/linux_basic/0130designlinux_2.php

Before continuing, please note that the following numbers may be different from those on your computer. Please refer to the specific circumstances on your own system to change.

First, let's take a look at the current partitioning situation: sudo fdisk-l


Device Boot Start End Blocks Id System
/DEV/SDA1 * 2048 15728639 7863296 Linux
/dev/sda2 15730686 16775167 522241 5 Extended
/dev/sda5 15730688 16775167 522240 Linux Swap/solaris

There are currently two primary partitions, a logical partition, on this system. We can add a primary partition and allocate the capacity of the 30G we have extended.

Using the command sudo FDISK/DEV/SDA, this time will show you to enter the commands command "command (M for help):" Enter m to return assistance information.

Command Action
A toggle a bootable flag
b Edit BSD Disklabel
C Toggle the DOS compatibility flag
D Delete a partition
L list known partition types
M Print this menu
n Add a new partition
o Create a new empty DOS partition table
P Print the partition table
Q Quit without saving changes
s create a new empty Sun Disklabel
t change a partition ' s system ID
U Change display/entry units
V Verify the partition table
W Write table to disk and exit
X Extra functionality (experts only)

You can see a series of commands, where we need to use the ' n '--Add a new partition, enter n

Partition Type:
P Primary (1 primary, 1 extended, 2 free)--This indicates that there are two primary partitions, and you can create two (but we'd better not create four primary partitions, see the link before)
L Logical (numbered from 5)--This means that the number of logical partitions starts at 5 (for what, see previous link)

This time he will ask you the type of new disk partition and tell you the current type of disk in parentheses. We then enter p to create the primary partition.

This time it will ask you the partition number, the default is 3. Please enter 3

Then it asks you where the disk partition started (15728640-83886079, default 15728640):

You might wonder how this 15728640 came in, and we'll see the disk partition information we've seen before:

Device Boot Start End Blocks Id System
/DEV/SDA1 * 2048 15728639 7863296 Linux
/dev/sda2 15730686 16775167 522241 5 Extended
/dev/sda5 15730688 16775167 522240 Linux Swap/solaris

See the red mark out of the number of wood there is that plus one, if we use this default number, you will find that when he wants you to enter the location of the end of the disk partition, the number that can be reached is not 83886079, but 15730685, this is why, because 15730686 ~ 16775167 has been used by SDA2. So we're going to type 16775168 here, which is the position that starts behind the sda2, and then enter.

This time it will ask you where the end of the disk partition is, you can enter 83886079, which means that you add all the additional disk space.

The final input command ' W ' is saved. You can query the current disk partition status, you will find your new/dev/sda3 Oh, haha ~ ~


The partition is new, we need to format it before we can use it: mkfs-t Ext3/dev/sda3

Then we need to mount the file directory up. Let's say we want to hang in the directory/home/work, then use the command: sudo mount/dev/sda3/home/work.

If you want to mount automatically every time you turn on, add a line to the/etc/fstab file

/dev/sda3/home/work ext3 defaults, 0 1


3. Modify Disk partition permissions

Disk partitions are built, but you have wood to find your wood has permission to create folders inside. We are in the/home directory Ls-all, found that the work folder permissions to root all .... So we need to modify the following permissions:

chmod 777/home/work

Okay, so it's really done. Ha ha..

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.