VBox Linux virtual machine root partition expansion

Source: Internet
Author: User
Tags uuid gparted

Objective

Using Linux for a period of time vbox may show that the root partition is out of space and needs to be expanded.

By consulting relevant data, there are two main ways to expand Linux in VBox: Through the expansion of LVM and through gparted capacity expansion

LVM condition: Linux systems in VBox use LVM to manage disks

GParted condition: Linux system Image (ISO) with GParted

determine if you can scale through LVM :

Terminal input "VGs", display "No volume groups found" can not use LVM expansion

The following shows the ability to use LVM for expansion:

  VG      #PV #LV #SN Attr   vsize  vfree   xiaoluo   2   0   15.99g  
Expansion via LVM

The basic knowledge of LVM can be referred to the following two articles, only according to the operation of this article can be completed successfully

    Basic concepts of LVM logical volumes and how LVM works

    The creation and use of LVM logical volume

First step: Add a virtual hard disk

Close the virtual machine, in the Virtual machine settings screen, select the "Storage" tab, click on the "Add Virtual hard disk" icon

Follow the prompts to complete the Add.

Step Two: partition and format the new hard drive

After adding a new hard disk, type "Fdisk-l" in the terminal to see the newly added hard drive, I'll show it as "/dev/sdb"

Type "Fdisk/dev/sdb" to start partitioning the new hard disk

Create a new partition by typing "n" on the new command line

Direct carriage return as primary partition

Type the partition number, or enter the default 1 directly

    Enter default from 2048 as the starting sector for this partition

    Enter default last sector as end sector

Type "W" to save and exit, now get/DEV/SDB1 partition, it is recommended to restart the following virtual machine

Step Three: Add the new partition to the LVM and expand the capacity

Type "pvcreate/dev/sdb1"

      Physical volume "/dev/hda4″successfully created

    Type "VGS" To view the volume group name, such as "Xiaoluo" or "VolGroup00"

Type "Vgextend volgroup00/dev/sdb1" to add a new partition to the volume group

Type "LVS" to see the logical volume names to be expanded, such as "LogVol00"

type " lvextend-l +4096m/dev/volgroup00/logvol00 "Extended logical partition, where" +4096m "represents an increase of 4G space

Type "Resize2fs-p/dev/volgroup00/logvol00" to activate the new space

Now type "Df-h" to see the space after expansion

expansion through GPartedFirst step: Convert VMDK format virtual hard disk to VDI format

(If your virtual hard disk is in VDI format, skip to the second step)

Locate the VBox installation directory and enter the CMD interface, mine is: H:\Program Files\oracle\virtualbox

Type "Vboxmanage list HDDs" To view the existing virtual hard disk, locate the virtual hard disk of the virtual machine to be expanded, record the next location

type Vboxmanage Clonehd "H:\Users\liber\VirtualBox vms\kali_iso\-disk1.vmdk" "H:\Users\liber\VirtualBox Vms\kali_iso\-disk1.vdi"--format VDI converts VMDK to VDI

Then uninstall the old VMDK in the virtual machine's settings and hang it in the new VDI

Step Two: Expanding the VDI format virtual hard disk

Type "Vboxmanage list HDDs" to view the UUID of the VDI file to be expanded and log

Type "Vboxmanage Modifyhd your uuid--resize 40960" to expand it to 40G, where 40960 represents the new size

Step Three: expanding the Linux root partition

In the settings screen of the virtual machine, select the "Storage" tab, click "Add Virtual CD drive", click "Select Disk" to browse the Linux ISO file, I am here kali-linux-1.1.0a-amd64.iso, then determine

(if there is an empty virtual optical drive to be removed, the boot will not boot from the CD drive)

On the System tab, adjust the optical drive to the highest priority

Boot the virtual machine from the virtual CD, select LiveCD mode, I am here "Live (AMD64)", this mode is not installed, only experience

Entering the system and entering gparted in the terminal will start the GParted graphical interface

The hard drive structure should now look like this:

/dev/sda

|---/dev/sda1 (EXT4, to enlarge)

|---/dev/sda2 (extended,885m)

| |---/dev/sda5 (linux-swap,885m)

|---Unallocated (unallocated, pending allocation)

Unallocated is our unallocated space,/dev/sda2 is virtual memory in Linux, used when a large program cannot mount memory at one time.

We can delete the/dev/sda5 first and then delete the/dev/sda2. And then there's only a partition and unallocated space left.

Right-click to expand the partition, select resize can be expanded, but note that here to leave a portion of space as a LINUX-SWAP partition as virtual memory

      

After the partition is expanded, right-click the new Linux-swap on the remaining unallocated space:

1. Select "Extended Partition" from the "Create as" drop-down menu in the new window

2. Right-click on the unallociated space in the built-in extended partition, new, "Create as" select "Linux-swap" to

Click the Apply button above to take effect.

Then remove the ISO CD drive and enter the virtual machine to discover that the root partition has been successfully expanded

Writing articles is not easy, reprint please indicate the source

    

VBox Linux virtual machine root partition expansion

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.