Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does Linux change the disk capacity of a VirtualBox virtual machine

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how Linux changes the disk capacity of VirtualBox virtual machine". The explanation in this article is simple and clear, and is easy to learn and understand. Please follow the editor's train of thought to study and learn "how Linux changes the disk capacity of VirtualBox virtual machine".

1. Start the CMD command line and go to the directory where VirtualBox is installed. Such as

Cd E:\ Program Files\ Oracle\ VirtualBox

two。 View the virtual hard disk that needs to be modified:

E:\ Program Files\ Oracle\ VirtualBox "VBoxManage.exe list hdds

UUID: e8e2c341-b3b1-49db-ad2d-ab4e6b08bc5a

Parent UUID: base

State: locked write

Type: normal (base)

Location: F:\ VM\ CentOS-64.vdi

Storage format: VDI

Capacity: 8000 MBytes

UUID: 707d45b6-380d-4e51-96bd-8c9508bfd313

Parent UUID: base

State: created

Type: normal (base)

Location: F:\ VM\ CentOS-64-ext.vdi

Storage format: VDI

Capacity: 21273 MBytes

UUID: aca81637-fbc0-4826-be66-847ecc96d83b

Parent UUID: base

State: created

Type: normal (base)

Location: C:\ Users\ Edward.Wu\ VirtualBox VMs\ WinXP\ WinXP.vdi

Storage format: VDI

Capacity: 10240 MBytes

We see that there are three virtual disks, and we are going to modify the first one in the figure, which has a space size of 8G gravitational UUID, e8e2c341Murb3b1-49db-ad2d-ab4e6b08bc5a.

two。 Adjust the disk space to 15g:

E:\ Program Files\ Oracle\ VirtualBox "VBoxManage.exe modifyhd e8e2c341-b3b1-49db-ad2d-ab4e6b08bc5a-- resize 15000%. .10%. .20%. .30%. .40%. .50%. .60%. .70%. .80%. .90%. .100%

Review again:

E:\ Program Files\ Oracle\ VirtualBox "VBoxManage.exe list hdds UUID: e8e2c341-b3b1-49db-ad2d-ab4e6b08bc5a Parent UUID: base State: locked write Type: normal (base) Location: F:\ VM\ CentOS-64.vdi Storage format: VDI Capacity: 15000 MBytes

UUID: 707d45b6-380d-4e51-96bd-8c9508bfd313 Parent UUID: base State: created Type: normal (base) Location: F:\ VM\ CentOS-64-ext.vdi Storage format: VDI Capacity: 21273 MBytes

UUID: aca81637-fbc0-4826-be66-847ecc96d83b Parent UUID: base State: created Type: normal (base) Location: C:\ Users\ Edward.Wu\ VirtualBox VMs\ WinXP\ WinXP.vdi Storage format: VDI Capacity: 10240 MBytes

4. View new disk space

Restart the virtual machine to check the disk condition.

[root@aimin ~] # fdisk-l / dev/sda

Disk / dev/sda: 15.7 GB, 15728640000 bytes 255 heads, 63 sectors/track, 1912 cylinders

You can see that the disk space has been expanded to 15G, but it is not available at this time.

New space added by 5.Enable

Use fdisk to create a new partition of the free space of the virtual disk. Note that the partition number 8e representing Linux LVM is used as the ID.

# fdisk / dev/sda

N {new partition}

P {primary partition}

3 {partition number}

[at this time, you will be prompted to change the size, and select enter directly by default]

T {change partition id}

3 {partition number}

8e {Linux LVM partition}

W

-

If there is a hint such as setting the size in the middle, enter directly.

When you are finished, if prompted:

WARNING: Re-reading the partition table failed with error 16: the device or resource is busy. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe (8) or kpartx (8)

Just restart the system.

6. Check to see if the newly added sda3 is marked as LVM, if reboot is not needed

# fdisk-l / dev/sda

7. Resize LVM

Take a look at the Volume Group name first.

[root@aimin] # vgdisplay-Volume group-VG Name vg_aimin

. . . .

Vg_aimin is the name of my VolumeGroup. In practice, you need to use the name that is actually displayed.

8. Create a new physical volume from the newly allocated space

# pvcreate / dev/sda3

9. Then use the new physical volume to extend LVM's VolGroup

# vgextend vg_aimin / dev/sda3

No physical volume label read from / dev/sda3

Writing physical volume data to disk "/ dev/sda3"

Physical volume "/ dev/sda3" successfully created

Volume group "vg_aimin" successfully extended

10. Then extend LVM's logical volume vg_aimin-lv_root

# lvextend / dev/vg_aimin/lv_root / dev/sda3

11. Resize logical volumes

# resize2fs / dev/vg_aimin/lv_root

The expansion of the space is completed here.

twelve。 View the effect

[root@aimin ~] # df-h File system capacity available% mount point / dev/mapper/vg_aimin-lv_root 12G 5.2g 6.2g 46% / tmpfs 499m 80K 499m 1% / dev/shm/dev/sda1 485m 33M 427m 8% / boot

Successful expansion!

Thank you for reading, the above is the content of "how Linux changes the disk capacity of VirtualBox virtual machine". After the study of this article, I believe you have a deeper understanding of how Linux changes the disk capacity of VirtualBox virtual machine, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report