This started as a simple note to myself. It's originated from numbers of google search and trail and fail. Hopefully good enough for anyone to use as reference.
Tested: CentOS7 on VirtualBox 5.0.0r on Windows 7x64
Warning!
When doing file system operation: make sure you are on your guestOS, mistake in file system tool can ruin your data. Make sure you have your data backup.
Tested: CentOS7 on VirtualBox 5.0.0r on Windows 7x64
Warning!
When doing file system operation: make sure you are on your guestOS, mistake in file system tool can ruin your data. Make sure you have your data backup.
- Step 1, on Host Side, shutdown guestOS
- Assuming you are expending to 80GB, run command line:
C:\Users\yourname> "Program Files\Oracle\VirtualBox\VBoxManage.exe" modifyhd --resize 81920 "C:\Users\yourname\VirtualBox VMs\Centos7x64\Centos7x64.vdi"
It should be done instantly. - On the Guest Side
$> su # to get root privileg - # > fdisk -l ## to list devices
## note the illustrated is run after extension is done, not sure how it looks like before completion of the full sequence.
- #> fdisk /dev/sda
>> to add another primary partition (command n)
>> Select Partition type (default p, press enter)
>> next free number (e.g. 3, press enter)
>> print partition table (p), write table (w). Then Reboot ...
- Add new partition as physical volume (PV)
# > lvm
lvm> pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created - lvm> lvdisplay ## to find your volume group info, and partition name
- Extend existing volume group (VG)
lvm> vgextend vg_centos /dev/sda3
Volume group "vg_centos" successfully extended - Extend logic volume, you can run this command multiple time until running out of available space, use "lvdisplay" to find out available space, vlm uses 4MB page size.
lvm > lvextend -L+8.48G /dev/vg_centos/root
Rounding size to boundary between physical extents: 8.48GiB
Extending logical volume lv_root to 25.56GiB
Logical volume lv_root successfully resized.
- Give your GuestOS internet access for xfsprogs installation
- You will likely have to kill yum to avoid "yum lock" hassle.
$> ps aux | grep yum
$> kill <process_id> ## to stop PackageKit - $> sudo yum install xfsprogs.x86_64 --assumeyes
# you need to mount the filesystem so you can resize, but for root parition which is already mounted, following steps are not necessary.
$> sudo mount -t xfs /dev/sdf /vol - $> sudo xfs_growsfs /root
- $> df -h ## should show you more available space.
- Useful tool: "xfs_info", "lsblk",
Reference and Acknowledgement: