VirtualBox is a free solution to host virtual machines on your computer. It provides configuration options for many components on our machine such as memory, storage, networking, etc. It also allows us to resize our machine storage after its operating system is installed. LVM is a volume manager in a Linux platform that helps us to allocate partitions in the system and configure the storage size that will be utilized for a specific volume group. There are some points to be noticed when we work with LVM on VirtualBox to resize our storage. These are some steps that need to be performed.
1. Stop your machine before resizing the storage.
2. Set new storage size using GUI by selecting "File > Virtual Media Manager > Properties" then find the desired virtual hard disk name that will be resized. OR, by running a CLI program located in "Program Files\Oracle\VirtualBox\VBoxManage.exe".
cd "/c/Program Files/Oracle/VirtualBox"
./VBoxManage.exe list hdds
./VBoxManage.exe modifyhd <UUID> --resize <size in MB>
3. Run your machine
4. Check your virtual group path by running df -lh
, then find a path that is mounted on /
. For example, it may be displayed similar to /dev/mapper/ubuntu--vg-ubuntu--lv
5. Check un-partitioned disk by running fdisk -l
6. If an error message like "GPT PMBR size mismatch (20971519 != 61439999) will be corrected by w(rite)." is shown, it means we utilize GPT partitioned drives. Run parted -l
then type "Fix". If you run fdisk -l
, an error message won't be displayed.
7. Add a new partition.
fdisk /dev/sda
m
to see available commandsn
create a new partition- The partition number is set to the default value
- The first sector is set to the default value. It is based on the last sector of the existing partition + 1.
- The last sector is set to the default value
p
to show partitions tablew
write changes
8. Check virtual group name by running pvscan
. For example, "ubuntu-vg"
9. Review the new partition number, for example, "/dev/sda4". Create physical volume for the new partition by running pvcreate /dev/sda4
.
10. Extend new physical volume to a virtual group by running vgextend ubuntu-vg /dev/sda4
.
11. Review virtual group path, for example, "/dev/mapper/ubuntu--vg-ubuntu--lv", expand the size by running lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
12. Resize file system by running resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
thank you very much, helped me a lot
ReplyDelete