Get the App
SLTechnology News&Howtos  ›  Servers  › 

Virtual linux disk expansion under VM VirtualBoX

Shulou Source: shulou.com Published: 2022-06-02 20:58:37 09月22日 Update

My VirtualBox virtual machine linux system has a total of 8 gigabytes of disks. I need to expand the capacity.

Reference blog: https://www.cnblogs.com/anjingshen/archive/2015/10/17/4887426.html

Reference blog: http://blog.jues.org.cn/post/resize2fs-bad-magic-number-in-super-block-dang-chang-shi-da-kai-devcentosvir-centos7root-shi-zhao-bu-dao-you-xiao-de-wen-jian-xi-tong-chao-ji-kuai-..html

The steps for capacity expansion are as follows:

1. Add a new virtual disk and create it as prompted.

2. There is an extra sdb in lsblk query.

3. Partition and format the new hard disk

Type "fdisk / dev/sdb" to start partitioning the new hard drive

Type "n" on the new command line to create a new partition

Enter directly as the main partition

Type the partition number, or enter directly by default 1

Enter defaults to 2048 as the start sector of this partition.

Enter defaults to the last sector as the end sector

Type "w" to save and exit, now get the / dev/sdb1 partition, it is recommended to restart the following virtual machines

4. Add a new partition to lvm and expand its capacity

Type "pvcreate / dev/sdb1"

Physical volume "/ dev/hda4" successfully created

Type "vgs" to view the volume group name, such as "centos" or "VolGroup00"

Type "vgextend centos / dev/sdb1" to add a new partition to the volume group

Type "lvs" to view the name of the logical volume to be expanded, such as "root"

Type "lvextend-L + 2048m / dev/centos/root" to expand the logical partition, where "+ 2048M" indicates an increase of 2G space (usually this is smaller than 2048).

Type "resize2fs-p / dev/centos/root" to activate the new space

Note: if it is a xfs file system, you cannot use resize2fs, but use xfs_growfs / dev/centos/root to activate it.

Tags: Blog activation hard disk space system logic reference disk name command dot suggestion number file format step prompt query Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Linux Xiaomi Docker Shulou Information