MAC VirtualBox virtual machine expands disk via LVM

Source: Internet
Author: User
Tags uuid

1, first turn off the virtual machine, view the hard disk allocation properties: For dynamic allocation of storage

2, enter virtual box installation directory

#cd/users/gds/virtualbox vms/gds
#VBoxManage list HDDs
UUID:           2fb7b86c-64f7-467b-9d45-de6df399e325
Parent UUID:    base State
:          created
Type:           Normal (Base)
Location:       /users/gds/ VirtualBox vms/gds/gds.vdi
Storage format:vdi
Capacity:       32768 MBytes
:     Disabled

Hard drive uuid:2fb7b86c-64f7-467b-9d45-de6df399e325, size: 32768 MBytes

3. Adjust disk space->60g

#VBoxManage MODIFYHD 2fb7b86c-64f7-467b-9d45-de6df399e325--resize 60000
0% ... 10%.. 20%.. 30%.. 40%.. 50%.. 60%.. 70%.. 80%.. 90%.. 100%

#VBoxManage list HDDs
uuid:           2fb7b86c-64f7-467b-9d45-de6df399e325
Parent UUID:    base
State:          created
Type:           Normal (Base)
Location:       /users/gds/virtualbox vms/gds/gds.vdi
Storage format:vdi
Capacity:       60000 MBytes encryption
:     disabled

4, restart the virtual machine to make it effective:

#fdisk-L/DEV/SDA disk/dev/sda:58.6 GiB, 62914560000 bytes, 122880000 sectors units:sectors of 1 * * * * bytes Sec Tor size (logical/physical): bytes/512 bytes I/o size (minimum/optimal): bytes/512 bytes Disklabel Type:dos D ISK identifier:0xbbef9801 device Start start end sector Size Id type/DEV/SDA1 * 2048 62914559 62912512 30G L Inux/dev/sda2 62916606 67106815 4190210 2G 5 extension/dev/sda5 62916608 67106815 4190208 2G Linux switch/S
Olaris #fdisk/DEV/SDA Welcome to fdisk (Util-linux 2.27.1).
Changes'll remain in memory only, until you decide to write them.


Be careful before using the Write command. Command (input m get help): M Help:dos (MBR) A toggle a bootable flag B edit nested BSD disklabel C toggle the DOS Compatibility Flag Generic D Delete a partition F list free unpartitioned spaces l list known partition t Ypes n Add a new partition P print the partition table T change a partitionType v Verify the partition Table I print information about a partition Misc m print this menu u ch Ange display/entry units x extra functionality (experts only) script I load disk layout from Sfdisk script fi Le O dump disk layout to Sfdisk script file Save & Exit W Write table to disk and exit Q quit Withou T saving changes create a new label G create a new empty GPT partition Table G Create a new empty SGI (IRIX) Partition table o Create a new empty DOS partition table s create a new empty Sun partition Table:f Unpartitio Ned space/dev/sda:26.6 GiB, 28555870208 bytes, 55773184 sectors-units:sectors of 1 *-The bytes sector size (logic al/physical): bytes/512 bytes Start end sector Size 67106816 122879999 55773184 26.6G Here you need to be aware that you cannot use the default start sector. Use the unpartitioned start sector to add the partition that you want to add, otherwise a separate partition command (input m get help): N Partition type P Primary (1 primary, 1 extended, 2 free ) L Logical (numberEd from 5) Select (default p): P partition code (3,4, default 3): 3 sector (62914560-122879999, default 62914560): 67106816 Las  T sector, +sectors or +size{k,m,g,t,p} (67106816-122879999, default 122879999): Created A new partition 3 of type ' Linux '
And of size 26.6 GiB.
Command (input m get help): W The partition table has been altered.
Calling IOCTL () to re-read partition table. Re-reading the partition table failed.: Device or resource busy the kernel still uses the old table.
 The new table is used at the next reboot or after you run Partprobe (8) or KPARTX (8).

5, restart

Fdisk-l/dev/sda
disk/dev/sda:58.6 GiB, 62914560000 bytes, 122880000 sectors Units:sectors of
1 * A TES
Sector Size (logical/physical): bytes/512 bytes
I/o size (minimum/optimal): bytes/512 bytes
Di Sklabel type:dos
Disk identifier:0xbbef9801

device       start    start    end   sector  Size Id type
/dev/ SDA1  *        2048  62914559 62912512   30G Linux  /dev/sda2 62916606 67106815 4190210    2G  5 extended
/dev/sda3       67106816 122879999 55773184 26.6G Linux
/dev/sda5       62916608  67106815  4190208    2G Linux swap/Solaris

Partition table entries are not in disk order.

Visible/dev/sda3 has joined in.

6, extended volume group, logical volume
Install Lvm2,sudo apt-get Install lvm2 and view Volume group:

Vgdisplay
  /run/lvm/lvmetad.socket:connect failed: No file or directory
  warning:failed to connect to Lvmetad. Falling back to internal scanning.

Error, perform the following actions:

root@gds$ systemctl Enable Lvm2-lvmetad.service
synchronizing state of Lvm2-lvmetad.service with SYSV init with/lib/
Systemd/systemd-sysv-install ... Executing/lib/systemd/systemd-sysv-install Enable Lvm2-lvmetad
root@gds$ Systemctl enable Lvm2-lvmetad.socket
root@gds$ systemctl start lvm2-lvmetad.service
root@gds$ systemctl start Lvm2-lvmetad.socket

To create a physical volume (physical volume):

root@gds$ Pvcreate/dev/sda3
Physical volume "/dev/sda3" successfully created

Use new physical volumes to extend LVM Volgroup:
Through Vgdisplay to view your system directory/volume group, this article is: Volgroup-lv_root

Extend existing vg:vgextend Volgroup-lv_root/dev/sda3 through the vgextend command
Then expand the LVM logical volume Volgroup-lv_root:
Lvextend-l +26g/dev/mapper/volgroup-lv_root

Resize a logical Volume: Resize2fs/dev/mapper/volgroup-lv_root

So, OK.

If the expanded partition is not in LVM management, you can create a directory by mount, and then mount the directory on the partition, such as Mount/dev/sda3/home/data, for expansion purposes.

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.